aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/video-playlists.ts5
-rw-r--r--server/tests/api/notifications/user-notifications.ts24
-rw-r--r--server/tests/api/videos/video-playlists.ts35
3 files changed, 42 insertions, 22 deletions
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts
index 46ec00d46..179ae9201 100644
--- a/server/tests/api/check-params/video-playlists.ts
+++ b/server/tests/api/check-params/video-playlists.ts
@@ -346,11 +346,6 @@ describe('Test video playlists API validator', function () {
346 const res = await addVideoInPlaylist(params) 346 const res = await addVideoInPlaylist(params)
347 playlistElementId = res.body.videoPlaylistElement.id 347 playlistElementId = res.body.videoPlaylistElement.id
348 }) 348 })
349
350 it('Should fail if the video was already added in the playlist', async function () {
351 const params = getBase({}, { expectedStatus: 409 })
352 await addVideoInPlaylist(params)
353 })
354 }) 349 })
355 350
356 describe('When updating an element in a playlist', function () { 351 describe('When updating an element in a playlist', function () {
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts
index af4ff42b0..edc95b069 100644
--- a/server/tests/api/notifications/user-notifications.ts
+++ b/server/tests/api/notifications/user-notifications.ts
@@ -65,7 +65,7 @@ describe('Test user notifications', function () {
65 }) 65 })
66 66
67 it('Should not send notifications if the user does not follow the video publisher', async function () { 67 it('Should not send notifications if the user does not follow the video publisher', async function () {
68 this.timeout(10000) 68 this.timeout(30000)
69 69
70 await uploadRandomVideoOnServers(servers, 1) 70 await uploadRandomVideoOnServers(servers, 1)
71 71
@@ -97,7 +97,7 @@ describe('Test user notifications', function () {
97 }) 97 })
98 98
99 it('Should send a new video notification on a scheduled publication', async function () { 99 it('Should send a new video notification on a scheduled publication', async function () {
100 this.timeout(20000) 100 this.timeout(30000)
101 101
102 // In 2 seconds 102 // In 2 seconds
103 const updateAt = new Date(new Date().getTime() + 2000) 103 const updateAt = new Date(new Date().getTime() + 2000)
@@ -136,7 +136,7 @@ describe('Test user notifications', function () {
136 }) 136 })
137 137
138 it('Should not send a notification before the video is published', async function () { 138 it('Should not send a notification before the video is published', async function () {
139 this.timeout(20000) 139 this.timeout(30000)
140 140
141 const updateAt = new Date(new Date().getTime() + 1000000) 141 const updateAt = new Date(new Date().getTime() + 1000000)
142 142
@@ -154,7 +154,7 @@ describe('Test user notifications', function () {
154 }) 154 })
155 155
156 it('Should send a new video notification when a video becomes public', async function () { 156 it('Should send a new video notification when a video becomes public', async function () {
157 this.timeout(10000) 157 this.timeout(30000)
158 158
159 const data = { privacy: VideoPrivacy.PRIVATE } 159 const data = { privacy: VideoPrivacy.PRIVATE }
160 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data) 160 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data)
@@ -168,7 +168,7 @@ describe('Test user notifications', function () {
168 }) 168 })
169 169
170 it('Should send a new video notification when a remote video becomes public', async function () { 170 it('Should send a new video notification when a remote video becomes public', async function () {
171 this.timeout(20000) 171 this.timeout(30000)
172 172
173 const data = { privacy: VideoPrivacy.PRIVATE } 173 const data = { privacy: VideoPrivacy.PRIVATE }
174 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) 174 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data)
@@ -182,7 +182,7 @@ describe('Test user notifications', function () {
182 }) 182 })
183 183
184 it('Should not send a new video notification when a video becomes unlisted', async function () { 184 it('Should not send a new video notification when a video becomes unlisted', async function () {
185 this.timeout(20000) 185 this.timeout(30000)
186 186
187 const data = { privacy: VideoPrivacy.PRIVATE } 187 const data = { privacy: VideoPrivacy.PRIVATE }
188 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data) 188 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data)
@@ -193,7 +193,7 @@ describe('Test user notifications', function () {
193 }) 193 })
194 194
195 it('Should not send a new video notification when a remote video becomes unlisted', async function () { 195 it('Should not send a new video notification when a remote video becomes unlisted', async function () {
196 this.timeout(20000) 196 this.timeout(30000)
197 197
198 const data = { privacy: VideoPrivacy.PRIVATE } 198 const data = { privacy: VideoPrivacy.PRIVATE }
199 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) 199 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data)
@@ -237,7 +237,7 @@ describe('Test user notifications', function () {
237 }) 237 })
238 238
239 it('Should not send a notification if transcoding is not enabled', async function () { 239 it('Should not send a notification if transcoding is not enabled', async function () {
240 this.timeout(10000) 240 this.timeout(30000)
241 241
242 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1) 242 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1)
243 await waitJobs(servers) 243 await waitJobs(servers)
@@ -416,7 +416,7 @@ describe('Test user notifications', function () {
416 }) 416 })
417 417
418 it('Should notify when a local channel is following one of our channel', async function () { 418 it('Should notify when a local channel is following one of our channel', async function () {
419 this.timeout(10000) 419 this.timeout(30000)
420 420
421 await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) 421 await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port)
422 await waitJobs(servers) 422 await waitJobs(servers)
@@ -427,7 +427,7 @@ describe('Test user notifications', function () {
427 }) 427 })
428 428
429 it('Should notify when a remote channel is following one of our channel', async function () { 429 it('Should notify when a remote channel is following one of our channel', async function () {
430 this.timeout(10000) 430 this.timeout(30000)
431 431
432 await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) 432 await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port)
433 await waitJobs(servers) 433 await waitJobs(servers)
@@ -439,7 +439,7 @@ describe('Test user notifications', function () {
439 439
440 // PeerTube does not support accout -> account follows 440 // PeerTube does not support accout -> account follows
441 // it('Should notify when a local account is following one of our channel', async function () { 441 // it('Should notify when a local account is following one of our channel', async function () {
442 // this.timeout(10000) 442 // this.timeout(30000)
443 // 443 //
444 // await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1@localhost:' + servers[0].port) 444 // await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1@localhost:' + servers[0].port)
445 // 445 //
@@ -449,7 +449,7 @@ describe('Test user notifications', function () {
449 // }) 449 // })
450 450
451 // it('Should notify when a remote account is following one of our channel', async function () { 451 // it('Should notify when a remote account is following one of our channel', async function () {
452 // this.timeout(10000) 452 // this.timeout(30000)
453 // 453 //
454 // await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1@localhost:' + servers[0].port) 454 // await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1@localhost:' + servers[0].port)
455 // 455 //
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index 52b32998d..0bfb5bcd4 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -552,6 +552,9 @@ describe('Test video playlists', function () {
552 { 552 {
553 const res = await addVideo({ videoId: nsfwVideoServer1, startTimestamp: 5 }) 553 const res = await addVideo({ videoId: nsfwVideoServer1, startTimestamp: 5 })
554 playlistElementNSFW = res.body.videoPlaylistElement.id 554 playlistElementNSFW = res.body.videoPlaylistElement.id
555
556 await addVideo({ videoId: nsfwVideoServer1, startTimestamp: 4 })
557 await addVideo({ videoId: nsfwVideoServer1 })
555 } 558 }
556 559
557 await waitJobs(servers) 560 await waitJobs(servers)
@@ -563,10 +566,10 @@ describe('Test video playlists', function () {
563 for (const server of servers) { 566 for (const server of servers) {
564 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10) 567 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
565 568
566 expect(res.body.total).to.equal(6) 569 expect(res.body.total).to.equal(8)
567 570
568 const videoElements: VideoPlaylistElement[] = res.body.data 571 const videoElements: VideoPlaylistElement[] = res.body.data
569 expect(videoElements).to.have.lengthOf(6) 572 expect(videoElements).to.have.lengthOf(8)
570 573
571 expect(videoElements[0].video.name).to.equal('video 0 server 1') 574 expect(videoElements[0].video.name).to.equal('video 0 server 1')
572 expect(videoElements[0].position).to.equal(1) 575 expect(videoElements[0].position).to.equal(1)
@@ -598,6 +601,16 @@ describe('Test video playlists', function () {
598 expect(videoElements[5].startTimestamp).to.equal(5) 601 expect(videoElements[5].startTimestamp).to.equal(5)
599 expect(videoElements[5].stopTimestamp).to.be.null 602 expect(videoElements[5].stopTimestamp).to.be.null
600 603
604 expect(videoElements[6].video.name).to.equal('NSFW video')
605 expect(videoElements[6].position).to.equal(7)
606 expect(videoElements[6].startTimestamp).to.equal(4)
607 expect(videoElements[6].stopTimestamp).to.be.null
608
609 expect(videoElements[7].video.name).to.equal('NSFW video')
610 expect(videoElements[7].position).to.equal(8)
611 expect(videoElements[7].startTimestamp).to.be.null
612 expect(videoElements[7].stopTimestamp).to.be.null
613
601 const res3 = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 2) 614 const res3 = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 2)
602 expect(res3.body.data).to.have.lengthOf(2) 615 expect(res3.body.data).to.have.lengthOf(2)
603 } 616 }
@@ -807,6 +820,8 @@ describe('Test video playlists', function () {
807 'video 1 server 3', 820 'video 1 server 3',
808 'video 3 server 1', 821 'video 3 server 1',
809 'video 4 server 1', 822 'video 4 server 1',
823 'NSFW video',
824 'NSFW video',
810 'NSFW video' 825 'NSFW video'
811 ]) 826 ])
812 } 827 }
@@ -836,6 +851,8 @@ describe('Test video playlists', function () {
836 'video 2 server 3', 851 'video 2 server 3',
837 'video 1 server 3', 852 'video 1 server 3',
838 'video 4 server 1', 853 'video 4 server 1',
854 'NSFW video',
855 'NSFW video',
839 'NSFW video' 856 'NSFW video'
840 ]) 857 ])
841 } 858 }
@@ -865,7 +882,9 @@ describe('Test video playlists', function () {
865 'video 2 server 3', 882 'video 2 server 3',
866 'NSFW video', 883 'NSFW video',
867 'video 1 server 3', 884 'video 1 server 3',
868 'video 4 server 1' 885 'video 4 server 1',
886 'NSFW video',
887 'NSFW video'
869 ]) 888 ])
870 889
871 for (let i = 1; i <= elements.length; i++) { 890 for (let i = 1; i <= elements.length; i++) {
@@ -1023,10 +1042,10 @@ describe('Test video playlists', function () {
1023 for (const server of servers) { 1042 for (const server of servers) {
1024 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10) 1043 const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
1025 1044
1026 expect(res.body.total).to.equal(4) 1045 expect(res.body.total).to.equal(6)
1027 1046
1028 const elements: VideoPlaylistElement[] = res.body.data 1047 const elements: VideoPlaylistElement[] = res.body.data
1029 expect(elements).to.have.lengthOf(4) 1048 expect(elements).to.have.lengthOf(6)
1030 1049
1031 expect(elements[0].video.name).to.equal('video 0 server 1') 1050 expect(elements[0].video.name).to.equal('video 0 server 1')
1032 expect(elements[0].position).to.equal(1) 1051 expect(elements[0].position).to.equal(1)
@@ -1039,6 +1058,12 @@ describe('Test video playlists', function () {
1039 1058
1040 expect(elements[3].video.name).to.equal('video 4 server 1') 1059 expect(elements[3].video.name).to.equal('video 4 server 1')
1041 expect(elements[3].position).to.equal(4) 1060 expect(elements[3].position).to.equal(4)
1061
1062 expect(elements[4].video.name).to.equal('NSFW video')
1063 expect(elements[4].position).to.equal(5)
1064
1065 expect(elements[5].video.name).to.equal('NSFW video')
1066 expect(elements[5].position).to.equal(6)
1042 } 1067 }
1043 }) 1068 })
1044 1069