From 7b0956ec4f7753c864c4cea220e6f189327baa93 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 14 Feb 2018 18:21:14 +0100 Subject: [PATCH] Fix tests --- client/src/standalone/videos/embed.ts | 2 +- server/tests/api/fixtures/avatar-resized.png | Bin 2420 -> 1727 bytes server/tests/api/fixtures/avatar2-resized.png | Bin 2350 -> 1725 bytes .../tests/api/users/users-multiple-servers.ts | 6 ++---- server/tests/api/users/users.ts | 3 +-- server/tests/api/videos/multiple-servers.ts | 3 +-- server/tests/api/videos/single-server.ts | 4 +--- server/tests/api/videos/video-comments.ts | 3 +-- server/tests/utils/miscs/miscs.ts | 5 ++++- server/tests/utils/videos/videos.ts | 6 ++---- 10 files changed, 13 insertions(+), 19 deletions(-) diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index da935ef4c..925367bb9 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -7,7 +7,7 @@ import 'videojs-dock/dist/videojs-dock.es.js' import { VideoDetails } from '../../../../shared' function getVideoUrl (id: string) { - return window.location.origin + '/api/v1/videos/' + videoId + return window.location.origin + '/api/v1/videos/' + id } async function loadVideoInfo (videoId: string): Promise { diff --git a/server/tests/api/fixtures/avatar-resized.png b/server/tests/api/fixtures/avatar-resized.png index e05fc07ce896e0a096b2c58802cc2c9c9301f89a..9d84151f8e4ec30614b61a5ba36915a192644126 100644 GIT binary patch delta 1691 zcmaKteLT~N1IOh&jD#JAJcXvzP9?%lw^k$E+42x(`^vegC0Rle5OMXHj(K8v`diE4e*=E9@&{7;IEHlyQr z4wT+o6eaMmUejSJS`6f4BZsVT0ZgrriQS>&WXKmXcF6leT8s|ne@Lyy1NhEyr3_ff zVZ?8zPE)T|1aE$<9vL~GM!?~4SS&Uq9f-wwJZ(?;LvC^RiW|deJ2}8p5xuVwY9am__JkT=2us6jcAQ-Vev+{YbHZ^5?`q3@ry>(Kd5Q1-g)(91< ztE&f?g3L$oIzc6P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V~Ebu~jl|6b43a;v)CV@L!< zvjKFfaG-*@P*`}(&22C)GBF^qte>Ll=B7%6mBZV;^<*A~hKAPE*Y}QondWnx?^}-h zJ=;kWc0}bYyDC>9EW8*mf~NTFShvmq94r#8(^c|?zivZ(+1A$9+}zyQDDz8PrL>vk zdf-2|?})vR>Et+(o^v+@g6QXi=vMZ!=^d!c+^kR3YT2H19ZINTC$a8>3`IWHJlX0s zSMa7U_NUq&pm3J-U2kO{pbLq-x+<>+J((LYR*ReOF?ymtnB)a)ySuMaY+SvY{ry|` z8Dd?U*c2kjX{+OXJ~}_a@%dJo{4I1$lBpbrQFKh@NCV`5Uql`z?zwi_ck=p1R)KJh O5`jUTZ0l@%@BIf^kcNH$ diff --git a/server/tests/api/fixtures/avatar2-resized.png b/server/tests/api/fixtures/avatar2-resized.png index a2e2613bfcb89e28f8d6f03deb7c1e921917a166..44149facbe39fc9e291e81bd9a52449f24e7be0a 100644 GIT binary patch delta 1689 zcmaKtYdG779>6n<+|YRNs;CpZnvL@?VRtgVh=AZR-wEFs4LZ1MwtmH;18} zsPMUS=hL>9>6p(X2hF3!nw0}=1G~KVFNmO#n0<0@JNjQ@hyRbnCqX0sAq4TFLSD9P zy9>m+_y4%Lxe44+Bv>K`nSnCyp(s4wyt6lF*LLEZS2o%p#<3_b0H#;+7&v=`IgtD4 zZ~lFFTe4K``PEbs3C)p|m6iFPDD$>3yHPl~a$-6utnq+WXm?~PlC?@j&aA&*Sy{Pk zY24M*<4`pcY^j=B{u{zIiFB94;Y?0W0`v0;9NCi#@7C7#e~^{dHglAT?P+8(82~=I z2CdMHa9+4xJz@LT-(E^jSK%U-At042PW~^9?2J(i)GvX?MYn7*U3>4|TrK3;*doOHQd3J!AeblhB z->d1t+mG?)$rc6{RIBy;kLbZ$Q#Kj~b8Bnl@Q2uA#OxVN-M#uBsT7-X#5`Q)HRL7- zGnQ+@xyn99V)cYk5;(t2a(-0B$jIoub~?|47lI$Wg1dyPHWgrAeio5M9dBq%*>&f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rcld&js}EC9F-4yTb3p0k~O445+Mt#IL^f>B4+^zxRVGY|tJ3s9hamY|aJ zh|dD>$Nli>576|Fzgs1)+5YHzhRt>`N-UkKcvTO~$WQyI+Y)b%2fFLo;5#L(@+JSN zd6@6?Ya0kpXSy@6i1k-SmN^CLn+<~?C{_yE;9-v#03_BN-e>u}p8~6NNv)$Vc6N3; zYDichH&k>f#j_r#?)O{^ zimd;1oo?+_8yyOv-+1J$0YOHBtzR^2uB@zDlg1Pc9S>bes zW=s`XXHAysv|Ljipz1OZ~TFj%fLVvJ=OyV{Qo4;N!Fw_M!zC=MB0SR@2&jghW5 zcu2n_bn(peZX>}I zv5tFtd-D=ru))7MO!WlofB-b8n=j)eO!n9X>3s(kQd5rw?2y zO%NU6Y)|hBUG>xE7%@h34w657gH1i*34;qK^H?hcAJbR8%_x(j*(G&h;&e69+Y!qt zkwpeiAe>7|Q^}b%!gJTm_(13dw?ts2fSdNtLB43&PAW^Qd;zU0V(dOk6|q~YCNX3k w8$I^^J86!gEBje(*Dl~O|CoyZi?lOpQ18#It%|l<@dpTCcflEfx4NA9A3E2M82|tP diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index 0483b9c3d..3c4eaff14 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts @@ -65,8 +65,7 @@ describe('Test users with multiple servers', function () { const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) user = res.body - const test = await testImage(servers[0].url, 'avatar2-resized', user.account.avatar.path, '.png') - expect(test).to.equal(true) + await testImage(servers[0].url, 'avatar2-resized', user.account.avatar.path, '.png') await wait(5000) }) @@ -83,8 +82,7 @@ describe('Test users with multiple servers', function () { expect(rootServer1Get.name).to.equal('root') expect(rootServer1Get.host).to.equal('localhost:9001') - const test = await testImage(server.url, 'avatar2-resized', rootServer1Get.avatar.path, '.png') - expect(test).to.equal(true) + await testImage(server.url, 'avatar2-resized', rootServer1Get.avatar.path, '.png') } }) diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index c23b58089..ac167d4f9 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts @@ -359,8 +359,7 @@ describe('Test users', function () { const res = await getMyUserInformation(server.url, accessTokenUser) const user = res.body - const test = await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.png') - expect(test).to.equal(true) + await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.png') }) it('Should be able to update another user', async function () { diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 3646fbb0f..85d158d61 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -641,8 +641,7 @@ describe('Test multiple servers', function () { const res = await getVideo(server.url, videoUUID) const video = res.body - const test = await testImage(server.url, 'video_short1-preview.webm', video.previewPath) - expect(test).to.equal(true) + await testImage(server.url, 'video_short1-preview.webm', video.previewPath) } }) }) diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index 476a25479..8f55075fb 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts @@ -341,9 +341,7 @@ describe('Test a single server', function () { for (const video of videos) { const videoName = video.name.replace(' name', '') - const test = await testImage(server.url, videoName, video.thumbnailPath) - - expect(test).to.equal(true) + await testImage(server.url, videoName, video.thumbnailPath) } }) diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts index cf8166a96..f83d95088 100644 --- a/server/tests/api/videos/video-comments.ts +++ b/server/tests/api/videos/video-comments.ts @@ -83,8 +83,7 @@ describe('Test video comments', function () { expect(comment.account.name).to.equal('root') expect(comment.account.host).to.equal('localhost:9001') - const test = await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png') - expect(test).to.equal(true) + await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png') expect(comment.totalReplies).to.equal(0) expect(dateIsValid(comment.createdAt as string)).to.be.true diff --git a/server/tests/utils/miscs/miscs.ts b/server/tests/utils/miscs/miscs.ts index 24cbf59ca..53cb67baf 100644 --- a/server/tests/utils/miscs/miscs.ts +++ b/server/tests/utils/miscs/miscs.ts @@ -1,10 +1,12 @@ /* tslint:disable:no-unused-expression */ +import * as chai from 'chai' import { isAbsolute, join } from 'path' import * as request from 'supertest' import * as WebTorrent from 'webtorrent' import { readFileBufferPromise } from '../../../helpers/core-utils' +const expect = chai.expect let webtorrent = new WebTorrent() function immutableAssign (target: T, source: U) { @@ -48,7 +50,8 @@ async function testImage (url: string, imageName: string, imagePath: string, ext const minLength = body.length - ((20 * body.length) / 100) const maxLength = body.length + ((20 * body.length) / 100) - return data.length > minLength && data.length < maxLength + expect(data.length).to.be.above(minLength) + expect(data.length).to.be.below(maxLength) } else { console.log('Do not test images. Enable it by setting NODE_TEST_IMAGE env variable.') return true diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index 8e58f1f0c..9a4af0b9f 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts @@ -445,13 +445,11 @@ async function completeVideoCheck ( expect(file.size).to.be.above(minSize).and.below(maxSize) { - const test = await testImage(url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath) - expect(test).to.equal(true) + await testImage(url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath) } if (attributes.previewfile) { - const test = await testImage(url, attributes.previewfile, videoDetails.previewPath) - expect(test).to.equal(true) + await testImage(url, attributes.previewfile, videoDetails.previewPath) } const torrent = await webtorrentAdd(magnetUri, true) -- 2.25.1