diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-29 11:51:55 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-29 12:33:19 +0100 |
commit | b1f5b93e4f1a9ae9015463c9a4946722ed87ec2e (patch) | |
tree | ab437e41a497aa388775d32369d8fe6bdf309e3b /server/tests/utils | |
parent | a20399c972d7f9512f77a654773f9c160db07d5c (diff) | |
download | PeerTube-b1f5b93e4f1a9ae9015463c9a4946722ed87ec2e.tar.gz PeerTube-b1f5b93e4f1a9ae9015463c9a4946722ed87ec2e.tar.zst PeerTube-b1f5b93e4f1a9ae9015463c9a4946722ed87ec2e.zip |
Refractor check video tests
Diffstat (limited to 'server/tests/utils')
-rw-r--r-- | server/tests/utils/miscs/miscs.ts | 4 | ||||
-rw-r--r-- | server/tests/utils/videos/videos.ts | 31 |
2 files changed, 26 insertions, 9 deletions
diff --git a/server/tests/utils/miscs/miscs.ts b/server/tests/utils/miscs/miscs.ts index 2147a07ff..2c51d1f0a 100644 --- a/server/tests/utils/miscs/miscs.ts +++ b/server/tests/utils/miscs/miscs.ts | |||
@@ -27,8 +27,8 @@ function readdirPromise (path: string) { | |||
27 | }) | 27 | }) |
28 | } | 28 | } |
29 | 29 | ||
30 | // Default interval -> 2 minutes | 30 | // Default interval -> 5 minutes |
31 | function dateIsValid (dateString: string, interval = 120000) { | 31 | function dateIsValid (dateString: string, interval = 300000) { |
32 | const dateToCheck = new Date(dateString) | 32 | const dateToCheck = new Date(dateString) |
33 | const now = new Date() | 33 | const now = new Date() |
34 | 34 | ||
diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index 17c3dbc15..d6bf27dc7 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { readFile } from 'fs' | 4 | import { readFile } from 'fs' |
5 | import * as parseTorrent from 'parse-torrent' | 5 | import * as parseTorrent from 'parse-torrent' |
6 | import { isAbsolute, join } from 'path' | 6 | import { extname, isAbsolute, join } from 'path' |
7 | import * as request from 'supertest' | 7 | import * as request from 'supertest' |
8 | import { getMyUserInformation, makeGetRequest, readFilePromise, ServerInfo } from '../' | 8 | import { getMyUserInformation, makeGetRequest, readFilePromise, ServerInfo } from '../' |
9 | import { VideoPrivacy } from '../../../../shared/models/videos' | 9 | import { VideoPrivacy } from '../../../../shared/models/videos' |
@@ -332,8 +332,12 @@ async function completeVideoCheck ( | |||
332 | isLocal: boolean, | 332 | isLocal: boolean, |
333 | tags: string[], | 333 | tags: string[], |
334 | privacy: number, | 334 | privacy: number, |
335 | likes?: number, | ||
336 | dislikes?: number, | ||
337 | duration: number, | ||
335 | channel: { | 338 | channel: { |
336 | name: string, | 339 | name: string, |
340 | description | ||
337 | isLocal: boolean | 341 | isLocal: boolean |
338 | } | 342 | } |
339 | fixture: string, | 343 | fixture: string, |
@@ -343,18 +347,24 @@ async function completeVideoCheck ( | |||
343 | }[] | 347 | }[] |
344 | } | 348 | } |
345 | ) { | 349 | ) { |
350 | if (!attributes.likes) attributes.likes = 0 | ||
351 | if (!attributes.dislikes) attributes.dislikes = 0 | ||
352 | |||
346 | expect(video.name).to.equal(attributes.name) | 353 | expect(video.name).to.equal(attributes.name) |
347 | expect(video.category).to.equal(attributes.category) | 354 | expect(video.category).to.equal(attributes.category) |
348 | expect(video.categoryLabel).to.equal(VIDEO_CATEGORIES[attributes.category]) | 355 | expect(video.categoryLabel).to.equal(VIDEO_CATEGORIES[attributes.category] || 'Misc') |
349 | expect(video.licence).to.equal(attributes.licence) | 356 | expect(video.licence).to.equal(attributes.licence) |
350 | expect(video.licenceLabel).to.equal(VIDEO_LICENCES[attributes.licence]) | 357 | expect(video.licenceLabel).to.equal(VIDEO_LICENCES[attributes.licence] || 'Unknown') |
351 | expect(video.language).to.equal(attributes.language) | 358 | expect(video.language).to.equal(attributes.language) |
352 | expect(video.languageLabel).to.equal(VIDEO_LANGUAGES[attributes.language]) | 359 | expect(video.languageLabel).to.equal(VIDEO_LANGUAGES[attributes.language] || 'Unknown') |
353 | expect(video.nsfw).to.equal(attributes.nsfw) | 360 | expect(video.nsfw).to.equal(attributes.nsfw) |
354 | expect(video.description).to.equal(attributes.description) | 361 | expect(video.description).to.equal(attributes.description) |
355 | expect(video.serverHost).to.equal(attributes.host) | 362 | expect(video.serverHost).to.equal(attributes.host) |
356 | expect(video.accountName).to.equal(attributes.account) | 363 | expect(video.accountName).to.equal(attributes.account) |
364 | expect(video.likes).to.equal(attributes.likes) | ||
365 | expect(video.dislikes).to.equal(attributes.dislikes) | ||
357 | expect(video.isLocal).to.equal(attributes.isLocal) | 366 | expect(video.isLocal).to.equal(attributes.isLocal) |
367 | expect(video.duration).to.equal(attributes.duration) | ||
358 | expect(dateIsValid(video.createdAt)).to.be.true | 368 | expect(dateIsValid(video.createdAt)).to.be.true |
359 | expect(dateIsValid(video.updatedAt)).to.be.true | 369 | expect(dateIsValid(video.updatedAt)).to.be.true |
360 | 370 | ||
@@ -376,13 +386,20 @@ async function completeVideoCheck ( | |||
376 | const file = videoDetails.files.find(f => f.resolution === attributeFile.resolution) | 386 | const file = videoDetails.files.find(f => f.resolution === attributeFile.resolution) |
377 | expect(file).not.to.be.undefined | 387 | expect(file).not.to.be.undefined |
378 | 388 | ||
389 | let extension = extname(attributes.fixture) | ||
390 | // Transcoding enabled on server 2, extension will always be .mp4 | ||
391 | if (attributes.host === 'localhost:9002') extension = '.mp4' | ||
392 | |||
379 | const magnetUri = file.magnetUri | 393 | const magnetUri = file.magnetUri |
380 | expect(file.magnetUri).to.have.lengthOf.above(2) | 394 | expect(file.magnetUri).to.have.lengthOf.above(2) |
381 | expect(file.torrentUrl).to.equal(`${url}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`) | 395 | expect(file.torrentUrl).to.equal(`http://${attributes.host}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`) |
382 | expect(file.fileUrl).to.equal(`${url}/static/webseed/${videoDetails.uuid}-${file.resolution}.webm`) | 396 | expect(file.fileUrl).to.equal(`http://${attributes.host}/static/webseed/${videoDetails.uuid}-${file.resolution}${extension}`) |
383 | expect(file.resolution).to.equal(attributeFile.resolution) | 397 | expect(file.resolution).to.equal(attributeFile.resolution) |
384 | expect(file.resolutionLabel).to.equal(attributeFile.resolution + 'p') | 398 | expect(file.resolutionLabel).to.equal(attributeFile.resolution + 'p') |
385 | expect(file.size).to.equal(attributeFile.size) | 399 | |
400 | const minSize = attributeFile.size - ((10 * attributeFile.size) / 100) | ||
401 | const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100) | ||
402 | expect(file.size).to.be.above(minSize).and.below(maxSize) | ||
386 | 403 | ||
387 | const test = await testVideoImage(url, attributes.fixture, videoDetails.thumbnailPath) | 404 | const test = await testVideoImage(url, attributes.fixture, videoDetails.thumbnailPath) |
388 | expect(test).to.equal(true) | 405 | expect(test).to.equal(true) |