diff options
author | Chocobozzz <me@florianbigard.com> | 2021-11-03 11:32:41 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-11-03 11:32:41 +0100 |
commit | d324756edb836672f12284cd18e642a658b273d8 (patch) | |
tree | 3b323682bd7380491ad904daaeaea10be606e0f9 /server/tests/api/videos | |
parent | d5d9c5b79edf613e97a752a3d59062fb42045275 (diff) | |
download | PeerTube-d324756edb836672f12284cd18e642a658b273d8.tar.gz PeerTube-d324756edb836672f12284cd18e642a658b273d8.tar.zst PeerTube-d324756edb836672f12284cd18e642a658b273d8.zip |
Add ability to filter by file type
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/videos-common-filters.ts | 80 |
1 files changed, 77 insertions, 3 deletions
diff --git a/server/tests/api/videos/videos-common-filters.ts b/server/tests/api/videos/videos-common-filters.ts index 03c5c3b3f..4f22d4ac3 100644 --- a/server/tests/api/videos/videos-common-filters.ts +++ b/server/tests/api/videos/videos-common-filters.ts | |||
@@ -135,6 +135,8 @@ describe('Test videos filter', function () { | |||
135 | server: PeerTubeServer | 135 | server: PeerTubeServer |
136 | path: string | 136 | path: string |
137 | isLocal?: boolean | 137 | isLocal?: boolean |
138 | hasWebtorrentFiles?: boolean | ||
139 | hasHLSFiles?: boolean | ||
138 | include?: VideoInclude | 140 | include?: VideoInclude |
139 | category?: number | 141 | category?: number |
140 | tagsAllOf?: string[] | 142 | tagsAllOf?: string[] |
@@ -146,7 +148,7 @@ describe('Test videos filter', function () { | |||
146 | path: options.path, | 148 | path: options.path, |
147 | token: options.token ?? options.server.accessToken, | 149 | token: options.token ?? options.server.accessToken, |
148 | query: { | 150 | query: { |
149 | ...pick(options, [ 'isLocal', 'include', 'category', 'tagsAllOf' ]), | 151 | ...pick(options, [ 'isLocal', 'include', 'category', 'tagsAllOf', 'hasWebtorrentFiles', 'hasHLSFiles' ]), |
150 | 152 | ||
151 | sort: 'createdAt' | 153 | sort: 'createdAt' |
152 | }, | 154 | }, |
@@ -397,11 +399,9 @@ describe('Test videos filter', function () { | |||
397 | 399 | ||
398 | for (const path of paths) { | 400 | for (const path of paths) { |
399 | { | 401 | { |
400 | |||
401 | const videos = await listVideos({ server: servers[0], path, tagsAllOf: [ 'tag1', 'tag2' ] }) | 402 | const videos = await listVideos({ server: servers[0], path, tagsAllOf: [ 'tag1', 'tag2' ] }) |
402 | expect(videos).to.have.lengthOf(1) | 403 | expect(videos).to.have.lengthOf(1) |
403 | expect(videos[0].name).to.equal('tag filter') | 404 | expect(videos[0].name).to.equal('tag filter') |
404 | |||
405 | } | 405 | } |
406 | 406 | ||
407 | { | 407 | { |
@@ -421,6 +421,80 @@ describe('Test videos filter', function () { | |||
421 | } | 421 | } |
422 | } | 422 | } |
423 | }) | 423 | }) |
424 | |||
425 | it('Should filter by HLS or WebTorrent files', async function () { | ||
426 | this.timeout(360000) | ||
427 | |||
428 | const finderFactory = (name: string) => (videos: Video[]) => videos.some(v => v.name === name) | ||
429 | |||
430 | await servers[0].config.enableTranscoding(true, false) | ||
431 | await servers[0].videos.upload({ attributes: { name: 'webtorrent video' } }) | ||
432 | const hasWebtorrent = finderFactory('webtorrent video') | ||
433 | |||
434 | await waitJobs(servers) | ||
435 | |||
436 | await servers[0].config.enableTranscoding(false, true) | ||
437 | await servers[0].videos.upload({ attributes: { name: 'hls video' } }) | ||
438 | const hasHLS = finderFactory('hls video') | ||
439 | |||
440 | await waitJobs(servers) | ||
441 | |||
442 | await servers[0].config.enableTranscoding(true, true) | ||
443 | await servers[0].videos.upload({ attributes: { name: 'hls and webtorrent video' } }) | ||
444 | const hasBoth = finderFactory('hls and webtorrent video') | ||
445 | |||
446 | await waitJobs(servers) | ||
447 | |||
448 | for (const path of paths) { | ||
449 | { | ||
450 | const videos = await listVideos({ server: servers[0], path, hasWebtorrentFiles: true }) | ||
451 | |||
452 | expect(hasWebtorrent(videos)).to.be.true | ||
453 | expect(hasHLS(videos)).to.be.false | ||
454 | expect(hasBoth(videos)).to.be.true | ||
455 | } | ||
456 | |||
457 | { | ||
458 | const videos = await listVideos({ server: servers[0], path, hasWebtorrentFiles: false }) | ||
459 | |||
460 | expect(hasWebtorrent(videos)).to.be.false | ||
461 | expect(hasHLS(videos)).to.be.true | ||
462 | expect(hasBoth(videos)).to.be.false | ||
463 | } | ||
464 | |||
465 | { | ||
466 | const videos = await listVideos({ server: servers[0], path, hasHLSFiles: true }) | ||
467 | |||
468 | expect(hasWebtorrent(videos)).to.be.false | ||
469 | expect(hasHLS(videos)).to.be.true | ||
470 | expect(hasBoth(videos)).to.be.true | ||
471 | } | ||
472 | |||
473 | { | ||
474 | const videos = await listVideos({ server: servers[0], path, hasHLSFiles: false }) | ||
475 | |||
476 | expect(hasWebtorrent(videos)).to.be.true | ||
477 | expect(hasHLS(videos)).to.be.false | ||
478 | expect(hasBoth(videos)).to.be.false | ||
479 | } | ||
480 | |||
481 | { | ||
482 | const videos = await listVideos({ server: servers[0], path, hasHLSFiles: false, hasWebtorrentFiles: false }) | ||
483 | |||
484 | expect(hasWebtorrent(videos)).to.be.false | ||
485 | expect(hasHLS(videos)).to.be.false | ||
486 | expect(hasBoth(videos)).to.be.false | ||
487 | } | ||
488 | |||
489 | { | ||
490 | const videos = await listVideos({ server: servers[0], path, hasHLSFiles: true, hasWebtorrentFiles: true }) | ||
491 | |||
492 | expect(hasWebtorrent(videos)).to.be.false | ||
493 | expect(hasHLS(videos)).to.be.false | ||
494 | expect(hasBoth(videos)).to.be.true | ||
495 | } | ||
496 | } | ||
497 | }) | ||
424 | }) | 498 | }) |
425 | 499 | ||
426 | after(async function () { | 500 | after(async function () { |