aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/video-playlists.ts46
-rw-r--r--server/tests/api/redundancy/redundancy.ts4
-rw-r--r--server/tests/api/videos/video-hls.ts6
-rw-r--r--server/tests/api/videos/video-playlists.ts42
4 files changed, 92 insertions, 6 deletions
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts
index 803e7afb9..4d8000dbf 100644
--- a/server/tests/api/check-params/video-playlists.ts
+++ b/server/tests/api/check-params/video-playlists.ts
@@ -522,6 +522,52 @@ describe('Test video playlists API validator', function () {
522 }) 522 })
523 }) 523 })
524 524
525 describe('When checking exists in playlist endpoint', function () {
526 const path = '/api/v1/users/me/video-playlists/videos-exist'
527
528 it('Should fail with an unauthenticated user', async function () {
529 await makeGetRequest({
530 url: server.url,
531 path,
532 query: { videoIds: [ 1, 2 ] },
533 statusCodeExpected: 401
534 })
535 })
536
537 it('Should fail with invalid video ids', async function () {
538 await makeGetRequest({
539 url: server.url,
540 token: server.accessToken,
541 path,
542 query: { videoIds: 'toto' }
543 })
544
545 await makeGetRequest({
546 url: server.url,
547 token: server.accessToken,
548 path,
549 query: { videoIds: [ 'toto' ] }
550 })
551
552 await makeGetRequest({
553 url: server.url,
554 token: server.accessToken,
555 path,
556 query: { videoIds: [ 1, 'toto' ] }
557 })
558 })
559
560 it('Should succeed with the correct params', async function () {
561 await makeGetRequest({
562 url: server.url,
563 token: server.accessToken,
564 path,
565 query: { videoIds: [ 1, 2 ] },
566 statusCodeExpected: 200
567 })
568 })
569 })
570
525 describe('When deleting an element in a playlist', function () { 571 describe('When deleting an element in a playlist', function () {
526 const getBase = (wrapper: any = {}) => { 572 const getBase = (wrapper: any = {}) => {
527 return Object.assign({ 573 return Object.assign({
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index fc5ffbad7..33921763d 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -184,7 +184,7 @@ async function check1PlaylistRedundancies (videoUUID?: string) {
184 expect(redundancy.baseUrl).to.equal(servers[0].url + '/static/redundancy/hls/' + videoUUID) 184 expect(redundancy.baseUrl).to.equal(servers[0].url + '/static/redundancy/hls/' + videoUUID)
185 } 185 }
186 186
187 const baseUrlPlaylist = servers[1].url + '/static/playlists/hls' 187 const baseUrlPlaylist = servers[1].url + '/static/streaming-playlists/hls'
188 const baseUrlSegment = servers[0].url + '/static/redundancy/hls' 188 const baseUrlSegment = servers[0].url + '/static/redundancy/hls'
189 189
190 const res = await getVideo(servers[0].url, videoUUID) 190 const res = await getVideo(servers[0].url, videoUUID)
@@ -194,7 +194,7 @@ async function check1PlaylistRedundancies (videoUUID?: string) {
194 await checkSegmentHash(baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist) 194 await checkSegmentHash(baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist)
195 } 195 }
196 196
197 for (const directory of [ 'test1/redundancy/hls', 'test2/playlists/hls' ]) { 197 for (const directory of [ 'test1/redundancy/hls', 'test2/streaming-playlists/hls' ]) {
198 const files = await readdir(join(root(), directory, videoUUID)) 198 const files = await readdir(join(root(), directory, videoUUID))
199 expect(files).to.have.length.at.least(4) 199 expect(files).to.have.length.at.least(4)
200 200
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts
index a1214bad1..3d04758b1 100644
--- a/server/tests/api/videos/video-hls.ts
+++ b/server/tests/api/videos/video-hls.ts
@@ -51,7 +51,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) {
51 51
52 { 52 {
53 for (const resolution of resolutions) { 53 for (const resolution of resolutions) {
54 const res2 = await getPlaylist(`http://localhost:9001/static/playlists/hls/${videoUUID}/${resolution}.m3u8`) 54 const res2 = await getPlaylist(`http://localhost:9001/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`)
55 55
56 const subPlaylist = res2.text 56 const subPlaylist = res2.text
57 expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`) 57 expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`)
@@ -59,7 +59,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) {
59 } 59 }
60 60
61 { 61 {
62 const baseUrl = 'http://localhost:9001/static/playlists/hls' 62 const baseUrl = 'http://localhost:9001/static/streaming-playlists/hls'
63 63
64 for (const resolution of resolutions) { 64 for (const resolution of resolutions) {
65 await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist) 65 await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist)
@@ -118,7 +118,7 @@ describe('Test HLS videos', function () {
118 it('Should have the playlists/segment deleted from the disk', async function () { 118 it('Should have the playlists/segment deleted from the disk', async function () {
119 for (const server of servers) { 119 for (const server of servers) {
120 await checkDirectoryIsEmpty(server, 'videos') 120 await checkDirectoryIsEmpty(server, 'videos')
121 await checkDirectoryIsEmpty(server, join('playlists', 'hls')) 121 await checkDirectoryIsEmpty(server, join('streaming-playlists', 'hls'))
122 } 122 }
123 }) 123 })
124 124
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index baa2b3b8c..931491406 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -10,7 +10,7 @@ import {
10 createVideoPlaylist, 10 createVideoPlaylist,
11 deleteVideoChannel, 11 deleteVideoChannel,
12 deleteVideoPlaylist, 12 deleteVideoPlaylist,
13 doubleFollow, 13 doubleFollow, doVideosExistInMyPlaylist,
14 flushAndRunMultipleServers, 14 flushAndRunMultipleServers,
15 flushTests, 15 flushTests,
16 getAccountPlaylistsList, 16 getAccountPlaylistsList,
@@ -41,6 +41,7 @@ import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/
41import { VideoPlaylist } from '../../../../shared/models/videos/playlist/video-playlist.model' 41import { VideoPlaylist } from '../../../../shared/models/videos/playlist/video-playlist.model'
42import { Video } from '../../../../shared/models/videos' 42import { Video } from '../../../../shared/models/videos'
43import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' 43import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model'
44import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model'
44 45
45const expect = chai.expect 46const expect = chai.expect
46 47
@@ -624,6 +625,45 @@ describe('Test video playlists', function () {
624 } 625 }
625 }) 626 })
626 627
628 it('Should check videos existence in my playlist', async function () {
629 const videoIds = [
630 servers[0].videos[0].id,
631 42000,
632 servers[0].videos[3].id,
633 43000,
634 servers[0].videos[4].id
635 ]
636 const res = await doVideosExistInMyPlaylist(servers[ 0 ].url, servers[ 0 ].accessToken, videoIds)
637 const obj = res.body as VideoExistInPlaylist
638
639 {
640 const elem = obj[servers[0].videos[0].id]
641 expect(elem).to.have.lengthOf(1)
642 expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id)
643 expect(elem[ 0 ].startTimestamp).to.equal(15)
644 expect(elem[ 0 ].stopTimestamp).to.equal(28)
645 }
646
647 {
648 const elem = obj[servers[0].videos[3].id]
649 expect(elem).to.have.lengthOf(1)
650 expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id)
651 expect(elem[ 0 ].startTimestamp).to.equal(1)
652 expect(elem[ 0 ].stopTimestamp).to.equal(35)
653 }
654
655 {
656 const elem = obj[servers[0].videos[4].id]
657 expect(elem).to.have.lengthOf(1)
658 expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id)
659 expect(elem[ 0 ].startTimestamp).to.equal(45)
660 expect(elem[ 0 ].stopTimestamp).to.equal(null)
661 }
662
663 expect(obj[42000]).to.have.lengthOf(0)
664 expect(obj[43000]).to.have.lengthOf(0)
665 })
666
627 it('Should delete some elements', async function () { 667 it('Should delete some elements', async function () {
628 this.timeout(30000) 668 this.timeout(30000)
629 669