diff options
Diffstat (limited to 'server/tests/api/videos')
23 files changed, 884 insertions, 489 deletions
diff --git a/server/tests/api/videos/audio-only.ts b/server/tests/api/videos/audio-only.ts index f12d730cc..ac7a0b89c 100644 --- a/server/tests/api/videos/audio-only.ts +++ b/server/tests/api/videos/audio-only.ts | |||
@@ -1,28 +1,21 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { | 5 | import { |
6 | checkDirectoryIsEmpty, | ||
7 | checkSegmentHash, | ||
8 | checkTmpIsEmpty, | ||
9 | cleanupTests, | 6 | cleanupTests, |
10 | doubleFollow, | 7 | doubleFollow, |
11 | flushAndRunMultipleServers, | 8 | flushAndRunMultipleServers, |
12 | getPlaylist, | 9 | getVideo, |
13 | getVideo, makeGetRequest, makeRawRequest, | 10 | root, |
14 | removeVideo, root, | ||
15 | ServerInfo, | 11 | ServerInfo, |
16 | setAccessTokensToServers, updateCustomSubConfig, | 12 | setAccessTokensToServers, |
17 | updateVideo, | ||
18 | uploadVideo, | 13 | uploadVideo, |
19 | waitJobs, webtorrentAdd | 14 | waitJobs |
20 | } from '../../../../shared/extra-utils' | 15 | } from '../../../../shared/extra-utils' |
21 | import { VideoDetails } from '../../../../shared/models/videos' | 16 | import { VideoDetails } from '../../../../shared/models/videos' |
22 | import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' | ||
23 | import { join } from 'path' | 17 | import { join } from 'path' |
24 | import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' | 18 | import { audio, getVideoStreamSize } from '@server/helpers/ffmpeg-utils' |
25 | import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution, audio, getVideoStreamSize } from '@server/helpers/ffmpeg-utils' | ||
26 | 19 | ||
27 | const expect = chai.expect | 20 | const expect = chai.expect |
28 | 21 | ||
@@ -87,14 +80,14 @@ describe('Test audio only video transcoding', function () { | |||
87 | 80 | ||
88 | it('0p transcoded video should not have video', async function () { | 81 | it('0p transcoded video should not have video', async function () { |
89 | const paths = [ | 82 | const paths = [ |
90 | join(root(), 'test' + servers[ 0 ].internalServerNumber, 'videos', videoUUID + '-0.mp4'), | 83 | join(root(), 'test' + servers[0].internalServerNumber, 'videos', videoUUID + '-0.mp4'), |
91 | join(root(), 'test' + servers[ 0 ].internalServerNumber, 'streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4') | 84 | join(root(), 'test' + servers[0].internalServerNumber, 'streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4') |
92 | ] | 85 | ] |
93 | 86 | ||
94 | for (const path of paths) { | 87 | for (const path of paths) { |
95 | const { audioStream } = await audio.get(path) | 88 | const { audioStream } = await audio.get(path) |
96 | expect(audioStream[ 'codec_name' ]).to.be.equal('aac') | 89 | expect(audioStream['codec_name']).to.be.equal('aac') |
97 | expect(audioStream[ 'bit_rate' ]).to.be.at.most(384 * 8000) | 90 | expect(audioStream['bit_rate']).to.be.at.most(384 * 8000) |
98 | 91 | ||
99 | const size = await getVideoStreamSize(path) | 92 | const size = await getVideoStreamSize(path) |
100 | expect(size.height).to.equal(0) | 93 | expect(size.height).to.equal(0) |
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index fa3e250ec..e3029f1ae 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
@@ -63,9 +63,9 @@ describe('Test multiple servers', function () { | |||
63 | displayName: 'my channel', | 63 | displayName: 'my channel', |
64 | description: 'super channel' | 64 | description: 'super channel' |
65 | } | 65 | } |
66 | await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel) | 66 | await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel) |
67 | const channelRes = await getVideoChannelsList(servers[ 0 ].url, 0, 1) | 67 | const channelRes = await getVideoChannelsList(servers[0].url, 0, 1) |
68 | videoChannelId = channelRes.body.data[ 0 ].id | 68 | videoChannelId = channelRes.body.data[0].id |
69 | } | 69 | } |
70 | 70 | ||
71 | // Server 1 and server 2 follow each other | 71 | // Server 1 and server 2 follow each other |
@@ -163,7 +163,7 @@ describe('Test multiple servers', function () { | |||
163 | username: 'user1', | 163 | username: 'user1', |
164 | password: 'super_password' | 164 | password: 'super_password' |
165 | } | 165 | } |
166 | await createUser({ url: servers[ 1 ].url, accessToken: servers[ 1 ].accessToken, username: user.username, password: user.password }) | 166 | await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) |
167 | const userAccessToken = await userLogin(servers[1], user) | 167 | const userAccessToken = await userLogin(servers[1], user) |
168 | 168 | ||
169 | const videoAttributes = { | 169 | const videoAttributes = { |
@@ -762,12 +762,12 @@ describe('Test multiple servers', function () { | |||
762 | 762 | ||
763 | { | 763 | { |
764 | const text = 'my super first comment' | 764 | const text = 'my super first comment' |
765 | await addVideoCommentThread(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, text) | 765 | await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, text) |
766 | } | 766 | } |
767 | 767 | ||
768 | { | 768 | { |
769 | const text = 'my super second comment' | 769 | const text = 'my super second comment' |
770 | await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, text) | 770 | await addVideoCommentThread(servers[2].url, servers[2].accessToken, videoUUID, text) |
771 | } | 771 | } |
772 | 772 | ||
773 | await waitJobs(servers) | 773 | await waitJobs(servers) |
@@ -777,7 +777,7 @@ describe('Test multiple servers', function () { | |||
777 | const threadId = res.body.data.find(c => c.text === 'my super first comment').id | 777 | const threadId = res.body.data.find(c => c.text === 'my super first comment').id |
778 | 778 | ||
779 | const text = 'my super answer to thread 1' | 779 | const text = 'my super answer to thread 1' |
780 | await addVideoCommentReply(servers[ 1 ].url, servers[ 1 ].accessToken, videoUUID, threadId, text) | 780 | await addVideoCommentReply(servers[1].url, servers[1].accessToken, videoUUID, threadId, text) |
781 | } | 781 | } |
782 | 782 | ||
783 | await waitJobs(servers) | 783 | await waitJobs(servers) |
@@ -790,10 +790,10 @@ describe('Test multiple servers', function () { | |||
790 | const childCommentId = res2.body.children[0].comment.id | 790 | const childCommentId = res2.body.children[0].comment.id |
791 | 791 | ||
792 | const text3 = 'my second answer to thread 1' | 792 | const text3 = 'my second answer to thread 1' |
793 | await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, threadId, text3) | 793 | await addVideoCommentReply(servers[2].url, servers[2].accessToken, videoUUID, threadId, text3) |
794 | 794 | ||
795 | const text2 = 'my super answer to answer of thread 1' | 795 | const text2 = 'my super answer to answer of thread 1' |
796 | await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, childCommentId, text2) | 796 | await addVideoCommentReply(servers[2].url, servers[2].accessToken, videoUUID, childCommentId, text2) |
797 | } | 797 | } |
798 | 798 | ||
799 | await waitJobs(servers) | 799 | await waitJobs(servers) |
@@ -900,9 +900,9 @@ describe('Test multiple servers', function () { | |||
900 | it('Should delete the thread comments', async function () { | 900 | it('Should delete the thread comments', async function () { |
901 | this.timeout(10000) | 901 | this.timeout(10000) |
902 | 902 | ||
903 | const res = await getVideoCommentThreads(servers[ 0 ].url, videoUUID, 0, 5) | 903 | const res = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5) |
904 | const threadId = res.body.data.find(c => c.text === 'my super first comment').id | 904 | const threadId = res.body.data.find(c => c.text === 'my super first comment').id |
905 | await deleteVideoComment(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, threadId) | 905 | await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId) |
906 | 906 | ||
907 | await waitJobs(servers) | 907 | await waitJobs(servers) |
908 | }) | 908 | }) |
@@ -945,9 +945,9 @@ describe('Test multiple servers', function () { | |||
945 | it('Should delete a remote thread by the origin server', async function () { | 945 | it('Should delete a remote thread by the origin server', async function () { |
946 | this.timeout(5000) | 946 | this.timeout(5000) |
947 | 947 | ||
948 | const res = await getVideoCommentThreads(servers[ 0 ].url, videoUUID, 0, 5) | 948 | const res = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5) |
949 | const threadId = res.body.data.find(c => c.text === 'my super second comment').id | 949 | const threadId = res.body.data.find(c => c.text === 'my super second comment').id |
950 | await deleteVideoComment(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, threadId) | 950 | await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId) |
951 | 951 | ||
952 | await waitJobs(servers) | 952 | await waitJobs(servers) |
953 | }) | 953 | }) |
@@ -1021,7 +1021,7 @@ describe('Test multiple servers', function () { | |||
1021 | const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm') | 1021 | const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm') |
1022 | 1022 | ||
1023 | await req.attach('videofile', filePath) | 1023 | await req.attach('videofile', filePath) |
1024 | .expect(200) | 1024 | .expect(200) |
1025 | 1025 | ||
1026 | await waitJobs(servers) | 1026 | await waitJobs(servers) |
1027 | 1027 | ||
@@ -1046,7 +1046,7 @@ describe('Test multiple servers', function () { | |||
1046 | duration: 5, | 1046 | duration: 5, |
1047 | commentsEnabled: true, | 1047 | commentsEnabled: true, |
1048 | downloadEnabled: true, | 1048 | downloadEnabled: true, |
1049 | tags: [ ], | 1049 | tags: [], |
1050 | privacy: VideoPrivacy.PUBLIC, | 1050 | privacy: VideoPrivacy.PUBLIC, |
1051 | channel: { | 1051 | channel: { |
1052 | displayName: 'Main root channel', | 1052 | displayName: 'Main root channel', |
diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts index 17172331f..5505a845a 100644 --- a/server/tests/api/videos/services.ts +++ b/server/tests/api/videos/services.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
@@ -31,8 +31,8 @@ describe('Test services', function () { | |||
31 | 31 | ||
32 | const res = await getOEmbed(server.url, oembedUrl) | 32 | const res = await getOEmbed(server.url, oembedUrl) |
33 | const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' + | 33 | const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' + |
34 | `src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` + | 34 | `src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` + |
35 | 'frameborder="0" allowfullscreen></iframe>' | 35 | 'frameborder="0" allowfullscreen></iframe>' |
36 | const expectedThumbnailUrl = 'http://localhost:' + server.port + '/static/previews/' + server.video.uuid + '.jpg' | 36 | const expectedThumbnailUrl = 'http://localhost:' + server.port + '/static/previews/' + server.video.uuid + '.jpg' |
37 | 37 | ||
38 | expect(res.body.html).to.equal(expectedHtml) | 38 | expect(res.body.html).to.equal(expectedHtml) |
@@ -53,8 +53,8 @@ describe('Test services', function () { | |||
53 | 53 | ||
54 | const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth) | 54 | const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth) |
55 | const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' + | 55 | const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' + |
56 | `src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` + | 56 | `src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` + |
57 | 'frameborder="0" allowfullscreen></iframe>' | 57 | 'frameborder="0" allowfullscreen></iframe>' |
58 | 58 | ||
59 | expect(res.body.html).to.equal(expectedHtml) | 59 | expect(res.body.html).to.equal(expectedHtml) |
60 | expect(res.body.title).to.equal(server.video.name) | 60 | expect(res.body.title).to.equal(server.video.name) |
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index 362d6b78f..0ae405950 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import { keyBy } from 'lodash' | 4 | import { keyBy } from 'lodash' |
@@ -34,6 +34,7 @@ const expect = chai.expect | |||
34 | describe('Test a single server', function () { | 34 | describe('Test a single server', function () { |
35 | let server: ServerInfo = null | 35 | let server: ServerInfo = null |
36 | let videoId = -1 | 36 | let videoId = -1 |
37 | let videoId2 = -1 | ||
37 | let videoUUID = '' | 38 | let videoUUID = '' |
38 | let videosListBase: any[] = null | 39 | let videosListBase: any[] = null |
39 | 40 | ||
@@ -237,12 +238,11 @@ describe('Test a single server', function () { | |||
237 | it('Should upload 6 videos', async function () { | 238 | it('Should upload 6 videos', async function () { |
238 | this.timeout(25000) | 239 | this.timeout(25000) |
239 | 240 | ||
240 | const videos = [ | 241 | const videos = new Set([ |
241 | 'video_short.mp4', 'video_short.ogv', 'video_short.webm', | 242 | 'video_short.mp4', 'video_short.ogv', 'video_short.webm', |
242 | 'video_short1.webm', 'video_short2.webm', 'video_short3.webm' | 243 | 'video_short1.webm', 'video_short2.webm', 'video_short3.webm' |
243 | ] | 244 | ]) |
244 | 245 | ||
245 | const tasks: Promise<any>[] = [] | ||
246 | for (const video of videos) { | 246 | for (const video of videos) { |
247 | const videoAttributes = { | 247 | const videoAttributes = { |
248 | name: video + ' name', | 248 | name: video + ' name', |
@@ -255,11 +255,8 @@ describe('Test a single server', function () { | |||
255 | fixture: video | 255 | fixture: video |
256 | } | 256 | } |
257 | 257 | ||
258 | const p = uploadVideo(server.url, server.accessToken, videoAttributes) | 258 | await uploadVideo(server.url, server.accessToken, videoAttributes) |
259 | tasks.push(p) | ||
260 | } | 259 | } |
261 | |||
262 | await Promise.all(tasks) | ||
263 | }) | 260 | }) |
264 | 261 | ||
265 | it('Should have the correct durations', async function () { | 262 | it('Should have the correct durations', async function () { |
@@ -345,6 +342,7 @@ describe('Test a single server', function () { | |||
345 | expect(videos[5].name).to.equal('video_short1.webm name') | 342 | expect(videos[5].name).to.equal('video_short1.webm name') |
346 | 343 | ||
347 | videoId = videos[3].uuid | 344 | videoId = videos[3].uuid |
345 | videoId2 = videos[5].uuid | ||
348 | }) | 346 | }) |
349 | 347 | ||
350 | it('Should list and sort by trending in descending order', async function () { | 348 | it('Should list and sort by trending in descending order', async function () { |
@@ -433,6 +431,43 @@ describe('Test a single server', function () { | |||
433 | expect(video.dislikes).to.equal(1) | 431 | expect(video.dislikes).to.equal(1) |
434 | }) | 432 | }) |
435 | 433 | ||
434 | it('Should sort by originallyPublishedAt', async function () { | ||
435 | { | ||
436 | |||
437 | { | ||
438 | const now = new Date() | ||
439 | const attributes = { originallyPublishedAt: now.toISOString() } | ||
440 | await updateVideo(server.url, server.accessToken, videoId, attributes) | ||
441 | |||
442 | const res = await getVideosListSort(server.url, '-originallyPublishedAt') | ||
443 | const names = res.body.data.map(v => v.name) | ||
444 | |||
445 | expect(names[0]).to.equal('my super video updated') | ||
446 | expect(names[1]).to.equal('video_short2.webm name') | ||
447 | expect(names[2]).to.equal('video_short1.webm name') | ||
448 | expect(names[3]).to.equal('video_short.webm name') | ||
449 | expect(names[4]).to.equal('video_short.ogv name') | ||
450 | expect(names[5]).to.equal('video_short.mp4 name') | ||
451 | } | ||
452 | |||
453 | { | ||
454 | const now = new Date() | ||
455 | const attributes = { originallyPublishedAt: now.toISOString() } | ||
456 | await updateVideo(server.url, server.accessToken, videoId2, attributes) | ||
457 | |||
458 | const res = await getVideosListSort(server.url, '-originallyPublishedAt') | ||
459 | const names = res.body.data.map(v => v.name) | ||
460 | |||
461 | expect(names[0]).to.equal('video_short1.webm name') | ||
462 | expect(names[1]).to.equal('my super video updated') | ||
463 | expect(names[2]).to.equal('video_short2.webm name') | ||
464 | expect(names[3]).to.equal('video_short.webm name') | ||
465 | expect(names[4]).to.equal('video_short.ogv name') | ||
466 | expect(names[5]).to.equal('video_short.mp4 name') | ||
467 | } | ||
468 | } | ||
469 | }) | ||
470 | |||
436 | after(async function () { | 471 | after(async function () { |
437 | await cleanupTests([ server ]) | 472 | await cleanupTests([ server ]) |
438 | }) | 473 | }) |
diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts index 0cd6f22c7..a96be97f6 100644 --- a/server/tests/api/videos/video-abuse.ts +++ b/server/tests/api/videos/video-abuse.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
@@ -13,7 +13,10 @@ import { | |||
13 | ServerInfo, | 13 | ServerInfo, |
14 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
15 | updateVideoAbuse, | 15 | updateVideoAbuse, |
16 | uploadVideo | 16 | uploadVideo, |
17 | removeVideo, | ||
18 | createUser, | ||
19 | userLogin | ||
17 | } from '../../../../shared/extra-utils/index' | 20 | } from '../../../../shared/extra-utils/index' |
18 | import { doubleFollow } from '../../../../shared/extra-utils/server/follows' | 21 | import { doubleFollow } from '../../../../shared/extra-utils/server/follows' |
19 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 22 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
@@ -68,7 +71,7 @@ describe('Test video abuses', function () { | |||
68 | }) | 71 | }) |
69 | 72 | ||
70 | it('Should not have video abuses', async function () { | 73 | it('Should not have video abuses', async function () { |
71 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 74 | const res = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
72 | 75 | ||
73 | expect(res.body.total).to.equal(0) | 76 | expect(res.body.total).to.equal(0) |
74 | expect(res.body.data).to.be.an('array') | 77 | expect(res.body.data).to.be.an('array') |
@@ -86,7 +89,7 @@ describe('Test video abuses', function () { | |||
86 | }) | 89 | }) |
87 | 90 | ||
88 | it('Should have 1 video abuses on server 1 and 0 on server 2', async function () { | 91 | it('Should have 1 video abuses on server 1 and 0 on server 2', async function () { |
89 | const res1 = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 92 | const res1 = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
90 | 93 | ||
91 | expect(res1.body.total).to.equal(1) | 94 | expect(res1.body.total).to.equal(1) |
92 | expect(res1.body.data).to.be.an('array') | 95 | expect(res1.body.data).to.be.an('array') |
@@ -97,8 +100,13 @@ describe('Test video abuses', function () { | |||
97 | expect(abuse.reporterAccount.name).to.equal('root') | 100 | expect(abuse.reporterAccount.name).to.equal('root') |
98 | expect(abuse.reporterAccount.host).to.equal('localhost:' + servers[0].port) | 101 | expect(abuse.reporterAccount.host).to.equal('localhost:' + servers[0].port) |
99 | expect(abuse.video.id).to.equal(servers[0].video.id) | 102 | expect(abuse.video.id).to.equal(servers[0].video.id) |
103 | expect(abuse.video.channel).to.exist | ||
104 | expect(abuse.count).to.equal(1) | ||
105 | expect(abuse.nth).to.equal(1) | ||
106 | expect(abuse.countReportsForReporter).to.equal(1) | ||
107 | expect(abuse.countReportsForReportee).to.equal(1) | ||
100 | 108 | ||
101 | const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 109 | const res2 = await getVideoAbusesList({ url: servers[1].url, token: servers[1].accessToken }) |
102 | expect(res2.body.total).to.equal(0) | 110 | expect(res2.body.total).to.equal(0) |
103 | expect(res2.body.data).to.be.an('array') | 111 | expect(res2.body.data).to.be.an('array') |
104 | expect(res2.body.data.length).to.equal(0) | 112 | expect(res2.body.data.length).to.equal(0) |
@@ -115,7 +123,7 @@ describe('Test video abuses', function () { | |||
115 | }) | 123 | }) |
116 | 124 | ||
117 | it('Should have 2 video abuses on server 1 and 1 on server 2', async function () { | 125 | it('Should have 2 video abuses on server 1 and 1 on server 2', async function () { |
118 | const res1 = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 126 | const res1 = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
119 | expect(res1.body.total).to.equal(2) | 127 | expect(res1.body.total).to.equal(2) |
120 | expect(res1.body.data).to.be.an('array') | 128 | expect(res1.body.data).to.be.an('array') |
121 | expect(res1.body.data.length).to.equal(2) | 129 | expect(res1.body.data.length).to.equal(2) |
@@ -128,6 +136,8 @@ describe('Test video abuses', function () { | |||
128 | expect(abuse1.state.id).to.equal(VideoAbuseState.PENDING) | 136 | expect(abuse1.state.id).to.equal(VideoAbuseState.PENDING) |
129 | expect(abuse1.state.label).to.equal('Pending') | 137 | expect(abuse1.state.label).to.equal('Pending') |
130 | expect(abuse1.moderationComment).to.be.null | 138 | expect(abuse1.moderationComment).to.be.null |
139 | expect(abuse1.count).to.equal(1) | ||
140 | expect(abuse1.nth).to.equal(1) | ||
131 | 141 | ||
132 | const abuse2: VideoAbuse = res1.body.data[1] | 142 | const abuse2: VideoAbuse = res1.body.data[1] |
133 | expect(abuse2.reason).to.equal('my super bad reason 2') | 143 | expect(abuse2.reason).to.equal('my super bad reason 2') |
@@ -138,7 +148,7 @@ describe('Test video abuses', function () { | |||
138 | expect(abuse2.state.label).to.equal('Pending') | 148 | expect(abuse2.state.label).to.equal('Pending') |
139 | expect(abuse2.moderationComment).to.be.null | 149 | expect(abuse2.moderationComment).to.be.null |
140 | 150 | ||
141 | const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 151 | const res2 = await getVideoAbusesList({ url: servers[1].url, token: servers[1].accessToken }) |
142 | expect(res2.body.total).to.equal(1) | 152 | expect(res2.body.total).to.equal(1) |
143 | expect(res2.body.data).to.be.an('array') | 153 | expect(res2.body.data).to.be.an('array') |
144 | expect(res2.body.data.length).to.equal(1) | 154 | expect(res2.body.data.length).to.equal(1) |
@@ -156,7 +166,7 @@ describe('Test video abuses', function () { | |||
156 | const body = { state: VideoAbuseState.REJECTED } | 166 | const body = { state: VideoAbuseState.REJECTED } |
157 | await updateVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id, body) | 167 | await updateVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id, body) |
158 | 168 | ||
159 | const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 169 | const res = await getVideoAbusesList({ url: servers[1].url, token: servers[1].accessToken }) |
160 | expect(res.body.data[0].state.id).to.equal(VideoAbuseState.REJECTED) | 170 | expect(res.body.data[0].state.id).to.equal(VideoAbuseState.REJECTED) |
161 | }) | 171 | }) |
162 | 172 | ||
@@ -164,7 +174,7 @@ describe('Test video abuses', function () { | |||
164 | const body = { state: VideoAbuseState.ACCEPTED, moderationComment: 'It is valid' } | 174 | const body = { state: VideoAbuseState.ACCEPTED, moderationComment: 'It is valid' } |
165 | await updateVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id, body) | 175 | await updateVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id, body) |
166 | 176 | ||
167 | const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 177 | const res = await getVideoAbusesList({ url: servers[1].url, token: servers[1].accessToken }) |
168 | expect(res.body.data[0].state.id).to.equal(VideoAbuseState.ACCEPTED) | 178 | expect(res.body.data[0].state.id).to.equal(VideoAbuseState.ACCEPTED) |
169 | expect(res.body.data[0].moderationComment).to.equal('It is valid') | 179 | expect(res.body.data[0].moderationComment).to.equal('It is valid') |
170 | }) | 180 | }) |
@@ -176,16 +186,16 @@ describe('Test video abuses', function () { | |||
176 | await reportVideoAbuse(servers[1].url, servers[1].accessToken, servers[0].video.uuid, 'will mute this') | 186 | await reportVideoAbuse(servers[1].url, servers[1].accessToken, servers[0].video.uuid, 'will mute this') |
177 | await waitJobs(servers) | 187 | await waitJobs(servers) |
178 | 188 | ||
179 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 189 | const res = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
180 | expect(res.body.total).to.equal(3) | 190 | expect(res.body.total).to.equal(3) |
181 | } | 191 | } |
182 | 192 | ||
183 | const accountToBlock = 'root@localhost:' + servers[1].port | 193 | const accountToBlock = 'root@localhost:' + servers[1].port |
184 | 194 | ||
185 | { | 195 | { |
186 | await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, accountToBlock) | 196 | await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, accountToBlock) |
187 | 197 | ||
188 | const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken) | 198 | const res = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
189 | expect(res.body.total).to.equal(2) | 199 | expect(res.body.total).to.equal(2) |
190 | 200 | ||
191 | const abuse = res.body.data.find(a => a.reason === 'will mute this') | 201 | const abuse = res.body.data.find(a => a.reason === 'will mute this') |
@@ -193,9 +203,9 @@ describe('Test video abuses', function () { | |||
193 | } | 203 | } |
194 | 204 | ||
195 | { | 205 | { |
196 | await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, accountToBlock) | 206 | await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, accountToBlock) |
197 | 207 | ||
198 | const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken) | 208 | const res = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
199 | expect(res.body.total).to.equal(3) | 209 | expect(res.body.total).to.equal(3) |
200 | } | 210 | } |
201 | }) | 211 | }) |
@@ -204,9 +214,9 @@ describe('Test video abuses', function () { | |||
204 | const serverToBlock = servers[1].host | 214 | const serverToBlock = servers[1].host |
205 | 215 | ||
206 | { | 216 | { |
207 | await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, servers[1].host) | 217 | await addServerToServerBlocklist(servers[0].url, servers[0].accessToken, servers[1].host) |
208 | 218 | ||
209 | const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken) | 219 | const res = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
210 | expect(res.body.total).to.equal(2) | 220 | expect(res.body.total).to.equal(2) |
211 | 221 | ||
212 | const abuse = res.body.data.find(a => a.reason === 'will mute this') | 222 | const abuse = res.body.data.find(a => a.reason === 'will mute this') |
@@ -214,13 +224,73 @@ describe('Test video abuses', function () { | |||
214 | } | 224 | } |
215 | 225 | ||
216 | { | 226 | { |
217 | await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, serverToBlock) | 227 | await removeServerFromServerBlocklist(servers[0].url, servers[0].accessToken, serverToBlock) |
218 | 228 | ||
219 | const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken) | 229 | const res = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
220 | expect(res.body.total).to.equal(3) | 230 | expect(res.body.total).to.equal(3) |
221 | } | 231 | } |
222 | }) | 232 | }) |
223 | 233 | ||
234 | it('Should keep the video abuse when deleting the video', async function () { | ||
235 | this.timeout(10000) | ||
236 | |||
237 | await removeVideo(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid) | ||
238 | |||
239 | await waitJobs(servers) | ||
240 | |||
241 | const res = await getVideoAbusesList({ url: servers[1].url, token: servers[1].accessToken }) | ||
242 | expect(res.body.total).to.equal(2, "wrong number of videos returned") | ||
243 | expect(res.body.data.length).to.equal(2, "wrong number of videos returned") | ||
244 | expect(res.body.data[0].id).to.equal(abuseServer2.id, "wrong origin server id for first video") | ||
245 | |||
246 | const abuse: VideoAbuse = res.body.data[0] | ||
247 | expect(abuse.video.id).to.equal(abuseServer2.video.id, "wrong video id") | ||
248 | expect(abuse.video.channel).to.exist | ||
249 | expect(abuse.video.deleted).to.be.true | ||
250 | }) | ||
251 | |||
252 | it('Should include counts of reports from reporter and reportee', async function () { | ||
253 | this.timeout(10000) | ||
254 | |||
255 | // register a second user to have two reporters/reportees | ||
256 | const user = { username: 'user2', password: 'password' } | ||
257 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, ...user }) | ||
258 | const userAccessToken = await userLogin(servers[0], user) | ||
259 | |||
260 | // upload a third video via this user | ||
261 | const video3Attributes = { | ||
262 | name: 'my second super name for server 1', | ||
263 | description: 'my second super description for server 1' | ||
264 | } | ||
265 | await uploadVideo(servers[0].url, userAccessToken, video3Attributes) | ||
266 | |||
267 | const res1 = await getVideosList(servers[0].url) | ||
268 | const videos = res1.body.data | ||
269 | const video3 = videos.find(video => video.name === 'my second super name for server 1') | ||
270 | |||
271 | // resume with the test | ||
272 | const reason3 = 'my super bad reason 3' | ||
273 | await reportVideoAbuse(servers[0].url, servers[0].accessToken, video3.id, reason3) | ||
274 | const reason4 = 'my super bad reason 4' | ||
275 | await reportVideoAbuse(servers[0].url, userAccessToken, servers[0].video.id, reason4) | ||
276 | |||
277 | const res2 = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) | ||
278 | |||
279 | { | ||
280 | for (const abuse of res2.body.data as VideoAbuse[]) { | ||
281 | if (abuse.video.id === video3.id) { | ||
282 | expect(abuse.count).to.equal(1, "wrong reports count for video 3") | ||
283 | expect(abuse.nth).to.equal(1, "wrong report position in report list for video 3") | ||
284 | expect(abuse.countReportsForReportee).to.equal(1, "wrong reports count for reporter on video 3 abuse") | ||
285 | expect(abuse.countReportsForReporter).to.equal(3, "wrong reports count for reportee on video 3 abuse") | ||
286 | } | ||
287 | if (abuse.video.id === servers[0].video.id) { | ||
288 | expect(abuse.countReportsForReportee).to.equal(3, "wrong reports count for reporter on video 1 abuse") | ||
289 | } | ||
290 | } | ||
291 | } | ||
292 | }) | ||
293 | |||
224 | it('Should delete the video abuse', async function () { | 294 | it('Should delete the video abuse', async function () { |
225 | this.timeout(10000) | 295 | this.timeout(10000) |
226 | 296 | ||
@@ -229,16 +299,54 @@ describe('Test video abuses', function () { | |||
229 | await waitJobs(servers) | 299 | await waitJobs(servers) |
230 | 300 | ||
231 | { | 301 | { |
232 | const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 302 | const res = await getVideoAbusesList({ url: servers[1].url, token: servers[1].accessToken }) |
233 | expect(res.body.total).to.equal(1) | 303 | expect(res.body.total).to.equal(1) |
234 | expect(res.body.data.length).to.equal(1) | 304 | expect(res.body.data.length).to.equal(1) |
235 | expect(res.body.data[0].id).to.not.equal(abuseServer2.id) | 305 | expect(res.body.data[0].id).to.not.equal(abuseServer2.id) |
236 | } | 306 | } |
237 | 307 | ||
238 | { | 308 | { |
239 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 309 | const res = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
240 | expect(res.body.total).to.equal(3) | 310 | expect(res.body.total).to.equal(5) |
311 | } | ||
312 | }) | ||
313 | |||
314 | it('Should list and filter video abuses', async function () { | ||
315 | async function list (query: Omit<Parameters<typeof getVideoAbusesList>[0], 'url' | 'token'>) { | ||
316 | const options = { | ||
317 | url: servers[0].url, | ||
318 | token: servers[0].accessToken | ||
319 | } | ||
320 | |||
321 | Object.assign(options, query) | ||
322 | |||
323 | const res = await getVideoAbusesList(options) | ||
324 | |||
325 | return res.body.data as VideoAbuse[] | ||
241 | } | 326 | } |
327 | |||
328 | expect(await list({ id: 56 })).to.have.lengthOf(0) | ||
329 | expect(await list({ id: 1 })).to.have.lengthOf(1) | ||
330 | |||
331 | expect(await list({ search: 'my super name for server 1' })).to.have.lengthOf(3) | ||
332 | expect(await list({ search: 'aaaaaaaaaaaaaaaaaaaaaaaaaa' })).to.have.lengthOf(0) | ||
333 | |||
334 | expect(await list({ searchVideo: 'my second super name for server 1' })).to.have.lengthOf(1) | ||
335 | |||
336 | expect(await list({ searchVideoChannel: 'root' })).to.have.lengthOf(3) | ||
337 | expect(await list({ searchVideoChannel: 'aaaa' })).to.have.lengthOf(0) | ||
338 | |||
339 | expect(await list({ searchReporter: 'user2' })).to.have.lengthOf(1) | ||
340 | expect(await list({ searchReporter: 'root' })).to.have.lengthOf(4) | ||
341 | |||
342 | expect(await list({ searchReportee: 'root' })).to.have.lengthOf(3) | ||
343 | expect(await list({ searchReportee: 'aaaa' })).to.have.lengthOf(0) | ||
344 | |||
345 | expect(await list({ videoIs: 'deleted' })).to.have.lengthOf(1) | ||
346 | expect(await list({ videoIs: 'blacklisted' })).to.have.lengthOf(0) | ||
347 | |||
348 | expect(await list({ state: VideoAbuseState.ACCEPTED })).to.have.lengthOf(0) | ||
349 | expect(await list({ state: VideoAbuseState.PENDING })).to.have.lengthOf(5) | ||
242 | }) | 350 | }) |
243 | 351 | ||
244 | after(async function () { | 352 | after(async function () { |
diff --git a/server/tests/api/videos/video-blacklist.ts b/server/tests/api/videos/video-blacklist.ts index 854b2f0cb..67bc0114c 100644 --- a/server/tests/api/videos/video-blacklist.ts +++ b/server/tests/api/videos/video-blacklist.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import { orderBy } from 'lodash' | 4 | import { orderBy } from 'lodash' |
@@ -8,7 +8,8 @@ import { | |||
8 | cleanupTests, | 8 | cleanupTests, |
9 | createUser, | 9 | createUser, |
10 | flushAndRunMultipleServers, | 10 | flushAndRunMultipleServers, |
11 | getBlacklistedVideosList, getMyUserInformation, | 11 | getBlacklistedVideosList, |
12 | getMyUserInformation, | ||
12 | getMyVideos, | 13 | getMyVideos, |
13 | getVideosList, | 14 | getVideosList, |
14 | killallServers, | 15 | killallServers, |
@@ -17,7 +18,6 @@ import { | |||
17 | searchVideo, | 18 | searchVideo, |
18 | ServerInfo, | 19 | ServerInfo, |
19 | setAccessTokensToServers, | 20 | setAccessTokensToServers, |
20 | setDefaultVideoChannel, | ||
21 | updateVideo, | 21 | updateVideo, |
22 | updateVideoBlacklist, | 22 | updateVideoBlacklist, |
23 | uploadVideo, | 23 | uploadVideo, |
@@ -27,7 +27,7 @@ import { doubleFollow } from '../../../../shared/extra-utils/server/follows' | |||
27 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 27 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
28 | import { VideoBlacklist, VideoBlacklistType } from '../../../../shared/models/videos' | 28 | import { VideoBlacklist, VideoBlacklistType } from '../../../../shared/models/videos' |
29 | import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' | 29 | import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' |
30 | import { User, UserRole, UserUpdateMe } from '../../../../shared/models/users' | 30 | import { User, UserRole } from '../../../../shared/models/users' |
31 | import { getMagnetURI, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' | 31 | import { getMagnetURI, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' |
32 | 32 | ||
33 | const expect = chai.expect | 33 | const expect = chai.expect |
@@ -40,7 +40,7 @@ describe('Test video blacklist', function () { | |||
40 | const res = await getVideosList(server.url) | 40 | const res = await getVideosList(server.url) |
41 | 41 | ||
42 | const videos = res.body.data | 42 | const videos = res.body.data |
43 | for (let video of videos) { | 43 | for (const video of videos) { |
44 | await addVideoToBlacklist(server.url, server.accessToken, video.id, 'super reason') | 44 | await addVideoToBlacklist(server.url, server.accessToken, video.id, 'super reason') |
45 | } | 45 | } |
46 | } | 46 | } |
@@ -72,7 +72,7 @@ describe('Test video blacklist', function () { | |||
72 | 72 | ||
73 | it('Should not have the video blacklisted in videos list/search on server 1', async function () { | 73 | it('Should not have the video blacklisted in videos list/search on server 1', async function () { |
74 | { | 74 | { |
75 | const res = await getVideosList(servers[ 0 ].url) | 75 | const res = await getVideosList(servers[0].url) |
76 | 76 | ||
77 | expect(res.body.total).to.equal(0) | 77 | expect(res.body.total).to.equal(0) |
78 | expect(res.body.data).to.be.an('array') | 78 | expect(res.body.data).to.be.an('array') |
@@ -80,7 +80,7 @@ describe('Test video blacklist', function () { | |||
80 | } | 80 | } |
81 | 81 | ||
82 | { | 82 | { |
83 | const res = await searchVideo(servers[ 0 ].url, 'name') | 83 | const res = await searchVideo(servers[0].url, 'name') |
84 | 84 | ||
85 | expect(res.body.total).to.equal(0) | 85 | expect(res.body.total).to.equal(0) |
86 | expect(res.body.data).to.be.an('array') | 86 | expect(res.body.data).to.be.an('array') |
@@ -90,7 +90,7 @@ describe('Test video blacklist', function () { | |||
90 | 90 | ||
91 | it('Should have the blacklisted video in videos list/search on server 2', async function () { | 91 | it('Should have the blacklisted video in videos list/search on server 2', async function () { |
92 | { | 92 | { |
93 | const res = await getVideosList(servers[ 1 ].url) | 93 | const res = await getVideosList(servers[1].url) |
94 | 94 | ||
95 | expect(res.body.total).to.equal(2) | 95 | expect(res.body.total).to.equal(2) |
96 | expect(res.body.data).to.be.an('array') | 96 | expect(res.body.data).to.be.an('array') |
@@ -98,7 +98,7 @@ describe('Test video blacklist', function () { | |||
98 | } | 98 | } |
99 | 99 | ||
100 | { | 100 | { |
101 | const res = await searchVideo(servers[ 1 ].url, 'video') | 101 | const res = await searchVideo(servers[1].url, 'video') |
102 | 102 | ||
103 | expect(res.body.total).to.equal(2) | 103 | expect(res.body.total).to.equal(2) |
104 | expect(res.body.data).to.be.an('array') | 104 | expect(res.body.data).to.be.an('array') |
@@ -125,8 +125,8 @@ describe('Test video blacklist', function () { | |||
125 | 125 | ||
126 | it('Should display all the blacklisted videos when applying manual type filter', async function () { | 126 | it('Should display all the blacklisted videos when applying manual type filter', async function () { |
127 | const res = await getBlacklistedVideosList({ | 127 | const res = await getBlacklistedVideosList({ |
128 | url: servers[ 0 ].url, | 128 | url: servers[0].url, |
129 | token: servers[ 0 ].accessToken, | 129 | token: servers[0].accessToken, |
130 | type: VideoBlacklistType.MANUAL | 130 | type: VideoBlacklistType.MANUAL |
131 | }) | 131 | }) |
132 | 132 | ||
@@ -139,8 +139,8 @@ describe('Test video blacklist', function () { | |||
139 | 139 | ||
140 | it('Should display nothing when applying automatic type filter', async function () { | 140 | it('Should display nothing when applying automatic type filter', async function () { |
141 | const res = await getBlacklistedVideosList({ | 141 | const res = await getBlacklistedVideosList({ |
142 | url: servers[ 0 ].url, | 142 | url: servers[0].url, |
143 | token: servers[ 0 ].accessToken, | 143 | token: servers[0].accessToken, |
144 | type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED | 144 | type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED |
145 | }) | 145 | }) |
146 | 146 | ||
@@ -152,7 +152,7 @@ describe('Test video blacklist', function () { | |||
152 | }) | 152 | }) |
153 | 153 | ||
154 | it('Should get the correct sort when sorting by descending id', async function () { | 154 | it('Should get the correct sort when sorting by descending id', async function () { |
155 | const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: '-id' }) | 155 | const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-id' }) |
156 | expect(res.body.total).to.equal(2) | 156 | expect(res.body.total).to.equal(2) |
157 | 157 | ||
158 | const blacklistedVideos = res.body.data | 158 | const blacklistedVideos = res.body.data |
@@ -165,7 +165,7 @@ describe('Test video blacklist', function () { | |||
165 | }) | 165 | }) |
166 | 166 | ||
167 | it('Should get the correct sort when sorting by descending video name', async function () { | 167 | it('Should get the correct sort when sorting by descending video name', async function () { |
168 | const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: '-name' }) | 168 | const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' }) |
169 | expect(res.body.total).to.equal(2) | 169 | expect(res.body.total).to.equal(2) |
170 | 170 | ||
171 | const blacklistedVideos = res.body.data | 171 | const blacklistedVideos = res.body.data |
@@ -178,7 +178,7 @@ describe('Test video blacklist', function () { | |||
178 | }) | 178 | }) |
179 | 179 | ||
180 | it('Should get the correct sort when sorting by ascending creation date', async function () { | 180 | it('Should get the correct sort when sorting by ascending creation date', async function () { |
181 | const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: 'createdAt' }) | 181 | const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: 'createdAt' }) |
182 | expect(res.body.total).to.equal(2) | 182 | expect(res.body.total).to.equal(2) |
183 | 183 | ||
184 | const blacklistedVideos = res.body.data | 184 | const blacklistedVideos = res.body.data |
@@ -195,7 +195,7 @@ describe('Test video blacklist', function () { | |||
195 | it('Should change the reason', async function () { | 195 | it('Should change the reason', async function () { |
196 | await updateVideoBlacklist(servers[0].url, servers[0].accessToken, videoId, 'my super reason updated') | 196 | await updateVideoBlacklist(servers[0].url, servers[0].accessToken, videoId, 'my super reason updated') |
197 | 197 | ||
198 | const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: '-name' }) | 198 | const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' }) |
199 | const video = res.body.data.find(b => b.video.id === videoId) | 199 | const video = res.body.data.find(b => b.video.id === videoId) |
200 | 200 | ||
201 | expect(video.reason).to.equal('my super reason updated') | 201 | expect(video.reason).to.equal('my super reason updated') |
@@ -231,7 +231,7 @@ describe('Test video blacklist', function () { | |||
231 | 231 | ||
232 | it('Should remove a video from the blacklist on server 1', async function () { | 232 | it('Should remove a video from the blacklist on server 1', async function () { |
233 | // Get one video in the blacklist | 233 | // Get one video in the blacklist |
234 | const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: '-name' }) | 234 | const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' }) |
235 | videoToRemove = res.body.data[0] | 235 | videoToRemove = res.body.data[0] |
236 | blacklist = res.body.data.slice(1) | 236 | blacklist = res.body.data.slice(1) |
237 | 237 | ||
@@ -252,7 +252,7 @@ describe('Test video blacklist', function () { | |||
252 | }) | 252 | }) |
253 | 253 | ||
254 | it('Should not have the ex-blacklisted video in videos blacklist list on server 1', async function () { | 254 | it('Should not have the ex-blacklisted video in videos blacklist list on server 1', async function () { |
255 | const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: '-name' }) | 255 | const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: '-name' }) |
256 | expect(res.body.total).to.equal(1) | 256 | expect(res.body.total).to.equal(1) |
257 | 257 | ||
258 | const videos = res.body.data | 258 | const videos = res.body.data |
@@ -274,7 +274,7 @@ describe('Test video blacklist', function () { | |||
274 | video3UUID = res.body.video.uuid | 274 | video3UUID = res.body.video.uuid |
275 | } | 275 | } |
276 | { | 276 | { |
277 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'Video 4' }) | 277 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'Video 4' }) |
278 | video4UUID = res.body.video.uuid | 278 | video4UUID = res.body.video.uuid |
279 | } | 279 | } |
280 | 280 | ||
@@ -284,17 +284,17 @@ describe('Test video blacklist', function () { | |||
284 | it('Should blacklist video 3 and keep it federated', async function () { | 284 | it('Should blacklist video 3 and keep it federated', async function () { |
285 | this.timeout(10000) | 285 | this.timeout(10000) |
286 | 286 | ||
287 | await addVideoToBlacklist(servers[ 0 ].url, servers[ 0 ].accessToken, video3UUID, 'super reason', false) | 287 | await addVideoToBlacklist(servers[0].url, servers[0].accessToken, video3UUID, 'super reason', false) |
288 | 288 | ||
289 | await waitJobs(servers) | 289 | await waitJobs(servers) |
290 | 290 | ||
291 | { | 291 | { |
292 | const res = await getVideosList(servers[ 0 ].url) | 292 | const res = await getVideosList(servers[0].url) |
293 | expect(res.body.data.find(v => v.uuid === video3UUID)).to.be.undefined | 293 | expect(res.body.data.find(v => v.uuid === video3UUID)).to.be.undefined |
294 | } | 294 | } |
295 | 295 | ||
296 | { | 296 | { |
297 | const res = await getVideosList(servers[ 1 ].url) | 297 | const res = await getVideosList(servers[1].url) |
298 | expect(res.body.data.find(v => v.uuid === video3UUID)).to.not.be.undefined | 298 | expect(res.body.data.find(v => v.uuid === video3UUID)).to.not.be.undefined |
299 | } | 299 | } |
300 | }) | 300 | }) |
@@ -302,7 +302,7 @@ describe('Test video blacklist', function () { | |||
302 | it('Should unfederate the video', async function () { | 302 | it('Should unfederate the video', async function () { |
303 | this.timeout(10000) | 303 | this.timeout(10000) |
304 | 304 | ||
305 | await addVideoToBlacklist(servers[ 0 ].url, servers[ 0 ].accessToken, video4UUID, 'super reason', true) | 305 | await addVideoToBlacklist(servers[0].url, servers[0].accessToken, video4UUID, 'super reason', true) |
306 | 306 | ||
307 | await waitJobs(servers) | 307 | await waitJobs(servers) |
308 | 308 | ||
@@ -315,7 +315,7 @@ describe('Test video blacklist', function () { | |||
315 | it('Should have the video unfederated even after an Update AP message', async function () { | 315 | it('Should have the video unfederated even after an Update AP message', async function () { |
316 | this.timeout(10000) | 316 | this.timeout(10000) |
317 | 317 | ||
318 | await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, video4UUID, { description: 'super description' }) | 318 | await updateVideo(servers[0].url, servers[0].accessToken, video4UUID, { description: 'super description' }) |
319 | 319 | ||
320 | await waitJobs(servers) | 320 | await waitJobs(servers) |
321 | 321 | ||
@@ -326,7 +326,7 @@ describe('Test video blacklist', function () { | |||
326 | }) | 326 | }) |
327 | 327 | ||
328 | it('Should have the correct video blacklist unfederate attribute', async function () { | 328 | it('Should have the correct video blacklist unfederate attribute', async function () { |
329 | const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: 'createdAt' }) | 329 | const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: 'createdAt' }) |
330 | 330 | ||
331 | const blacklistedVideos: VideoBlacklist[] = res.body.data | 331 | const blacklistedVideos: VideoBlacklist[] = res.body.data |
332 | const video3Blacklisted = blacklistedVideos.find(b => b.video.uuid === video3UUID) | 332 | const video3Blacklisted = blacklistedVideos.find(b => b.video.uuid === video3UUID) |
@@ -339,7 +339,7 @@ describe('Test video blacklist', function () { | |||
339 | it('Should remove the video from blacklist and refederate the video', async function () { | 339 | it('Should remove the video from blacklist and refederate the video', async function () { |
340 | this.timeout(10000) | 340 | this.timeout(10000) |
341 | 341 | ||
342 | await removeVideoFromBlacklist(servers[ 0 ].url, servers[ 0 ].accessToken, video4UUID) | 342 | await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, video4UUID) |
343 | 343 | ||
344 | await waitJobs(servers) | 344 | await waitJobs(servers) |
345 | 345 | ||
@@ -362,9 +362,9 @@ describe('Test video blacklist', function () { | |||
362 | killallServers([ servers[0] ]) | 362 | killallServers([ servers[0] ]) |
363 | 363 | ||
364 | const config = { | 364 | const config = { |
365 | 'auto_blacklist': { | 365 | auto_blacklist: { |
366 | videos: { | 366 | videos: { |
367 | 'of_users': { | 367 | of_users: { |
368 | enabled: true | 368 | enabled: true |
369 | } | 369 | } |
370 | } | 370 | } |
@@ -375,8 +375,8 @@ describe('Test video blacklist', function () { | |||
375 | { | 375 | { |
376 | const user = { username: 'user_without_flag', password: 'password' } | 376 | const user = { username: 'user_without_flag', password: 'password' } |
377 | await createUser({ | 377 | await createUser({ |
378 | url: servers[ 0 ].url, | 378 | url: servers[0].url, |
379 | accessToken: servers[ 0 ].accessToken, | 379 | accessToken: servers[0].accessToken, |
380 | username: user.username, | 380 | username: user.username, |
381 | adminFlags: UserAdminFlag.NONE, | 381 | adminFlags: UserAdminFlag.NONE, |
382 | password: user.password, | 382 | password: user.password, |
@@ -393,8 +393,8 @@ describe('Test video blacklist', function () { | |||
393 | { | 393 | { |
394 | const user = { username: 'user_with_flag', password: 'password' } | 394 | const user = { username: 'user_with_flag', password: 'password' } |
395 | await createUser({ | 395 | await createUser({ |
396 | url: servers[ 0 ].url, | 396 | url: servers[0].url, |
397 | accessToken: servers[ 0 ].accessToken, | 397 | accessToken: servers[0].accessToken, |
398 | username: user.username, | 398 | username: user.username, |
399 | adminFlags: UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST, | 399 | adminFlags: UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST, |
400 | password: user.password, | 400 | password: user.password, |
@@ -411,8 +411,8 @@ describe('Test video blacklist', function () { | |||
411 | await uploadVideo(servers[0].url, userWithoutFlag, { name: 'blacklisted' }) | 411 | await uploadVideo(servers[0].url, userWithoutFlag, { name: 'blacklisted' }) |
412 | 412 | ||
413 | const res = await getBlacklistedVideosList({ | 413 | const res = await getBlacklistedVideosList({ |
414 | url: servers[ 0 ].url, | 414 | url: servers[0].url, |
415 | token: servers[ 0 ].accessToken, | 415 | token: servers[0].accessToken, |
416 | type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED | 416 | type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED |
417 | }) | 417 | }) |
418 | 418 | ||
@@ -428,11 +428,11 @@ describe('Test video blacklist', function () { | |||
428 | name: 'URL import', | 428 | name: 'URL import', |
429 | channelId: channelOfUserWithoutFlag | 429 | channelId: channelOfUserWithoutFlag |
430 | } | 430 | } |
431 | await importVideo(servers[ 0 ].url, userWithoutFlag, attributes) | 431 | await importVideo(servers[0].url, userWithoutFlag, attributes) |
432 | 432 | ||
433 | const res = await getBlacklistedVideosList({ | 433 | const res = await getBlacklistedVideosList({ |
434 | url: servers[ 0 ].url, | 434 | url: servers[0].url, |
435 | token: servers[ 0 ].accessToken, | 435 | token: servers[0].accessToken, |
436 | sort: 'createdAt', | 436 | sort: 'createdAt', |
437 | type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED | 437 | type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED |
438 | }) | 438 | }) |
@@ -447,11 +447,11 @@ describe('Test video blacklist', function () { | |||
447 | name: 'Torrent import', | 447 | name: 'Torrent import', |
448 | channelId: channelOfUserWithoutFlag | 448 | channelId: channelOfUserWithoutFlag |
449 | } | 449 | } |
450 | await importVideo(servers[ 0 ].url, userWithoutFlag, attributes) | 450 | await importVideo(servers[0].url, userWithoutFlag, attributes) |
451 | 451 | ||
452 | const res = await getBlacklistedVideosList({ | 452 | const res = await getBlacklistedVideosList({ |
453 | url: servers[ 0 ].url, | 453 | url: servers[0].url, |
454 | token: servers[ 0 ].accessToken, | 454 | token: servers[0].accessToken, |
455 | sort: 'createdAt', | 455 | sort: 'createdAt', |
456 | type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED | 456 | type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED |
457 | }) | 457 | }) |
@@ -464,8 +464,8 @@ describe('Test video blacklist', function () { | |||
464 | await uploadVideo(servers[0].url, userWithFlag, { name: 'not blacklisted' }) | 464 | await uploadVideo(servers[0].url, userWithFlag, { name: 'not blacklisted' }) |
465 | 465 | ||
466 | const res = await getBlacklistedVideosList({ | 466 | const res = await getBlacklistedVideosList({ |
467 | url: servers[ 0 ].url, | 467 | url: servers[0].url, |
468 | token: servers[ 0 ].accessToken, | 468 | token: servers[0].accessToken, |
469 | type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED | 469 | type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED |
470 | }) | 470 | }) |
471 | 471 | ||
diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts index 5e13f5949..b4ecb39f4 100644 --- a/server/tests/api/videos/video-captions.ts +++ b/server/tests/api/videos/video-captions.ts | |||
@@ -1,16 +1,17 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { | 5 | import { |
6 | checkVideoFilesWereRemoved, cleanupTests, | 6 | checkVideoFilesWereRemoved, |
7 | cleanupTests, | ||
7 | doubleFollow, | 8 | doubleFollow, |
8 | flushAndRunMultipleServers, | 9 | flushAndRunMultipleServers, |
9 | removeVideo, | 10 | removeVideo, |
10 | uploadVideo, | 11 | uploadVideo, |
11 | wait | 12 | wait |
12 | } from '../../../../shared/extra-utils' | 13 | } from '../../../../shared/extra-utils' |
13 | import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index' | 14 | import { ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index' |
14 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 15 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
15 | import { | 16 | import { |
16 | createVideoCaption, | 17 | createVideoCaption, |
@@ -36,7 +37,7 @@ describe('Test video captions', function () { | |||
36 | 37 | ||
37 | await waitJobs(servers) | 38 | await waitJobs(servers) |
38 | 39 | ||
39 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'my video name' }) | 40 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'my video name' }) |
40 | videoUUID = res.body.video.uuid | 41 | videoUUID = res.body.video.uuid |
41 | 42 | ||
42 | await waitJobs(servers) | 43 | await waitJobs(servers) |
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts index 64ee2355a..dee6575b9 100644 --- a/server/tests/api/videos/video-change-ownership.ts +++ b/server/tests/api/videos/video-change-ownership.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
@@ -38,7 +38,7 @@ describe('Test video change ownership - nominal', function () { | |||
38 | } | 38 | } |
39 | let firstUserAccessToken = '' | 39 | let firstUserAccessToken = '' |
40 | let secondUserAccessToken = '' | 40 | let secondUserAccessToken = '' |
41 | let lastRequestChangeOwnershipId = undefined | 41 | let lastRequestChangeOwnershipId = '' |
42 | 42 | ||
43 | before(async function () { | 43 | before(async function () { |
44 | this.timeout(50000) | 44 | this.timeout(50000) |
@@ -48,15 +48,15 @@ describe('Test video change ownership - nominal', function () { | |||
48 | 48 | ||
49 | const videoQuota = 42000000 | 49 | const videoQuota = 42000000 |
50 | await createUser({ | 50 | await createUser({ |
51 | url: servers[ 0 ].url, | 51 | url: servers[0].url, |
52 | accessToken: servers[ 0 ].accessToken, | 52 | accessToken: servers[0].accessToken, |
53 | username: firstUser.username, | 53 | username: firstUser.username, |
54 | password: firstUser.password, | 54 | password: firstUser.password, |
55 | videoQuota: videoQuota | 55 | videoQuota: videoQuota |
56 | }) | 56 | }) |
57 | await createUser({ | 57 | await createUser({ |
58 | url: servers[ 0 ].url, | 58 | url: servers[0].url, |
59 | accessToken: servers[ 0 ].accessToken, | 59 | accessToken: servers[0].accessToken, |
60 | username: secondUser.username, | 60 | username: secondUser.username, |
61 | password: secondUser.password, | 61 | password: secondUser.password, |
62 | videoQuota: videoQuota | 62 | videoQuota: videoQuota |
@@ -209,7 +209,7 @@ describe('Test video change ownership - nominal', function () { | |||
209 | }) | 209 | }) |
210 | 210 | ||
211 | describe('Test video change ownership - quota too small', function () { | 211 | describe('Test video change ownership - quota too small', function () { |
212 | let server: ServerInfo = undefined | 212 | let server: ServerInfo |
213 | const firstUser = { | 213 | const firstUser = { |
214 | username: 'first', | 214 | username: 'first', |
215 | password: 'My great password' | 215 | password: 'My great password' |
@@ -220,14 +220,14 @@ describe('Test video change ownership - quota too small', function () { | |||
220 | } | 220 | } |
221 | let firstUserAccessToken = '' | 221 | let firstUserAccessToken = '' |
222 | let secondUserAccessToken = '' | 222 | let secondUserAccessToken = '' |
223 | let lastRequestChangeOwnershipId = undefined | 223 | let lastRequestChangeOwnershipId = '' |
224 | 224 | ||
225 | before(async function () { | 225 | before(async function () { |
226 | this.timeout(50000) | 226 | this.timeout(50000) |
227 | 227 | ||
228 | // Run one server | 228 | // Run one server |
229 | server = await flushAndRunServer(1) | 229 | server = await flushAndRunServer(1) |
230 | await setAccessTokensToServers([server]) | 230 | await setAccessTokensToServers([ server ]) |
231 | 231 | ||
232 | const videoQuota = 42000000 | 232 | const videoQuota = 42000000 |
233 | const limitedVideoQuota = 10 | 233 | const limitedVideoQuota = 10 |
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 4f600cae8..876a6ab66 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts | |||
@@ -1,19 +1,21 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { User, Video, VideoChannel, VideoDetails } from '../../../../shared/index' | 5 | import { User, Video, VideoChannel, ViewsPerDate, VideoDetails } from '../../../../shared/index' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | createUser, | 8 | createUser, |
9 | doubleFollow, | 9 | doubleFollow, |
10 | flushAndRunMultipleServers, getVideo, | 10 | flushAndRunMultipleServers, |
11 | getVideo, | ||
11 | getVideoChannelVideos, | 12 | getVideoChannelVideos, |
12 | testImage, | 13 | testImage, |
13 | updateVideo, | 14 | updateVideo, |
14 | updateVideoChannelAvatar, | 15 | updateVideoChannelAvatar, |
15 | uploadVideo, | 16 | uploadVideo, |
16 | userLogin | 17 | userLogin, |
18 | wait | ||
17 | } from '../../../../shared/extra-utils' | 19 | } from '../../../../shared/extra-utils' |
18 | import { | 20 | import { |
19 | addVideoChannel, | 21 | addVideoChannel, |
@@ -24,7 +26,8 @@ import { | |||
24 | getVideoChannelsList, | 26 | getVideoChannelsList, |
25 | ServerInfo, | 27 | ServerInfo, |
26 | setAccessTokensToServers, | 28 | setAccessTokensToServers, |
27 | updateVideoChannel | 29 | updateVideoChannel, |
30 | viewVideo | ||
28 | } from '../../../../shared/extra-utils/index' | 31 | } from '../../../../shared/extra-utils/index' |
29 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 32 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
30 | 33 | ||
@@ -73,14 +76,14 @@ describe('Test video channels', function () { | |||
73 | description: 'super video channel description', | 76 | description: 'super video channel description', |
74 | support: 'super video channel support text' | 77 | support: 'super video channel support text' |
75 | } | 78 | } |
76 | const res = await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel) | 79 | const res = await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel) |
77 | secondVideoChannelId = res.body.videoChannel.id | 80 | secondVideoChannelId = res.body.videoChannel.id |
78 | } | 81 | } |
79 | 82 | ||
80 | // The channel is 1 is propagated to servers 2 | 83 | // The channel is 1 is propagated to servers 2 |
81 | { | 84 | { |
82 | const videoAttributesArg = { name: 'my video name', channelId: secondVideoChannelId, support: 'video support field' } | 85 | const videoAttributesArg = { name: 'my video name', channelId: secondVideoChannelId, support: 'video support field' } |
83 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAttributesArg) | 86 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributesArg) |
84 | videoUUID = res.body.video.uuid | 87 | videoUUID = res.body.video.uuid |
85 | } | 88 | } |
86 | 89 | ||
@@ -106,7 +109,7 @@ describe('Test video channels', function () { | |||
106 | 109 | ||
107 | it('Should have two video channels when getting account channels on server 1', async function () { | 110 | it('Should have two video channels when getting account channels on server 1', async function () { |
108 | const res = await getAccountVideoChannelsList({ | 111 | const res = await getAccountVideoChannelsList({ |
109 | url: servers[ 0 ].url, | 112 | url: servers[0].url, |
110 | accountName: userInfo.account.name + '@' + userInfo.account.host | 113 | accountName: userInfo.account.name + '@' + userInfo.account.host |
111 | }) | 114 | }) |
112 | 115 | ||
@@ -127,7 +130,7 @@ describe('Test video channels', function () { | |||
127 | it('Should paginate and sort account channels', async function () { | 130 | it('Should paginate and sort account channels', async function () { |
128 | { | 131 | { |
129 | const res = await getAccountVideoChannelsList({ | 132 | const res = await getAccountVideoChannelsList({ |
130 | url: servers[ 0 ].url, | 133 | url: servers[0].url, |
131 | accountName: userInfo.account.name + '@' + userInfo.account.host, | 134 | accountName: userInfo.account.name + '@' + userInfo.account.host, |
132 | start: 0, | 135 | start: 0, |
133 | count: 1, | 136 | count: 1, |
@@ -137,13 +140,13 @@ describe('Test video channels', function () { | |||
137 | expect(res.body.total).to.equal(2) | 140 | expect(res.body.total).to.equal(2) |
138 | expect(res.body.data).to.have.lengthOf(1) | 141 | expect(res.body.data).to.have.lengthOf(1) |
139 | 142 | ||
140 | const videoChannel: VideoChannel = res.body.data[ 0 ] | 143 | const videoChannel: VideoChannel = res.body.data[0] |
141 | expect(videoChannel.name).to.equal('root_channel') | 144 | expect(videoChannel.name).to.equal('root_channel') |
142 | } | 145 | } |
143 | 146 | ||
144 | { | 147 | { |
145 | const res = await getAccountVideoChannelsList({ | 148 | const res = await getAccountVideoChannelsList({ |
146 | url: servers[ 0 ].url, | 149 | url: servers[0].url, |
147 | accountName: userInfo.account.name + '@' + userInfo.account.host, | 150 | accountName: userInfo.account.name + '@' + userInfo.account.host, |
148 | start: 0, | 151 | start: 0, |
149 | count: 1, | 152 | count: 1, |
@@ -153,13 +156,13 @@ describe('Test video channels', function () { | |||
153 | expect(res.body.total).to.equal(2) | 156 | expect(res.body.total).to.equal(2) |
154 | expect(res.body.data).to.have.lengthOf(1) | 157 | expect(res.body.data).to.have.lengthOf(1) |
155 | 158 | ||
156 | const videoChannel: VideoChannel = res.body.data[ 0 ] | 159 | const videoChannel: VideoChannel = res.body.data[0] |
157 | expect(videoChannel.name).to.equal('second_video_channel') | 160 | expect(videoChannel.name).to.equal('second_video_channel') |
158 | } | 161 | } |
159 | 162 | ||
160 | { | 163 | { |
161 | const res = await getAccountVideoChannelsList({ | 164 | const res = await getAccountVideoChannelsList({ |
162 | url: servers[ 0 ].url, | 165 | url: servers[0].url, |
163 | accountName: userInfo.account.name + '@' + userInfo.account.host, | 166 | accountName: userInfo.account.name + '@' + userInfo.account.host, |
164 | start: 1, | 167 | start: 1, |
165 | count: 1, | 168 | count: 1, |
@@ -169,14 +172,14 @@ describe('Test video channels', function () { | |||
169 | expect(res.body.total).to.equal(2) | 172 | expect(res.body.total).to.equal(2) |
170 | expect(res.body.data).to.have.lengthOf(1) | 173 | expect(res.body.data).to.have.lengthOf(1) |
171 | 174 | ||
172 | const videoChannel: VideoChannel = res.body.data[ 0 ] | 175 | const videoChannel: VideoChannel = res.body.data[0] |
173 | expect(videoChannel.name).to.equal('root_channel') | 176 | expect(videoChannel.name).to.equal('root_channel') |
174 | } | 177 | } |
175 | }) | 178 | }) |
176 | 179 | ||
177 | it('Should have one video channel when getting account channels on server 2', async function () { | 180 | it('Should have one video channel when getting account channels on server 2', async function () { |
178 | const res = await getAccountVideoChannelsList({ | 181 | const res = await getAccountVideoChannelsList({ |
179 | url: servers[ 1 ].url, | 182 | url: servers[1].url, |
180 | accountName: userInfo.account.name + '@' + userInfo.account.host | 183 | accountName: userInfo.account.name + '@' + userInfo.account.host |
181 | }) | 184 | }) |
182 | 185 | ||
@@ -349,19 +352,55 @@ describe('Test video channels', function () { | |||
349 | it('Should create the main channel with an uuid if there is a conflict', async function () { | 352 | it('Should create the main channel with an uuid if there is a conflict', async function () { |
350 | { | 353 | { |
351 | const videoChannel = { name: 'toto_channel', displayName: 'My toto channel' } | 354 | const videoChannel = { name: 'toto_channel', displayName: 'My toto channel' } |
352 | await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel) | 355 | await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel) |
353 | } | 356 | } |
354 | 357 | ||
355 | { | 358 | { |
356 | await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: 'toto', password: 'password' }) | 359 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: 'toto', password: 'password' }) |
357 | const accessToken = await userLogin(servers[ 0 ], { username: 'toto', password: 'password' }) | 360 | const accessToken = await userLogin(servers[0], { username: 'toto', password: 'password' }) |
358 | 361 | ||
359 | const res = await getMyUserInformation(servers[ 0 ].url, accessToken) | 362 | const res = await getMyUserInformation(servers[0].url, accessToken) |
360 | const videoChannel = res.body.videoChannels[ 0 ] | 363 | const videoChannel = res.body.videoChannels[0] |
361 | expect(videoChannel.name).to.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/) | 364 | expect(videoChannel.name).to.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/) |
362 | } | 365 | } |
363 | }) | 366 | }) |
364 | 367 | ||
368 | it('Should report correct channel statistics', async function () { | ||
369 | |||
370 | { | ||
371 | const res = await getAccountVideoChannelsList({ | ||
372 | url: servers[0].url, | ||
373 | accountName: userInfo.account.name + '@' + userInfo.account.host, | ||
374 | withStats: true | ||
375 | }) | ||
376 | res.body.data.forEach((channel: VideoChannel) => { | ||
377 | expect(channel).to.haveOwnProperty('viewsPerDay') | ||
378 | expect(channel.viewsPerDay).to.have.length(30 + 1) // daysPrior + today | ||
379 | channel.viewsPerDay.forEach((v: ViewsPerDate) => { | ||
380 | expect(v.date).to.be.an('string') | ||
381 | expect(v.views).to.equal(0) | ||
382 | }) | ||
383 | }) | ||
384 | } | ||
385 | |||
386 | { | ||
387 | // video has been posted on channel firstVideoChannelId since last update | ||
388 | await viewVideo(servers[0].url, videoUUID, 204, '0.0.0.1,127.0.0.1') | ||
389 | await viewVideo(servers[0].url, videoUUID, 204, '0.0.0.2,127.0.0.1') | ||
390 | |||
391 | // Wait the repeatable job | ||
392 | await wait(8000) | ||
393 | |||
394 | const res = await getAccountVideoChannelsList({ | ||
395 | url: servers[0].url, | ||
396 | accountName: userInfo.account.name + '@' + userInfo.account.host, | ||
397 | withStats: true | ||
398 | }) | ||
399 | const channelWithView = res.body.data.find((channel: VideoChannel) => channel.id === firstVideoChannelId) | ||
400 | expect(channelWithView.viewsPerDay.slice(-1)[0].views).to.equal(2) | ||
401 | } | ||
402 | }) | ||
403 | |||
365 | after(async function () { | 404 | after(async function () { |
366 | await cleanupTests(servers) | 405 | await cleanupTests(servers) |
367 | }) | 406 | }) |
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts index 06e4ff9c8..afb58e95a 100644 --- a/server/tests/api/videos/video-comments.ts +++ b/server/tests/api/videos/video-comments.ts | |||
@@ -1,17 +1,17 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' | 5 | import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' |
6 | import { cleanupTests, testImage } from '../../../../shared/extra-utils' | 6 | import { cleanupTests, testImage } from '../../../../shared/extra-utils' |
7 | import { | 7 | import { |
8 | createUser, | ||
8 | dateIsValid, | 9 | dateIsValid, |
9 | flushAndRunServer, | 10 | flushAndRunServer, |
11 | getAccessToken, | ||
10 | ServerInfo, | 12 | ServerInfo, |
11 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
12 | updateMyAvatar, | 14 | updateMyAvatar, |
13 | getAccessToken, | ||
14 | createUser, | ||
15 | uploadVideo | 15 | uploadVideo |
16 | } from '../../../../shared/extra-utils/index' | 16 | } from '../../../../shared/extra-utils/index' |
17 | import { | 17 | import { |
diff --git a/server/tests/api/videos/video-description.ts b/server/tests/api/videos/video-description.ts index db4d278bf..b8e98e45f 100644 --- a/server/tests/api/videos/video-description.ts +++ b/server/tests/api/videos/video-description.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
@@ -8,7 +8,6 @@ import { | |||
8 | getVideo, | 8 | getVideo, |
9 | getVideoDescription, | 9 | getVideoDescription, |
10 | getVideosList, | 10 | getVideosList, |
11 | killallServers, | ||
12 | ServerInfo, | 11 | ServerInfo, |
13 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
14 | updateVideo, | 13 | updateVideo, |
@@ -23,7 +22,7 @@ describe('Test video description', function () { | |||
23 | let servers: ServerInfo[] = [] | 22 | let servers: ServerInfo[] = [] |
24 | let videoUUID = '' | 23 | let videoUUID = '' |
25 | let videoId: number | 24 | let videoId: number |
26 | let longDescription = 'my super description for server 1'.repeat(50) | 25 | const longDescription = 'my super description for server 1'.repeat(50) |
27 | 26 | ||
28 | before(async function () { | 27 | before(async function () { |
29 | this.timeout(40000) | 28 | this.timeout(40000) |
@@ -61,7 +60,7 @@ describe('Test video description', function () { | |||
61 | 60 | ||
62 | // 30 characters * 6 -> 240 characters | 61 | // 30 characters * 6 -> 240 characters |
63 | const truncatedDescription = 'my super description for server 1'.repeat(7) + | 62 | const truncatedDescription = 'my super description for server 1'.repeat(7) + |
64 | 'my super descrip...' | 63 | 'my super descrip...' |
65 | 64 | ||
66 | expect(video.description).to.equal(truncatedDescription) | 65 | expect(video.description).to.equal(truncatedDescription) |
67 | } | 66 | } |
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index bde3b5656..6555bc8b6 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
@@ -10,13 +10,16 @@ import { | |||
10 | doubleFollow, | 10 | doubleFollow, |
11 | flushAndRunMultipleServers, | 11 | flushAndRunMultipleServers, |
12 | getPlaylist, | 12 | getPlaylist, |
13 | getVideo, makeGetRequest, makeRawRequest, | 13 | getVideo, |
14 | makeRawRequest, | ||
14 | removeVideo, | 15 | removeVideo, |
15 | ServerInfo, | 16 | ServerInfo, |
16 | setAccessTokensToServers, updateCustomSubConfig, | 17 | setAccessTokensToServers, |
18 | updateCustomSubConfig, | ||
17 | updateVideo, | 19 | updateVideo, |
18 | uploadVideo, | 20 | uploadVideo, |
19 | waitJobs, webtorrentAdd | 21 | waitJobs, |
22 | webtorrentAdd | ||
20 | } from '../../../../shared/extra-utils' | 23 | } from '../../../../shared/extra-utils' |
21 | import { VideoDetails } from '../../../../shared/models/videos' | 24 | import { VideoDetails } from '../../../../shared/models/videos' |
22 | import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' | 25 | import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' |
@@ -48,7 +51,9 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn | |||
48 | 51 | ||
49 | expect(file.magnetUri).to.have.lengthOf.above(2) | 52 | expect(file.magnetUri).to.have.lengthOf.above(2) |
50 | expect(file.torrentUrl).to.equal(`${baseUrl}/static/torrents/${videoDetails.uuid}-${file.resolution.id}-hls.torrent`) | 53 | expect(file.torrentUrl).to.equal(`${baseUrl}/static/torrents/${videoDetails.uuid}-${file.resolution.id}-hls.torrent`) |
51 | expect(file.fileUrl).to.equal(`${baseUrl}/static/streaming-playlists/hls/${videoDetails.uuid}/${videoDetails.uuid}-${file.resolution.id}-fragmented.mp4`) | 54 | expect(file.fileUrl).to.equal( |
55 | `${baseUrl}/static/streaming-playlists/hls/${videoDetails.uuid}/${videoDetails.uuid}-${file.resolution.id}-fragmented.mp4` | ||
56 | ) | ||
52 | expect(file.resolution.label).to.equal(resolution + 'p') | 57 | expect(file.resolution.label).to.equal(resolution + 'p') |
53 | 58 | ||
54 | await makeRawRequest(file.torrentUrl, 200) | 59 | await makeRawRequest(file.torrentUrl, 200) |
@@ -66,7 +71,9 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn | |||
66 | const masterPlaylist = res.text | 71 | const masterPlaylist = res.text |
67 | 72 | ||
68 | for (const resolution of resolutions) { | 73 | for (const resolution of resolutions) { |
69 | const reg = new RegExp('#EXT-X-STREAM-INF:BANDWIDTH=\\d+,RESOLUTION=\\d+x' + resolution + ',FRAME-RATE=\\d+,CODECS="avc1.64001f,mp4a.40.2"') | 74 | const reg = new RegExp( |
75 | '#EXT-X-STREAM-INF:BANDWIDTH=\\d+,RESOLUTION=\\d+x' + resolution + ',FRAME-RATE=\\d+,CODECS="avc1.64001f,mp4a.40.2"' | ||
76 | ) | ||
70 | 77 | ||
71 | expect(masterPlaylist).to.match(reg) | 78 | expect(masterPlaylist).to.match(reg) |
72 | expect(masterPlaylist).to.contain(`${resolution}.m3u8`) | 79 | expect(masterPlaylist).to.contain(`${resolution}.m3u8`) |
@@ -102,7 +109,7 @@ describe('Test HLS videos', function () { | |||
102 | it('Should upload a video and transcode it to HLS', async function () { | 109 | it('Should upload a video and transcode it to HLS', async function () { |
103 | this.timeout(120000) | 110 | this.timeout(120000) |
104 | 111 | ||
105 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video 1', fixture: 'video_short.webm' }) | 112 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video 1', fixture: 'video_short.webm' }) |
106 | videoUUID = res.body.video.uuid | 113 | videoUUID = res.body.video.uuid |
107 | 114 | ||
108 | await waitJobs(servers) | 115 | await waitJobs(servers) |
@@ -113,7 +120,7 @@ describe('Test HLS videos', function () { | |||
113 | it('Should upload an audio file and transcode it to HLS', async function () { | 120 | it('Should upload an audio file and transcode it to HLS', async function () { |
114 | this.timeout(120000) | 121 | this.timeout(120000) |
115 | 122 | ||
116 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video audio', fixture: 'sample.ogg' }) | 123 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video audio', fixture: 'sample.ogg' }) |
117 | videoAudioUUID = res.body.video.uuid | 124 | videoAudioUUID = res.body.video.uuid |
118 | 125 | ||
119 | await waitJobs(servers) | 126 | await waitJobs(servers) |
@@ -124,7 +131,7 @@ describe('Test HLS videos', function () { | |||
124 | it('Should update the video', async function () { | 131 | it('Should update the video', async function () { |
125 | this.timeout(10000) | 132 | this.timeout(10000) |
126 | 133 | ||
127 | await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, { name: 'video 1 updated' }) | 134 | await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { name: 'video 1 updated' }) |
128 | 135 | ||
129 | await waitJobs(servers) | 136 | await waitJobs(servers) |
130 | 137 | ||
@@ -134,8 +141,8 @@ describe('Test HLS videos', function () { | |||
134 | it('Should delete videos', async function () { | 141 | it('Should delete videos', async function () { |
135 | this.timeout(10000) | 142 | this.timeout(10000) |
136 | 143 | ||
137 | await removeVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID) | 144 | await removeVideo(servers[0].url, servers[0].accessToken, videoUUID) |
138 | await removeVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAudioUUID) | 145 | await removeVideo(servers[0].url, servers[0].accessToken, videoAudioUUID) |
139 | 146 | ||
140 | await waitJobs(servers) | 147 | await waitJobs(servers) |
141 | 148 | ||
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index 1233ed6eb..4d5989f43 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { VideoDetails, VideoImport, VideoPrivacy } from '../../../../shared/models/videos' | 5 | import { VideoDetails, VideoImport, VideoPrivacy, VideoCaption } from '../../../../shared/models/videos' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | doubleFollow, | 8 | doubleFollow, |
@@ -11,13 +11,15 @@ import { | |||
11 | getMyVideos, | 11 | getMyVideos, |
12 | getVideo, | 12 | getVideo, |
13 | getVideosList, | 13 | getVideosList, |
14 | listVideoCaptions, | ||
15 | testCaptionFile, | ||
14 | immutableAssign, | 16 | immutableAssign, |
15 | killallServers, | ||
16 | ServerInfo, | 17 | ServerInfo, |
17 | setAccessTokensToServers | 18 | setAccessTokensToServers |
18 | } from '../../../../shared/extra-utils' | 19 | } from '../../../../shared/extra-utils' |
19 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 20 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
20 | import { getMagnetURI, getYoutubeVideoUrl, importVideo, getMyVideoImports } from '../../../../shared/extra-utils/videos/video-imports' | 21 | import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' |
22 | import { testImage } from '../../../../shared/extra-utils/miscs/miscs' | ||
21 | 23 | ||
22 | const expect = chai.expect | 24 | const expect = chai.expect |
23 | 25 | ||
@@ -61,11 +63,14 @@ describe('Test video imports', function () { | |||
61 | 63 | ||
62 | expect(videoTorrent.name).to.contain('ä½ å¥½ 世界 720p.mp4') | 64 | expect(videoTorrent.name).to.contain('ä½ å¥½ 世界 720p.mp4') |
63 | expect(videoMagnet.name).to.contain('super peertube2 video') | 65 | expect(videoMagnet.name).to.contain('super peertube2 video') |
66 | |||
67 | const resCaptions = await listVideoCaptions(url, idHttp) | ||
68 | expect(resCaptions.body.total).to.equal(2) | ||
64 | } | 69 | } |
65 | 70 | ||
66 | async function checkVideoServer2 (url: string, id: number | string) { | 71 | async function checkVideoServer2 (url: string, id: number | string) { |
67 | const res = await getVideo(url, id) | 72 | const res = await getVideo(url, id) |
68 | const video = res.body | 73 | const video: VideoDetails = res.body |
69 | 74 | ||
70 | expect(video.name).to.equal('my super name') | 75 | expect(video.name).to.equal('my super name') |
71 | expect(video.category.label).to.equal('Entertainment') | 76 | expect(video.category.label).to.equal('Entertainment') |
@@ -76,6 +81,9 @@ describe('Test video imports', function () { | |||
76 | expect(video.tags).to.deep.equal([ 'supertag1', 'supertag2' ]) | 81 | expect(video.tags).to.deep.equal([ 'supertag1', 'supertag2' ]) |
77 | 82 | ||
78 | expect(video.files).to.have.lengthOf(1) | 83 | expect(video.files).to.have.lengthOf(1) |
84 | |||
85 | const resCaptions = await listVideoCaptions(url, id) | ||
86 | expect(resCaptions.body.total).to.equal(2) | ||
79 | } | 87 | } |
80 | 88 | ||
81 | before(async function () { | 89 | before(async function () { |
@@ -88,12 +96,12 @@ describe('Test video imports', function () { | |||
88 | 96 | ||
89 | { | 97 | { |
90 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) | 98 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) |
91 | channelIdServer1 = res.body.videoChannels[ 0 ].id | 99 | channelIdServer1 = res.body.videoChannels[0].id |
92 | } | 100 | } |
93 | 101 | ||
94 | { | 102 | { |
95 | const res = await getMyUserInformation(servers[1].url, servers[1].accessToken) | 103 | const res = await getMyUserInformation(servers[1].url, servers[1].accessToken) |
96 | channelIdServer2 = res.body.videoChannels[ 0 ].id | 104 | channelIdServer2 = res.body.videoChannels[0].id |
97 | } | 105 | } |
98 | 106 | ||
99 | await doubleFollow(servers[0], servers[1]) | 107 | await doubleFollow(servers[0], servers[1]) |
@@ -111,6 +119,48 @@ describe('Test video imports', function () { | |||
111 | const attributes = immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() }) | 119 | const attributes = immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() }) |
112 | const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) | 120 | const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) |
113 | expect(res.body.video.name).to.equal('small video - youtube') | 121 | expect(res.body.video.name).to.equal('small video - youtube') |
122 | expect(res.body.video.thumbnailPath).to.equal(`/static/thumbnails/${res.body.video.uuid}.jpg`) | ||
123 | expect(res.body.video.previewPath).to.equal(`/static/previews/${res.body.video.uuid}.jpg`) | ||
124 | await testImage(servers[0].url, 'video_import_thumbnail', res.body.video.thumbnailPath) | ||
125 | await testImage(servers[0].url, 'video_import_preview', res.body.video.previewPath) | ||
126 | |||
127 | const resCaptions = await listVideoCaptions(servers[0].url, res.body.video.id) | ||
128 | const videoCaptions: VideoCaption[] = resCaptions.body.data | ||
129 | expect(videoCaptions).to.have.lengthOf(2) | ||
130 | |||
131 | const enCaption = videoCaptions.find(caption => caption.language.id === 'en') | ||
132 | expect(enCaption).to.exist | ||
133 | expect(enCaption.language.label).to.equal('English') | ||
134 | expect(enCaption.captionPath).to.equal(`/static/video-captions/${res.body.video.uuid}-en.vtt`) | ||
135 | await testCaptionFile(servers[0].url, enCaption.captionPath, `WEBVTT | ||
136 | Kind: captions | ||
137 | Language: en | ||
138 | |||
139 | 00:00:01.600 --> 00:00:04.200 | ||
140 | English (US) | ||
141 | |||
142 | 00:00:05.900 --> 00:00:07.999 | ||
143 | This is a subtitle in American English | ||
144 | |||
145 | 00:00:10.000 --> 00:00:14.000 | ||
146 | Adding subtitles is very easy to do`) | ||
147 | |||
148 | const frCaption = videoCaptions.find(caption => caption.language.id === 'fr') | ||
149 | expect(frCaption).to.exist | ||
150 | expect(frCaption.language.label).to.equal('French') | ||
151 | expect(frCaption.captionPath).to.equal(`/static/video-captions/${res.body.video.uuid}-fr.vtt`) | ||
152 | await testCaptionFile(servers[0].url, frCaption.captionPath, `WEBVTT | ||
153 | Kind: captions | ||
154 | Language: fr | ||
155 | |||
156 | 00:00:01.600 --> 00:00:04.200 | ||
157 | Français (FR) | ||
158 | |||
159 | 00:00:05.900 --> 00:00:07.999 | ||
160 | C'est un sous-titre français | ||
161 | |||
162 | 00:00:10.000 --> 00:00:14.000 | ||
163 | Ajouter un sous-titre est vraiment facile`) | ||
114 | } | 164 | } |
115 | 165 | ||
116 | { | 166 | { |
@@ -214,7 +264,7 @@ describe('Test video imports', function () { | |||
214 | 264 | ||
215 | await checkVideoServer2(server.url, res.body.data[0].uuid) | 265 | await checkVideoServer2(server.url, res.body.data[0].uuid) |
216 | 266 | ||
217 | const [ ,videoHttp, videoMagnet, videoTorrent ] = res.body.data | 267 | const [ , videoHttp, videoMagnet, videoTorrent ] = res.body.data |
218 | await checkVideosServer1(server.url, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid) | 268 | await checkVideosServer1(server.url, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid) |
219 | } | 269 | } |
220 | }) | 270 | }) |
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts index ad6a4b43f..b16b484b9 100644 --- a/server/tests/api/videos/video-nsfw.ts +++ b/server/tests/api/videos/video-nsfw.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
@@ -19,12 +19,20 @@ import { | |||
19 | updateCustomConfig, | 19 | updateCustomConfig, |
20 | updateMyUser | 20 | updateMyUser |
21 | } from '../../../../shared/extra-utils' | 21 | } from '../../../../shared/extra-utils' |
22 | import { ServerConfig } from '../../../../shared/models' | 22 | import { ServerConfig, VideosOverview } from '../../../../shared/models' |
23 | import { CustomConfig } from '../../../../shared/models/server/custom-config.model' | 23 | import { CustomConfig } from '../../../../shared/models/server/custom-config.model' |
24 | import { User } from '../../../../shared/models/users' | 24 | import { User } from '../../../../shared/models/users' |
25 | import { getVideosOverview, getVideosOverviewWithToken } from '@shared/extra-utils/overviews/overviews' | ||
25 | 26 | ||
26 | const expect = chai.expect | 27 | const expect = chai.expect |
27 | 28 | ||
29 | function createOverviewRes (res: any) { | ||
30 | const overview = res.body as VideosOverview | ||
31 | |||
32 | const videos = overview.categories[0].videos | ||
33 | return { body: { data: videos, total: videos.length } } | ||
34 | } | ||
35 | |||
28 | describe('Test video NSFW policy', function () { | 36 | describe('Test video NSFW policy', function () { |
29 | let server: ServerInfo | 37 | let server: ServerInfo |
30 | let userAccessToken: string | 38 | let userAccessToken: string |
@@ -36,22 +44,38 @@ describe('Test video NSFW policy', function () { | |||
36 | const user: User = res.body | 44 | const user: User = res.body |
37 | const videoChannelName = user.videoChannels[0].name | 45 | const videoChannelName = user.videoChannels[0].name |
38 | const accountName = user.account.name + '@' + user.account.host | 46 | const accountName = user.account.name + '@' + user.account.host |
47 | const hasQuery = Object.keys(query).length !== 0 | ||
48 | let promises: Promise<any>[] | ||
39 | 49 | ||
40 | if (token) { | 50 | if (token) { |
41 | return Promise.all([ | 51 | promises = [ |
42 | getVideosListWithToken(server.url, token, query), | 52 | getVideosListWithToken(server.url, token, query), |
43 | searchVideoWithToken(server.url, 'n', token, query), | 53 | searchVideoWithToken(server.url, 'n', token, query), |
44 | getAccountVideos(server.url, token, accountName, 0, 5, undefined, query), | 54 | getAccountVideos(server.url, token, accountName, 0, 5, undefined, query), |
45 | getVideoChannelVideos(server.url, token, videoChannelName, 0, 5, undefined, query) | 55 | getVideoChannelVideos(server.url, token, videoChannelName, 0, 5, undefined, query) |
46 | ]) | 56 | ] |
57 | |||
58 | // Overviews do not support video filters | ||
59 | if (!hasQuery) { | ||
60 | promises.push(getVideosOverviewWithToken(server.url, 1, token).then(res => createOverviewRes(res))) | ||
61 | } | ||
62 | |||
63 | return Promise.all(promises) | ||
47 | } | 64 | } |
48 | 65 | ||
49 | return Promise.all([ | 66 | promises = [ |
50 | getVideosList(server.url), | 67 | getVideosList(server.url), |
51 | searchVideo(server.url, 'n'), | 68 | searchVideo(server.url, 'n'), |
52 | getAccountVideos(server.url, undefined, accountName, 0, 5), | 69 | getAccountVideos(server.url, undefined, accountName, 0, 5), |
53 | getVideoChannelVideos(server.url, undefined, videoChannelName, 0, 5) | 70 | getVideoChannelVideos(server.url, undefined, videoChannelName, 0, 5) |
54 | ]) | 71 | ] |
72 | |||
73 | // Overviews do not support video filters | ||
74 | if (!hasQuery) { | ||
75 | promises.push(getVideosOverview(server.url, 1).then(res => createOverviewRes(res))) | ||
76 | } | ||
77 | |||
78 | return Promise.all(promises) | ||
55 | }) | 79 | }) |
56 | } | 80 | } |
57 | 81 | ||
@@ -63,12 +87,12 @@ describe('Test video NSFW policy', function () { | |||
63 | await setAccessTokensToServers([ server ]) | 87 | await setAccessTokensToServers([ server ]) |
64 | 88 | ||
65 | { | 89 | { |
66 | const attributes = { name: 'nsfw', nsfw: true } | 90 | const attributes = { name: 'nsfw', nsfw: true, category: 1 } |
67 | await uploadVideo(server.url, server.accessToken, attributes) | 91 | await uploadVideo(server.url, server.accessToken, attributes) |
68 | } | 92 | } |
69 | 93 | ||
70 | { | 94 | { |
71 | const attributes = { name: 'normal', nsfw: false } | 95 | const attributes = { name: 'normal', nsfw: false, category: 1 } |
72 | await uploadVideo(server.url, server.accessToken, attributes) | 96 | await uploadVideo(server.url, server.accessToken, attributes) |
73 | } | 97 | } |
74 | 98 | ||
@@ -89,8 +113,8 @@ describe('Test video NSFW policy', function () { | |||
89 | 113 | ||
90 | const videos = res.body.data | 114 | const videos = res.body.data |
91 | expect(videos).to.have.lengthOf(2) | 115 | expect(videos).to.have.lengthOf(2) |
92 | expect(videos[ 0 ].name).to.equal('normal') | 116 | expect(videos[0].name).to.equal('normal') |
93 | expect(videos[ 1 ].name).to.equal('nsfw') | 117 | expect(videos[1].name).to.equal('nsfw') |
94 | } | 118 | } |
95 | }) | 119 | }) |
96 | 120 | ||
@@ -107,7 +131,7 @@ describe('Test video NSFW policy', function () { | |||
107 | 131 | ||
108 | const videos = res.body.data | 132 | const videos = res.body.data |
109 | expect(videos).to.have.lengthOf(1) | 133 | expect(videos).to.have.lengthOf(1) |
110 | expect(videos[ 0 ].name).to.equal('normal') | 134 | expect(videos[0].name).to.equal('normal') |
111 | } | 135 | } |
112 | }) | 136 | }) |
113 | 137 | ||
@@ -124,8 +148,8 @@ describe('Test video NSFW policy', function () { | |||
124 | 148 | ||
125 | const videos = res.body.data | 149 | const videos = res.body.data |
126 | expect(videos).to.have.lengthOf(2) | 150 | expect(videos).to.have.lengthOf(2) |
127 | expect(videos[ 0 ].name).to.equal('normal') | 151 | expect(videos[0].name).to.equal('normal') |
128 | expect(videos[ 1 ].name).to.equal('nsfw') | 152 | expect(videos[1].name).to.equal('nsfw') |
129 | } | 153 | } |
130 | }) | 154 | }) |
131 | }) | 155 | }) |
@@ -154,8 +178,8 @@ describe('Test video NSFW policy', function () { | |||
154 | 178 | ||
155 | const videos = res.body.data | 179 | const videos = res.body.data |
156 | expect(videos).to.have.lengthOf(2) | 180 | expect(videos).to.have.lengthOf(2) |
157 | expect(videos[ 0 ].name).to.equal('normal') | 181 | expect(videos[0].name).to.equal('normal') |
158 | expect(videos[ 1 ].name).to.equal('nsfw') | 182 | expect(videos[1].name).to.equal('nsfw') |
159 | } | 183 | } |
160 | }) | 184 | }) |
161 | 185 | ||
@@ -171,8 +195,8 @@ describe('Test video NSFW policy', function () { | |||
171 | 195 | ||
172 | const videos = res.body.data | 196 | const videos = res.body.data |
173 | expect(videos).to.have.lengthOf(2) | 197 | expect(videos).to.have.lengthOf(2) |
174 | expect(videos[ 0 ].name).to.equal('normal') | 198 | expect(videos[0].name).to.equal('normal') |
175 | expect(videos[ 1 ].name).to.equal('nsfw') | 199 | expect(videos[1].name).to.equal('nsfw') |
176 | } | 200 | } |
177 | }) | 201 | }) |
178 | 202 | ||
@@ -188,7 +212,7 @@ describe('Test video NSFW policy', function () { | |||
188 | 212 | ||
189 | const videos = res.body.data | 213 | const videos = res.body.data |
190 | expect(videos).to.have.lengthOf(1) | 214 | expect(videos).to.have.lengthOf(1) |
191 | expect(videos[ 0 ].name).to.equal('normal') | 215 | expect(videos[0].name).to.equal('normal') |
192 | } | 216 | } |
193 | }) | 217 | }) |
194 | 218 | ||
@@ -198,8 +222,8 @@ describe('Test video NSFW policy', function () { | |||
198 | 222 | ||
199 | const videos = res.body.data | 223 | const videos = res.body.data |
200 | expect(videos).to.have.lengthOf(2) | 224 | expect(videos).to.have.lengthOf(2) |
201 | expect(videos[ 0 ].name).to.equal('normal') | 225 | expect(videos[0].name).to.equal('normal') |
202 | expect(videos[ 1 ].name).to.equal('nsfw') | 226 | expect(videos[1].name).to.equal('nsfw') |
203 | }) | 227 | }) |
204 | 228 | ||
205 | it('Should display NSFW videos when the nsfw param === true', async function () { | 229 | it('Should display NSFW videos when the nsfw param === true', async function () { |
@@ -208,7 +232,7 @@ describe('Test video NSFW policy', function () { | |||
208 | 232 | ||
209 | const videos = res.body.data | 233 | const videos = res.body.data |
210 | expect(videos).to.have.lengthOf(1) | 234 | expect(videos).to.have.lengthOf(1) |
211 | expect(videos[ 0 ].name).to.equal('nsfw') | 235 | expect(videos[0].name).to.equal('nsfw') |
212 | } | 236 | } |
213 | }) | 237 | }) |
214 | 238 | ||
@@ -218,7 +242,7 @@ describe('Test video NSFW policy', function () { | |||
218 | 242 | ||
219 | const videos = res.body.data | 243 | const videos = res.body.data |
220 | expect(videos).to.have.lengthOf(1) | 244 | expect(videos).to.have.lengthOf(1) |
221 | expect(videos[ 0 ].name).to.equal('normal') | 245 | expect(videos[0].name).to.equal('normal') |
222 | } | 246 | } |
223 | }) | 247 | }) |
224 | 248 | ||
@@ -228,8 +252,8 @@ describe('Test video NSFW policy', function () { | |||
228 | 252 | ||
229 | const videos = res.body.data | 253 | const videos = res.body.data |
230 | expect(videos).to.have.lengthOf(2) | 254 | expect(videos).to.have.lengthOf(2) |
231 | expect(videos[ 0 ].name).to.equal('normal') | 255 | expect(videos[0].name).to.equal('normal') |
232 | expect(videos[ 1 ].name).to.equal('nsfw') | 256 | expect(videos[1].name).to.equal('nsfw') |
233 | } | 257 | } |
234 | }) | 258 | }) |
235 | }) | 259 | }) |
diff --git a/server/tests/api/videos/video-playlist-thumbnails.ts b/server/tests/api/videos/video-playlist-thumbnails.ts index 73ab02c17..a93a0b7de 100644 --- a/server/tests/api/videos/video-playlist-thumbnails.ts +++ b/server/tests/api/videos/video-playlist-thumbnails.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
@@ -8,14 +8,15 @@ import { | |||
8 | createVideoPlaylist, | 8 | createVideoPlaylist, |
9 | doubleFollow, | 9 | doubleFollow, |
10 | flushAndRunMultipleServers, | 10 | flushAndRunMultipleServers, |
11 | getVideoPlaylistsList, removeVideoFromPlaylist, | 11 | getVideoPlaylistsList, |
12 | removeVideoFromPlaylist, | ||
13 | reorderVideosPlaylist, | ||
12 | ServerInfo, | 14 | ServerInfo, |
13 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
14 | setDefaultVideoChannel, | 16 | setDefaultVideoChannel, |
15 | testImage, | 17 | testImage, |
16 | uploadVideoAndGetId, | 18 | uploadVideoAndGetId, |
17 | waitJobs, | 19 | waitJobs |
18 | reorderVideosPlaylist | ||
19 | } from '../../../../shared/extra-utils' | 20 | } from '../../../../shared/extra-utils' |
20 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | 21 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' |
21 | 22 | ||
@@ -69,19 +70,19 @@ describe('Playlist thumbnail', function () { | |||
69 | this.timeout(30000) | 70 | this.timeout(30000) |
70 | 71 | ||
71 | const res = await createVideoPlaylist({ | 72 | const res = await createVideoPlaylist({ |
72 | url: servers[ 1 ].url, | 73 | url: servers[1].url, |
73 | token: servers[ 1 ].accessToken, | 74 | token: servers[1].accessToken, |
74 | playlistAttrs: { | 75 | playlistAttrs: { |
75 | displayName: 'playlist without thumbnail', | 76 | displayName: 'playlist without thumbnail', |
76 | privacy: VideoPlaylistPrivacy.PUBLIC, | 77 | privacy: VideoPlaylistPrivacy.PUBLIC, |
77 | videoChannelId: servers[ 1 ].videoChannel.id | 78 | videoChannelId: servers[1].videoChannel.id |
78 | } | 79 | } |
79 | }) | 80 | }) |
80 | playlistWithoutThumbnail = res.body.videoPlaylist.id | 81 | playlistWithoutThumbnail = res.body.videoPlaylist.id |
81 | 82 | ||
82 | const res2 = await addVideoInPlaylist({ | 83 | const res2 = await addVideoInPlaylist({ |
83 | url: servers[ 1 ].url, | 84 | url: servers[1].url, |
84 | token: servers[ 1 ].accessToken, | 85 | token: servers[1].accessToken, |
85 | playlistId: playlistWithoutThumbnail, | 86 | playlistId: playlistWithoutThumbnail, |
86 | elementAttrs: { videoId: video1 } | 87 | elementAttrs: { videoId: video1 } |
87 | }) | 88 | }) |
@@ -99,20 +100,20 @@ describe('Playlist thumbnail', function () { | |||
99 | this.timeout(30000) | 100 | this.timeout(30000) |
100 | 101 | ||
101 | const res = await createVideoPlaylist({ | 102 | const res = await createVideoPlaylist({ |
102 | url: servers[ 1 ].url, | 103 | url: servers[1].url, |
103 | token: servers[ 1 ].accessToken, | 104 | token: servers[1].accessToken, |
104 | playlistAttrs: { | 105 | playlistAttrs: { |
105 | displayName: 'playlist with thumbnail', | 106 | displayName: 'playlist with thumbnail', |
106 | privacy: VideoPlaylistPrivacy.PUBLIC, | 107 | privacy: VideoPlaylistPrivacy.PUBLIC, |
107 | videoChannelId: servers[ 1 ].videoChannel.id, | 108 | videoChannelId: servers[1].videoChannel.id, |
108 | thumbnailfile: 'thumbnail.jpg' | 109 | thumbnailfile: 'thumbnail.jpg' |
109 | } | 110 | } |
110 | }) | 111 | }) |
111 | playlistWithThumbnail = res.body.videoPlaylist.id | 112 | playlistWithThumbnail = res.body.videoPlaylist.id |
112 | 113 | ||
113 | const res2 = await addVideoInPlaylist({ | 114 | const res2 = await addVideoInPlaylist({ |
114 | url: servers[ 1 ].url, | 115 | url: servers[1].url, |
115 | token: servers[ 1 ].accessToken, | 116 | token: servers[1].accessToken, |
116 | playlistId: playlistWithThumbnail, | 117 | playlistId: playlistWithThumbnail, |
117 | elementAttrs: { videoId: video1 } | 118 | elementAttrs: { videoId: video1 } |
118 | }) | 119 | }) |
@@ -130,8 +131,8 @@ describe('Playlist thumbnail', function () { | |||
130 | this.timeout(30000) | 131 | this.timeout(30000) |
131 | 132 | ||
132 | const res = await addVideoInPlaylist({ | 133 | const res = await addVideoInPlaylist({ |
133 | url: servers[ 1 ].url, | 134 | url: servers[1].url, |
134 | token: servers[ 1 ].accessToken, | 135 | token: servers[1].accessToken, |
135 | playlistId: playlistWithoutThumbnail, | 136 | playlistId: playlistWithoutThumbnail, |
136 | elementAttrs: { videoId: video2 } | 137 | elementAttrs: { videoId: video2 } |
137 | }) | 138 | }) |
@@ -159,8 +160,8 @@ describe('Playlist thumbnail', function () { | |||
159 | this.timeout(30000) | 160 | this.timeout(30000) |
160 | 161 | ||
161 | const res = await addVideoInPlaylist({ | 162 | const res = await addVideoInPlaylist({ |
162 | url: servers[ 1 ].url, | 163 | url: servers[1].url, |
163 | token: servers[ 1 ].accessToken, | 164 | token: servers[1].accessToken, |
164 | playlistId: playlistWithThumbnail, | 165 | playlistId: playlistWithThumbnail, |
165 | elementAttrs: { videoId: video2 } | 166 | elementAttrs: { videoId: video2 } |
166 | }) | 167 | }) |
@@ -188,8 +189,8 @@ describe('Playlist thumbnail', function () { | |||
188 | this.timeout(30000) | 189 | this.timeout(30000) |
189 | 190 | ||
190 | await removeVideoFromPlaylist({ | 191 | await removeVideoFromPlaylist({ |
191 | url: servers[ 1 ].url, | 192 | url: servers[1].url, |
192 | token: servers[ 1 ].accessToken, | 193 | token: servers[1].accessToken, |
193 | playlistId: playlistWithoutThumbnail, | 194 | playlistId: playlistWithoutThumbnail, |
194 | playlistElementId: withoutThumbnailE1 | 195 | playlistElementId: withoutThumbnailE1 |
195 | }) | 196 | }) |
@@ -206,8 +207,8 @@ describe('Playlist thumbnail', function () { | |||
206 | this.timeout(30000) | 207 | this.timeout(30000) |
207 | 208 | ||
208 | await removeVideoFromPlaylist({ | 209 | await removeVideoFromPlaylist({ |
209 | url: servers[ 1 ].url, | 210 | url: servers[1].url, |
210 | token: servers[ 1 ].accessToken, | 211 | token: servers[1].accessToken, |
211 | playlistId: playlistWithThumbnail, | 212 | playlistId: playlistWithThumbnail, |
212 | playlistElementId: withThumbnailE1 | 213 | playlistElementId: withThumbnailE1 |
213 | }) | 214 | }) |
@@ -224,8 +225,8 @@ describe('Playlist thumbnail', function () { | |||
224 | this.timeout(30000) | 225 | this.timeout(30000) |
225 | 226 | ||
226 | await removeVideoFromPlaylist({ | 227 | await removeVideoFromPlaylist({ |
227 | url: servers[ 1 ].url, | 228 | url: servers[1].url, |
228 | token: servers[ 1 ].accessToken, | 229 | token: servers[1].accessToken, |
229 | playlistId: playlistWithoutThumbnail, | 230 | playlistId: playlistWithoutThumbnail, |
230 | playlistElementId: withoutThumbnailE2 | 231 | playlistElementId: withoutThumbnailE2 |
231 | }) | 232 | }) |
@@ -242,8 +243,8 @@ describe('Playlist thumbnail', function () { | |||
242 | this.timeout(30000) | 243 | this.timeout(30000) |
243 | 244 | ||
244 | await removeVideoFromPlaylist({ | 245 | await removeVideoFromPlaylist({ |
245 | url: servers[ 1 ].url, | 246 | url: servers[1].url, |
246 | token: servers[ 1 ].accessToken, | 247 | token: servers[1].accessToken, |
247 | playlistId: playlistWithThumbnail, | 248 | playlistId: playlistWithThumbnail, |
248 | playlistElementId: withThumbnailE2 | 249 | playlistElementId: withThumbnailE2 |
249 | }) | 250 | }) |
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts index 9fd48ac7c..2bb97d7a8 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/server/tests/api/videos/video-playlists.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
@@ -141,12 +141,12 @@ describe('Test video playlists', function () { | |||
141 | servers[2].videos = await Promise.all(serverPromises[2]) | 141 | servers[2].videos = await Promise.all(serverPromises[2]) |
142 | } | 142 | } |
143 | 143 | ||
144 | nsfwVideoServer1 = (await uploadVideoAndGetId({ server: servers[ 0 ], videoName: 'NSFW video', nsfw: true })).id | 144 | nsfwVideoServer1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'NSFW video', nsfw: true })).id |
145 | 145 | ||
146 | { | 146 | { |
147 | await createUser({ | 147 | await createUser({ |
148 | url: servers[ 0 ].url, | 148 | url: servers[0].url, |
149 | accessToken: servers[ 0 ].accessToken, | 149 | accessToken: servers[0].accessToken, |
150 | username: 'user1', | 150 | username: 'user1', |
151 | password: 'password' | 151 | password: 'password' |
152 | }) | 152 | }) |
@@ -158,17 +158,17 @@ describe('Test video playlists', function () { | |||
158 | 158 | ||
159 | describe('Get default playlists', function () { | 159 | describe('Get default playlists', function () { |
160 | it('Should list video playlist privacies', async function () { | 160 | it('Should list video playlist privacies', async function () { |
161 | const res = await getVideoPlaylistPrivacies(servers[ 0 ].url) | 161 | const res = await getVideoPlaylistPrivacies(servers[0].url) |
162 | 162 | ||
163 | const privacies = res.body | 163 | const privacies = res.body |
164 | expect(Object.keys(privacies)).to.have.length.at.least(3) | 164 | expect(Object.keys(privacies)).to.have.length.at.least(3) |
165 | 165 | ||
166 | expect(privacies[ 3 ]).to.equal('Private') | 166 | expect(privacies[3]).to.equal('Private') |
167 | }) | 167 | }) |
168 | 168 | ||
169 | it('Should list watch later playlist', async function () { | 169 | it('Should list watch later playlist', async function () { |
170 | const url = servers[ 0 ].url | 170 | const url = servers[0].url |
171 | const accessToken = servers[ 0 ].accessToken | 171 | const accessToken = servers[0].accessToken |
172 | 172 | ||
173 | { | 173 | { |
174 | const res = await getAccountPlaylistsListWithToken(url, accessToken, 'root', 0, 5, VideoPlaylistType.WATCH_LATER) | 174 | const res = await getAccountPlaylistsListWithToken(url, accessToken, 'root', 0, 5, VideoPlaylistType.WATCH_LATER) |
@@ -176,7 +176,7 @@ describe('Test video playlists', function () { | |||
176 | expect(res.body.total).to.equal(1) | 176 | expect(res.body.total).to.equal(1) |
177 | expect(res.body.data).to.have.lengthOf(1) | 177 | expect(res.body.data).to.have.lengthOf(1) |
178 | 178 | ||
179 | const playlist: VideoPlaylist = res.body.data[ 0 ] | 179 | const playlist: VideoPlaylist = res.body.data[0] |
180 | expect(playlist.displayName).to.equal('Watch later') | 180 | expect(playlist.displayName).to.equal('Watch later') |
181 | expect(playlist.type.id).to.equal(VideoPlaylistType.WATCH_LATER) | 181 | expect(playlist.type.id).to.equal(VideoPlaylistType.WATCH_LATER) |
182 | expect(playlist.type.label).to.equal('Watch later') | 182 | expect(playlist.type.label).to.equal('Watch later') |
@@ -197,15 +197,15 @@ describe('Test video playlists', function () { | |||
197 | }) | 197 | }) |
198 | 198 | ||
199 | it('Should get private playlist for a classic user', async function () { | 199 | it('Should get private playlist for a classic user', async function () { |
200 | const token = await generateUserAccessToken(servers[ 0 ], 'toto') | 200 | const token = await generateUserAccessToken(servers[0], 'toto') |
201 | 201 | ||
202 | const res = await getAccountPlaylistsListWithToken(servers[ 0 ].url, token, 'toto', 0, 5) | 202 | const res = await getAccountPlaylistsListWithToken(servers[0].url, token, 'toto', 0, 5) |
203 | 203 | ||
204 | expect(res.body.total).to.equal(1) | 204 | expect(res.body.total).to.equal(1) |
205 | expect(res.body.data).to.have.lengthOf(1) | 205 | expect(res.body.data).to.have.lengthOf(1) |
206 | 206 | ||
207 | const playlistId = res.body.data[ 0 ].id | 207 | const playlistId = res.body.data[0].id |
208 | await getPlaylistVideos(servers[ 0 ].url, token, playlistId, 0, 5) | 208 | await getPlaylistVideos(servers[0].url, token, playlistId, 0, 5) |
209 | }) | 209 | }) |
210 | }) | 210 | }) |
211 | 211 | ||
@@ -215,14 +215,14 @@ describe('Test video playlists', function () { | |||
215 | this.timeout(30000) | 215 | this.timeout(30000) |
216 | 216 | ||
217 | await createVideoPlaylist({ | 217 | await createVideoPlaylist({ |
218 | url: servers[ 0 ].url, | 218 | url: servers[0].url, |
219 | token: servers[ 0 ].accessToken, | 219 | token: servers[0].accessToken, |
220 | playlistAttrs: { | 220 | playlistAttrs: { |
221 | displayName: 'my super playlist', | 221 | displayName: 'my super playlist', |
222 | privacy: VideoPlaylistPrivacy.PUBLIC, | 222 | privacy: VideoPlaylistPrivacy.PUBLIC, |
223 | description: 'my super description', | 223 | description: 'my super description', |
224 | thumbnailfile: 'thumbnail.jpg', | 224 | thumbnailfile: 'thumbnail.jpg', |
225 | videoChannelId: servers[ 0 ].videoChannel.id | 225 | videoChannelId: servers[0].videoChannel.id |
226 | } | 226 | } |
227 | }) | 227 | }) |
228 | 228 | ||
@@ -233,7 +233,7 @@ describe('Test video playlists', function () { | |||
233 | expect(res.body.total).to.equal(1) | 233 | expect(res.body.total).to.equal(1) |
234 | expect(res.body.data).to.have.lengthOf(1) | 234 | expect(res.body.data).to.have.lengthOf(1) |
235 | 235 | ||
236 | const playlistFromList = res.body.data[ 0 ] as VideoPlaylist | 236 | const playlistFromList = res.body.data[0] as VideoPlaylist |
237 | 237 | ||
238 | const res2 = await getVideoPlaylist(server.url, playlistFromList.uuid) | 238 | const res2 = await getVideoPlaylist(server.url, playlistFromList.uuid) |
239 | const playlistFromGet = res2.body | 239 | const playlistFromGet = res2.body |
@@ -266,12 +266,12 @@ describe('Test video playlists', function () { | |||
266 | 266 | ||
267 | { | 267 | { |
268 | const res = await createVideoPlaylist({ | 268 | const res = await createVideoPlaylist({ |
269 | url: servers[ 1 ].url, | 269 | url: servers[1].url, |
270 | token: servers[ 1 ].accessToken, | 270 | token: servers[1].accessToken, |
271 | playlistAttrs: { | 271 | playlistAttrs: { |
272 | displayName: 'playlist 2', | 272 | displayName: 'playlist 2', |
273 | privacy: VideoPlaylistPrivacy.PUBLIC, | 273 | privacy: VideoPlaylistPrivacy.PUBLIC, |
274 | videoChannelId: servers[ 1 ].videoChannel.id | 274 | videoChannelId: servers[1].videoChannel.id |
275 | } | 275 | } |
276 | }) | 276 | }) |
277 | playlistServer2Id1 = res.body.videoPlaylist.id | 277 | playlistServer2Id1 = res.body.videoPlaylist.id |
@@ -279,13 +279,13 @@ describe('Test video playlists', function () { | |||
279 | 279 | ||
280 | { | 280 | { |
281 | const res = await createVideoPlaylist({ | 281 | const res = await createVideoPlaylist({ |
282 | url: servers[ 1 ].url, | 282 | url: servers[1].url, |
283 | token: servers[ 1 ].accessToken, | 283 | token: servers[1].accessToken, |
284 | playlistAttrs: { | 284 | playlistAttrs: { |
285 | displayName: 'playlist 3', | 285 | displayName: 'playlist 3', |
286 | privacy: VideoPlaylistPrivacy.PUBLIC, | 286 | privacy: VideoPlaylistPrivacy.PUBLIC, |
287 | thumbnailfile: 'thumbnail.jpg', | 287 | thumbnailfile: 'thumbnail.jpg', |
288 | videoChannelId: servers[ 1 ].videoChannel.id | 288 | videoChannelId: servers[1].videoChannel.id |
289 | } | 289 | } |
290 | }) | 290 | }) |
291 | 291 | ||
@@ -293,24 +293,24 @@ describe('Test video playlists', function () { | |||
293 | playlistServer2UUID2 = res.body.videoPlaylist.uuid | 293 | playlistServer2UUID2 = res.body.videoPlaylist.uuid |
294 | } | 294 | } |
295 | 295 | ||
296 | for (let id of [ playlistServer2Id1, playlistServer2Id2 ]) { | 296 | for (const id of [ playlistServer2Id1, playlistServer2Id2 ]) { |
297 | await addVideoInPlaylist({ | 297 | await addVideoInPlaylist({ |
298 | url: servers[ 1 ].url, | 298 | url: servers[1].url, |
299 | token: servers[ 1 ].accessToken, | 299 | token: servers[1].accessToken, |
300 | playlistId: id, | 300 | playlistId: id, |
301 | elementAttrs: { videoId: servers[ 1 ].videos[ 0 ].id, startTimestamp: 1, stopTimestamp: 2 } | 301 | elementAttrs: { videoId: servers[1].videos[0].id, startTimestamp: 1, stopTimestamp: 2 } |
302 | }) | 302 | }) |
303 | await addVideoInPlaylist({ | 303 | await addVideoInPlaylist({ |
304 | url: servers[ 1 ].url, | 304 | url: servers[1].url, |
305 | token: servers[ 1 ].accessToken, | 305 | token: servers[1].accessToken, |
306 | playlistId: id, | 306 | playlistId: id, |
307 | elementAttrs: { videoId: servers[ 1 ].videos[ 1 ].id } | 307 | elementAttrs: { videoId: servers[1].videos[1].id } |
308 | }) | 308 | }) |
309 | } | 309 | } |
310 | 310 | ||
311 | await waitJobs(servers) | 311 | await waitJobs(servers) |
312 | 312 | ||
313 | for (const server of [ servers[ 0 ], servers[ 1 ] ]) { | 313 | for (const server of [ servers[0], servers[1] ]) { |
314 | const res = await getVideoPlaylistsList(server.url, 0, 5) | 314 | const res = await getVideoPlaylistsList(server.url, 0, 5) |
315 | 315 | ||
316 | const playlist2 = res.body.data.find(p => p.displayName === 'playlist 2') | 316 | const playlist2 = res.body.data.find(p => p.displayName === 'playlist 2') |
@@ -322,7 +322,7 @@ describe('Test video playlists', function () { | |||
322 | await testImage(server.url, 'thumbnail', playlist3.thumbnailPath) | 322 | await testImage(server.url, 'thumbnail', playlist3.thumbnailPath) |
323 | } | 323 | } |
324 | 324 | ||
325 | const res = await getVideoPlaylistsList(servers[ 2 ].url, 0, 5) | 325 | const res = await getVideoPlaylistsList(servers[2].url, 0, 5) |
326 | expect(res.body.data.find(p => p.displayName === 'playlist 2')).to.be.undefined | 326 | expect(res.body.data.find(p => p.displayName === 'playlist 2')).to.be.undefined |
327 | expect(res.body.data.find(p => p.displayName === 'playlist 3')).to.be.undefined | 327 | expect(res.body.data.find(p => p.displayName === 'playlist 3')).to.be.undefined |
328 | }) | 328 | }) |
@@ -331,13 +331,13 @@ describe('Test video playlists', function () { | |||
331 | this.timeout(30000) | 331 | this.timeout(30000) |
332 | 332 | ||
333 | // Server 2 and server 3 follow each other | 333 | // Server 2 and server 3 follow each other |
334 | await doubleFollow(servers[ 1 ], servers[ 2 ]) | 334 | await doubleFollow(servers[1], servers[2]) |
335 | 335 | ||
336 | const res = await getVideoPlaylistsList(servers[ 2 ].url, 0, 5) | 336 | const res = await getVideoPlaylistsList(servers[2].url, 0, 5) |
337 | 337 | ||
338 | const playlist2 = res.body.data.find(p => p.displayName === 'playlist 2') | 338 | const playlist2 = res.body.data.find(p => p.displayName === 'playlist 2') |
339 | expect(playlist2).to.not.be.undefined | 339 | expect(playlist2).to.not.be.undefined |
340 | await testImage(servers[ 2 ].url, 'thumbnail-playlist', playlist2.thumbnailPath) | 340 | await testImage(servers[2].url, 'thumbnail-playlist', playlist2.thumbnailPath) |
341 | 341 | ||
342 | expect(res.body.data.find(p => p.displayName === 'playlist 3')).to.not.be.undefined | 342 | expect(res.body.data.find(p => p.displayName === 'playlist 3')).to.not.be.undefined |
343 | }) | 343 | }) |
@@ -349,25 +349,25 @@ describe('Test video playlists', function () { | |||
349 | this.timeout(30000) | 349 | this.timeout(30000) |
350 | 350 | ||
351 | { | 351 | { |
352 | const res = await getVideoPlaylistsList(servers[ 2 ].url, 1, 2, 'createdAt') | 352 | const res = await getVideoPlaylistsList(servers[2].url, 1, 2, 'createdAt') |
353 | 353 | ||
354 | expect(res.body.total).to.equal(3) | 354 | expect(res.body.total).to.equal(3) |
355 | 355 | ||
356 | const data: VideoPlaylist[] = res.body.data | 356 | const data: VideoPlaylist[] = res.body.data |
357 | expect(data).to.have.lengthOf(2) | 357 | expect(data).to.have.lengthOf(2) |
358 | expect(data[ 0 ].displayName).to.equal('playlist 2') | 358 | expect(data[0].displayName).to.equal('playlist 2') |
359 | expect(data[ 1 ].displayName).to.equal('playlist 3') | 359 | expect(data[1].displayName).to.equal('playlist 3') |
360 | } | 360 | } |
361 | 361 | ||
362 | { | 362 | { |
363 | const res = await getVideoPlaylistsList(servers[ 2 ].url, 1, 2, '-createdAt') | 363 | const res = await getVideoPlaylistsList(servers[2].url, 1, 2, '-createdAt') |
364 | 364 | ||
365 | expect(res.body.total).to.equal(3) | 365 | expect(res.body.total).to.equal(3) |
366 | 366 | ||
367 | const data: VideoPlaylist[] = res.body.data | 367 | const data: VideoPlaylist[] = res.body.data |
368 | expect(data).to.have.lengthOf(2) | 368 | expect(data).to.have.lengthOf(2) |
369 | expect(data[ 0 ].displayName).to.equal('playlist 2') | 369 | expect(data[0].displayName).to.equal('playlist 2') |
370 | expect(data[ 1 ].displayName).to.equal('my super playlist') | 370 | expect(data[1].displayName).to.equal('my super playlist') |
371 | } | 371 | } |
372 | }) | 372 | }) |
373 | 373 | ||
@@ -375,13 +375,13 @@ describe('Test video playlists', function () { | |||
375 | this.timeout(30000) | 375 | this.timeout(30000) |
376 | 376 | ||
377 | { | 377 | { |
378 | const res = await getVideoChannelPlaylistsList(servers[ 0 ].url, 'root_channel', 0, 2, '-createdAt') | 378 | const res = await getVideoChannelPlaylistsList(servers[0].url, 'root_channel', 0, 2, '-createdAt') |
379 | 379 | ||
380 | expect(res.body.total).to.equal(1) | 380 | expect(res.body.total).to.equal(1) |
381 | 381 | ||
382 | const data: VideoPlaylist[] = res.body.data | 382 | const data: VideoPlaylist[] = res.body.data |
383 | expect(data).to.have.lengthOf(1) | 383 | expect(data).to.have.lengthOf(1) |
384 | expect(data[ 0 ].displayName).to.equal('my super playlist') | 384 | expect(data[0].displayName).to.equal('my super playlist') |
385 | } | 385 | } |
386 | }) | 386 | }) |
387 | 387 | ||
@@ -389,37 +389,37 @@ describe('Test video playlists', function () { | |||
389 | this.timeout(30000) | 389 | this.timeout(30000) |
390 | 390 | ||
391 | { | 391 | { |
392 | const res = await getAccountPlaylistsList(servers[ 1 ].url, 'root', 1, 2, '-createdAt') | 392 | const res = await getAccountPlaylistsList(servers[1].url, 'root', 1, 2, '-createdAt') |
393 | 393 | ||
394 | expect(res.body.total).to.equal(2) | 394 | expect(res.body.total).to.equal(2) |
395 | 395 | ||
396 | const data: VideoPlaylist[] = res.body.data | 396 | const data: VideoPlaylist[] = res.body.data |
397 | expect(data).to.have.lengthOf(1) | 397 | expect(data).to.have.lengthOf(1) |
398 | expect(data[ 0 ].displayName).to.equal('playlist 2') | 398 | expect(data[0].displayName).to.equal('playlist 2') |
399 | } | 399 | } |
400 | 400 | ||
401 | { | 401 | { |
402 | const res = await getAccountPlaylistsList(servers[ 1 ].url, 'root', 1, 2, 'createdAt') | 402 | const res = await getAccountPlaylistsList(servers[1].url, 'root', 1, 2, 'createdAt') |
403 | 403 | ||
404 | expect(res.body.total).to.equal(2) | 404 | expect(res.body.total).to.equal(2) |
405 | 405 | ||
406 | const data: VideoPlaylist[] = res.body.data | 406 | const data: VideoPlaylist[] = res.body.data |
407 | expect(data).to.have.lengthOf(1) | 407 | expect(data).to.have.lengthOf(1) |
408 | expect(data[ 0 ].displayName).to.equal('playlist 3') | 408 | expect(data[0].displayName).to.equal('playlist 3') |
409 | } | 409 | } |
410 | 410 | ||
411 | { | 411 | { |
412 | const res = await getAccountPlaylistsList(servers[ 1 ].url, 'root', 0, 10, 'createdAt', '3') | 412 | const res = await getAccountPlaylistsList(servers[1].url, 'root', 0, 10, 'createdAt', '3') |
413 | 413 | ||
414 | expect(res.body.total).to.equal(1) | 414 | expect(res.body.total).to.equal(1) |
415 | 415 | ||
416 | const data: VideoPlaylist[] = res.body.data | 416 | const data: VideoPlaylist[] = res.body.data |
417 | expect(data).to.have.lengthOf(1) | 417 | expect(data).to.have.lengthOf(1) |
418 | expect(data[ 0 ].displayName).to.equal('playlist 3') | 418 | expect(data[0].displayName).to.equal('playlist 3') |
419 | } | 419 | } |
420 | 420 | ||
421 | { | 421 | { |
422 | const res = await getAccountPlaylistsList(servers[ 1 ].url, 'root', 0, 10, 'createdAt', '4') | 422 | const res = await getAccountPlaylistsList(servers[1].url, 'root', 0, 10, 'createdAt', '4') |
423 | 423 | ||
424 | expect(res.body.total).to.equal(0) | 424 | expect(res.body.total).to.equal(0) |
425 | 425 | ||
@@ -432,8 +432,8 @@ describe('Test video playlists', function () { | |||
432 | this.timeout(30000) | 432 | this.timeout(30000) |
433 | 433 | ||
434 | await createVideoPlaylist({ | 434 | await createVideoPlaylist({ |
435 | url: servers[ 1 ].url, | 435 | url: servers[1].url, |
436 | token: servers[ 1 ].accessToken, | 436 | token: servers[1].accessToken, |
437 | playlistAttrs: { | 437 | playlistAttrs: { |
438 | displayName: 'playlist unlisted', | 438 | displayName: 'playlist unlisted', |
439 | privacy: VideoPlaylistPrivacy.UNLISTED | 439 | privacy: VideoPlaylistPrivacy.UNLISTED |
@@ -441,8 +441,8 @@ describe('Test video playlists', function () { | |||
441 | }) | 441 | }) |
442 | 442 | ||
443 | await createVideoPlaylist({ | 443 | await createVideoPlaylist({ |
444 | url: servers[ 1 ].url, | 444 | url: servers[1].url, |
445 | token: servers[ 1 ].accessToken, | 445 | token: servers[1].accessToken, |
446 | playlistAttrs: { | 446 | playlistAttrs: { |
447 | displayName: 'playlist private', | 447 | displayName: 'playlist private', |
448 | privacy: VideoPlaylistPrivacy.PRIVATE | 448 | privacy: VideoPlaylistPrivacy.PRIVATE |
@@ -453,18 +453,18 @@ describe('Test video playlists', function () { | |||
453 | 453 | ||
454 | for (const server of servers) { | 454 | for (const server of servers) { |
455 | const results = [ | 455 | const results = [ |
456 | await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[ 1 ].port, 0, 5, '-createdAt'), | 456 | await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[1].port, 0, 5, '-createdAt'), |
457 | await getVideoPlaylistsList(server.url, 0, 2, '-createdAt') | 457 | await getVideoPlaylistsList(server.url, 0, 2, '-createdAt') |
458 | ] | 458 | ] |
459 | 459 | ||
460 | expect(results[ 0 ].body.total).to.equal(2) | 460 | expect(results[0].body.total).to.equal(2) |
461 | expect(results[ 1 ].body.total).to.equal(3) | 461 | expect(results[1].body.total).to.equal(3) |
462 | 462 | ||
463 | for (const res of results) { | 463 | for (const res of results) { |
464 | const data: VideoPlaylist[] = res.body.data | 464 | const data: VideoPlaylist[] = res.body.data |
465 | expect(data).to.have.lengthOf(2) | 465 | expect(data).to.have.lengthOf(2) |
466 | expect(data[ 0 ].displayName).to.equal('playlist 3') | 466 | expect(data[0].displayName).to.equal('playlist 3') |
467 | expect(data[ 1 ].displayName).to.equal('playlist 2') | 467 | expect(data[1].displayName).to.equal('playlist 2') |
468 | } | 468 | } |
469 | } | 469 | } |
470 | }) | 470 | }) |
@@ -519,32 +519,32 @@ describe('Test video playlists', function () { | |||
519 | this.timeout(30000) | 519 | this.timeout(30000) |
520 | 520 | ||
521 | const addVideo = (elementAttrs: any) => { | 521 | const addVideo = (elementAttrs: any) => { |
522 | return addVideoInPlaylist({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, playlistId: playlistServer1Id, elementAttrs }) | 522 | return addVideoInPlaylist({ url: servers[0].url, token: servers[0].accessToken, playlistId: playlistServer1Id, elementAttrs }) |
523 | } | 523 | } |
524 | 524 | ||
525 | const res = await createVideoPlaylist({ | 525 | const res = await createVideoPlaylist({ |
526 | url: servers[ 0 ].url, | 526 | url: servers[0].url, |
527 | token: servers[ 0 ].accessToken, | 527 | token: servers[0].accessToken, |
528 | playlistAttrs: { | 528 | playlistAttrs: { |
529 | displayName: 'playlist 4', | 529 | displayName: 'playlist 4', |
530 | privacy: VideoPlaylistPrivacy.PUBLIC, | 530 | privacy: VideoPlaylistPrivacy.PUBLIC, |
531 | videoChannelId: servers[ 0 ].videoChannel.id | 531 | videoChannelId: servers[0].videoChannel.id |
532 | } | 532 | } |
533 | }) | 533 | }) |
534 | 534 | ||
535 | playlistServer1Id = res.body.videoPlaylist.id | 535 | playlistServer1Id = res.body.videoPlaylist.id |
536 | playlistServer1UUID = res.body.videoPlaylist.uuid | 536 | playlistServer1UUID = res.body.videoPlaylist.uuid |
537 | 537 | ||
538 | await addVideo({ videoId: servers[ 0 ].videos[ 0 ].uuid, startTimestamp: 15, stopTimestamp: 28 }) | 538 | await addVideo({ videoId: servers[0].videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 }) |
539 | await addVideo({ videoId: servers[ 2 ].videos[ 1 ].uuid, startTimestamp: 35 }) | 539 | await addVideo({ videoId: servers[2].videos[1].uuid, startTimestamp: 35 }) |
540 | await addVideo({ videoId: servers[ 2 ].videos[ 2 ].uuid }) | 540 | await addVideo({ videoId: servers[2].videos[2].uuid }) |
541 | { | 541 | { |
542 | const res = await addVideo({ videoId: servers[ 0 ].videos[ 3 ].uuid, stopTimestamp: 35 }) | 542 | const res = await addVideo({ videoId: servers[0].videos[3].uuid, stopTimestamp: 35 }) |
543 | playlistElementServer1Video4 = res.body.videoPlaylistElement.id | 543 | playlistElementServer1Video4 = res.body.videoPlaylistElement.id |
544 | } | 544 | } |
545 | 545 | ||
546 | { | 546 | { |
547 | const res = await addVideo({ videoId: servers[ 0 ].videos[ 4 ].uuid, startTimestamp: 45, stopTimestamp: 60 }) | 547 | const res = await addVideo({ videoId: servers[0].videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 }) |
548 | playlistElementServer1Video5 = res.body.videoPlaylistElement.id | 548 | playlistElementServer1Video5 = res.body.videoPlaylistElement.id |
549 | } | 549 | } |
550 | 550 | ||
@@ -567,35 +567,35 @@ describe('Test video playlists', function () { | |||
567 | const videoElements: VideoPlaylistElement[] = res.body.data | 567 | const videoElements: VideoPlaylistElement[] = res.body.data |
568 | expect(videoElements).to.have.lengthOf(6) | 568 | expect(videoElements).to.have.lengthOf(6) |
569 | 569 | ||
570 | expect(videoElements[ 0 ].video.name).to.equal('video 0 server 1') | 570 | expect(videoElements[0].video.name).to.equal('video 0 server 1') |
571 | expect(videoElements[ 0 ].position).to.equal(1) | 571 | expect(videoElements[0].position).to.equal(1) |
572 | expect(videoElements[ 0 ].startTimestamp).to.equal(15) | 572 | expect(videoElements[0].startTimestamp).to.equal(15) |
573 | expect(videoElements[ 0 ].stopTimestamp).to.equal(28) | 573 | expect(videoElements[0].stopTimestamp).to.equal(28) |
574 | 574 | ||
575 | expect(videoElements[ 1 ].video.name).to.equal('video 1 server 3') | 575 | expect(videoElements[1].video.name).to.equal('video 1 server 3') |
576 | expect(videoElements[ 1 ].position).to.equal(2) | 576 | expect(videoElements[1].position).to.equal(2) |
577 | expect(videoElements[ 1 ].startTimestamp).to.equal(35) | 577 | expect(videoElements[1].startTimestamp).to.equal(35) |
578 | expect(videoElements[ 1 ].stopTimestamp).to.be.null | 578 | expect(videoElements[1].stopTimestamp).to.be.null |
579 | 579 | ||
580 | expect(videoElements[ 2 ].video.name).to.equal('video 2 server 3') | 580 | expect(videoElements[2].video.name).to.equal('video 2 server 3') |
581 | expect(videoElements[ 2 ].position).to.equal(3) | 581 | expect(videoElements[2].position).to.equal(3) |
582 | expect(videoElements[ 2 ].startTimestamp).to.be.null | 582 | expect(videoElements[2].startTimestamp).to.be.null |
583 | expect(videoElements[ 2 ].stopTimestamp).to.be.null | 583 | expect(videoElements[2].stopTimestamp).to.be.null |
584 | 584 | ||
585 | expect(videoElements[ 3 ].video.name).to.equal('video 3 server 1') | 585 | expect(videoElements[3].video.name).to.equal('video 3 server 1') |
586 | expect(videoElements[ 3 ].position).to.equal(4) | 586 | expect(videoElements[3].position).to.equal(4) |
587 | expect(videoElements[ 3 ].startTimestamp).to.be.null | 587 | expect(videoElements[3].startTimestamp).to.be.null |
588 | expect(videoElements[ 3 ].stopTimestamp).to.equal(35) | 588 | expect(videoElements[3].stopTimestamp).to.equal(35) |
589 | 589 | ||
590 | expect(videoElements[ 4 ].video.name).to.equal('video 4 server 1') | 590 | expect(videoElements[4].video.name).to.equal('video 4 server 1') |
591 | expect(videoElements[ 4 ].position).to.equal(5) | 591 | expect(videoElements[4].position).to.equal(5) |
592 | expect(videoElements[ 4 ].startTimestamp).to.equal(45) | 592 | expect(videoElements[4].startTimestamp).to.equal(45) |
593 | expect(videoElements[ 4 ].stopTimestamp).to.equal(60) | 593 | expect(videoElements[4].stopTimestamp).to.equal(60) |
594 | 594 | ||
595 | expect(videoElements[ 5 ].video.name).to.equal('NSFW video') | 595 | expect(videoElements[5].video.name).to.equal('NSFW video') |
596 | expect(videoElements[ 5 ].position).to.equal(6) | 596 | expect(videoElements[5].position).to.equal(6) |
597 | expect(videoElements[ 5 ].startTimestamp).to.equal(5) | 597 | expect(videoElements[5].startTimestamp).to.equal(5) |
598 | expect(videoElements[ 5 ].stopTimestamp).to.be.null | 598 | expect(videoElements[5].stopTimestamp).to.be.null |
599 | 599 | ||
600 | const res3 = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 2) | 600 | const res3 = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 2) |
601 | expect(res3.body.data).to.have.lengthOf(2) | 601 | expect(res3.body.data).to.have.lengthOf(2) |
@@ -616,18 +616,18 @@ describe('Test video playlists', function () { | |||
616 | before(async function () { | 616 | before(async function () { |
617 | this.timeout(30000) | 617 | this.timeout(30000) |
618 | 618 | ||
619 | groupUser1 = [ Object.assign({}, servers[ 0 ], { accessToken: userAccessTokenServer1 }) ] | 619 | groupUser1 = [ Object.assign({}, servers[0], { accessToken: userAccessTokenServer1 }) ] |
620 | groupWithoutToken1 = [ Object.assign({}, servers[ 0 ], { accessToken: undefined }) ] | 620 | groupWithoutToken1 = [ Object.assign({}, servers[0], { accessToken: undefined }) ] |
621 | group1 = [ servers[ 0 ] ] | 621 | group1 = [ servers[0] ] |
622 | group2 = [ servers[ 1 ], servers[ 2 ] ] | 622 | group2 = [ servers[1], servers[2] ] |
623 | 623 | ||
624 | const res = await createVideoPlaylist({ | 624 | const res = await createVideoPlaylist({ |
625 | url: servers[ 0 ].url, | 625 | url: servers[0].url, |
626 | token: userAccessTokenServer1, | 626 | token: userAccessTokenServer1, |
627 | playlistAttrs: { | 627 | playlistAttrs: { |
628 | displayName: 'playlist 56', | 628 | displayName: 'playlist 56', |
629 | privacy: VideoPlaylistPrivacy.PUBLIC, | 629 | privacy: VideoPlaylistPrivacy.PUBLIC, |
630 | videoChannelId: servers[ 0 ].videoChannel.id | 630 | videoChannelId: servers[0].videoChannel.id |
631 | } | 631 | } |
632 | }) | 632 | }) |
633 | 633 | ||
@@ -635,7 +635,7 @@ describe('Test video playlists', function () { | |||
635 | playlistServer1UUID2 = res.body.videoPlaylist.uuid | 635 | playlistServer1UUID2 = res.body.videoPlaylist.uuid |
636 | 636 | ||
637 | const addVideo = (elementAttrs: any) => { | 637 | const addVideo = (elementAttrs: any) => { |
638 | return addVideoInPlaylist({ url: servers[ 0 ].url, token: userAccessTokenServer1, playlistId: playlistServer1Id2, elementAttrs }) | 638 | return addVideoInPlaylist({ url: servers[0].url, token: userAccessTokenServer1, playlistId: playlistServer1Id2, elementAttrs }) |
639 | } | 639 | } |
640 | 640 | ||
641 | video1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 89', token: userAccessTokenServer1 })).uuid | 641 | video1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 89', token: userAccessTokenServer1 })).uuid |
@@ -656,7 +656,7 @@ describe('Test video playlists', function () { | |||
656 | const position = 1 | 656 | const position = 1 |
657 | 657 | ||
658 | { | 658 | { |
659 | await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, video1, { privacy: VideoPrivacy.PRIVATE }) | 659 | await updateVideo(servers[0].url, servers[0].accessToken, video1, { privacy: VideoPrivacy.PRIVATE }) |
660 | await waitJobs(servers) | 660 | await waitJobs(servers) |
661 | 661 | ||
662 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 662 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
@@ -666,7 +666,7 @@ describe('Test video playlists', function () { | |||
666 | } | 666 | } |
667 | 667 | ||
668 | { | 668 | { |
669 | await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, video1, { privacy: VideoPrivacy.PUBLIC }) | 669 | await updateVideo(servers[0].url, servers[0].accessToken, video1, { privacy: VideoPrivacy.PUBLIC }) |
670 | await waitJobs(servers) | 670 | await waitJobs(servers) |
671 | 671 | ||
672 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 672 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
@@ -684,7 +684,7 @@ describe('Test video playlists', function () { | |||
684 | const position = 1 | 684 | const position = 1 |
685 | 685 | ||
686 | { | 686 | { |
687 | await addVideoToBlacklist(servers[ 0 ].url, servers[ 0 ].accessToken, video1, 'reason', true) | 687 | await addVideoToBlacklist(servers[0].url, servers[0].accessToken, video1, 'reason', true) |
688 | await waitJobs(servers) | 688 | await waitJobs(servers) |
689 | 689 | ||
690 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 690 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
@@ -694,7 +694,7 @@ describe('Test video playlists', function () { | |||
694 | } | 694 | } |
695 | 695 | ||
696 | { | 696 | { |
697 | await removeVideoFromBlacklist(servers[ 0 ].url, servers[ 0 ].accessToken, video1) | 697 | await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, video1) |
698 | await waitJobs(servers) | 698 | await waitJobs(servers) |
699 | 699 | ||
700 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 700 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
@@ -712,52 +712,52 @@ describe('Test video playlists', function () { | |||
712 | const position = 2 | 712 | const position = 2 |
713 | 713 | ||
714 | { | 714 | { |
715 | await addAccountToAccountBlocklist(servers[ 0 ].url, userAccessTokenServer1, 'root@localhost:' + servers[1].port) | 715 | await addAccountToAccountBlocklist(servers[0].url, userAccessTokenServer1, 'root@localhost:' + servers[1].port) |
716 | await waitJobs(servers) | 716 | await waitJobs(servers) |
717 | 717 | ||
718 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) | 718 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) |
719 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 719 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
720 | 720 | ||
721 | await removeAccountFromAccountBlocklist(servers[ 0 ].url, userAccessTokenServer1, 'root@localhost:' + servers[1].port) | 721 | await removeAccountFromAccountBlocklist(servers[0].url, userAccessTokenServer1, 'root@localhost:' + servers[1].port) |
722 | await waitJobs(servers) | 722 | await waitJobs(servers) |
723 | 723 | ||
724 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 724 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
725 | } | 725 | } |
726 | 726 | ||
727 | { | 727 | { |
728 | await addServerToAccountBlocklist(servers[ 0 ].url, userAccessTokenServer1, 'localhost:' + servers[1].port) | 728 | await addServerToAccountBlocklist(servers[0].url, userAccessTokenServer1, 'localhost:' + servers[1].port) |
729 | await waitJobs(servers) | 729 | await waitJobs(servers) |
730 | 730 | ||
731 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) | 731 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) |
732 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 732 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
733 | 733 | ||
734 | await removeServerFromAccountBlocklist(servers[ 0 ].url, userAccessTokenServer1, 'localhost:' + servers[1].port) | 734 | await removeServerFromAccountBlocklist(servers[0].url, userAccessTokenServer1, 'localhost:' + servers[1].port) |
735 | await waitJobs(servers) | 735 | await waitJobs(servers) |
736 | 736 | ||
737 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 737 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
738 | } | 738 | } |
739 | 739 | ||
740 | { | 740 | { |
741 | await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'root@localhost:' + servers[1].port) | 741 | await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, 'root@localhost:' + servers[1].port) |
742 | await waitJobs(servers) | 742 | await waitJobs(servers) |
743 | 743 | ||
744 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) | 744 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) |
745 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 745 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
746 | 746 | ||
747 | await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'root@localhost:' + servers[1].port) | 747 | await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, 'root@localhost:' + servers[1].port) |
748 | await waitJobs(servers) | 748 | await waitJobs(servers) |
749 | 749 | ||
750 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 750 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
751 | } | 751 | } |
752 | 752 | ||
753 | { | 753 | { |
754 | await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port) | 754 | await addServerToServerBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port) |
755 | await waitJobs(servers) | 755 | await waitJobs(servers) |
756 | 756 | ||
757 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) | 757 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) |
758 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 758 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
759 | 759 | ||
760 | await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port) | 760 | await removeServerFromServerBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port) |
761 | await waitJobs(servers) | 761 | await waitJobs(servers) |
762 | 762 | ||
763 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 763 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
@@ -785,8 +785,8 @@ describe('Test video playlists', function () { | |||
785 | 785 | ||
786 | { | 786 | { |
787 | await reorderVideosPlaylist({ | 787 | await reorderVideosPlaylist({ |
788 | url: servers[ 0 ].url, | 788 | url: servers[0].url, |
789 | token: servers[ 0 ].accessToken, | 789 | token: servers[0].accessToken, |
790 | playlistId: playlistServer1Id, | 790 | playlistId: playlistServer1Id, |
791 | elementAttrs: { | 791 | elementAttrs: { |
792 | startPosition: 2, | 792 | startPosition: 2, |
@@ -813,8 +813,8 @@ describe('Test video playlists', function () { | |||
813 | 813 | ||
814 | { | 814 | { |
815 | await reorderVideosPlaylist({ | 815 | await reorderVideosPlaylist({ |
816 | url: servers[ 0 ].url, | 816 | url: servers[0].url, |
817 | token: servers[ 0 ].accessToken, | 817 | token: servers[0].accessToken, |
818 | playlistId: playlistServer1Id, | 818 | playlistId: playlistServer1Id, |
819 | elementAttrs: { | 819 | elementAttrs: { |
820 | startPosition: 1, | 820 | startPosition: 1, |
@@ -842,8 +842,8 @@ describe('Test video playlists', function () { | |||
842 | 842 | ||
843 | { | 843 | { |
844 | await reorderVideosPlaylist({ | 844 | await reorderVideosPlaylist({ |
845 | url: servers[ 0 ].url, | 845 | url: servers[0].url, |
846 | token: servers[ 0 ].accessToken, | 846 | token: servers[0].accessToken, |
847 | playlistId: playlistServer1Id, | 847 | playlistId: playlistServer1Id, |
848 | elementAttrs: { | 848 | elementAttrs: { |
849 | startPosition: 6, | 849 | startPosition: 6, |
@@ -868,7 +868,7 @@ describe('Test video playlists', function () { | |||
868 | ]) | 868 | ]) |
869 | 869 | ||
870 | for (let i = 1; i <= elements.length; i++) { | 870 | for (let i = 1; i <= elements.length; i++) { |
871 | expect(elements[ i - 1 ].position).to.equal(i) | 871 | expect(elements[i - 1].position).to.equal(i) |
872 | } | 872 | } |
873 | } | 873 | } |
874 | } | 874 | } |
@@ -878,8 +878,8 @@ describe('Test video playlists', function () { | |||
878 | this.timeout(30000) | 878 | this.timeout(30000) |
879 | 879 | ||
880 | await updateVideoPlaylistElement({ | 880 | await updateVideoPlaylistElement({ |
881 | url: servers[ 0 ].url, | 881 | url: servers[0].url, |
882 | token: servers[ 0 ].accessToken, | 882 | token: servers[0].accessToken, |
883 | playlistId: playlistServer1Id, | 883 | playlistId: playlistServer1Id, |
884 | playlistElementId: playlistElementServer1Video4, | 884 | playlistElementId: playlistElementServer1Video4, |
885 | elementAttrs: { | 885 | elementAttrs: { |
@@ -888,8 +888,8 @@ describe('Test video playlists', function () { | |||
888 | }) | 888 | }) |
889 | 889 | ||
890 | await updateVideoPlaylistElement({ | 890 | await updateVideoPlaylistElement({ |
891 | url: servers[ 0 ].url, | 891 | url: servers[0].url, |
892 | token: servers[ 0 ].accessToken, | 892 | token: servers[0].accessToken, |
893 | playlistId: playlistServer1Id, | 893 | playlistId: playlistServer1Id, |
894 | playlistElementId: playlistElementServer1Video5, | 894 | playlistElementId: playlistElementServer1Video5, |
895 | elementAttrs: { | 895 | elementAttrs: { |
@@ -903,62 +903,62 @@ describe('Test video playlists', function () { | |||
903 | const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10) | 903 | const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10) |
904 | const elements: VideoPlaylistElement[] = res.body.data | 904 | const elements: VideoPlaylistElement[] = res.body.data |
905 | 905 | ||
906 | expect(elements[ 0 ].video.name).to.equal('video 3 server 1') | 906 | expect(elements[0].video.name).to.equal('video 3 server 1') |
907 | expect(elements[ 0 ].position).to.equal(1) | 907 | expect(elements[0].position).to.equal(1) |
908 | expect(elements[ 0 ].startTimestamp).to.equal(1) | 908 | expect(elements[0].startTimestamp).to.equal(1) |
909 | expect(elements[ 0 ].stopTimestamp).to.equal(35) | 909 | expect(elements[0].stopTimestamp).to.equal(35) |
910 | 910 | ||
911 | expect(elements[ 5 ].video.name).to.equal('video 4 server 1') | 911 | expect(elements[5].video.name).to.equal('video 4 server 1') |
912 | expect(elements[ 5 ].position).to.equal(6) | 912 | expect(elements[5].position).to.equal(6) |
913 | expect(elements[ 5 ].startTimestamp).to.equal(45) | 913 | expect(elements[5].startTimestamp).to.equal(45) |
914 | expect(elements[ 5 ].stopTimestamp).to.be.null | 914 | expect(elements[5].stopTimestamp).to.be.null |
915 | } | 915 | } |
916 | }) | 916 | }) |
917 | 917 | ||
918 | it('Should check videos existence in my playlist', async function () { | 918 | it('Should check videos existence in my playlist', async function () { |
919 | const videoIds = [ | 919 | const videoIds = [ |
920 | servers[ 0 ].videos[ 0 ].id, | 920 | servers[0].videos[0].id, |
921 | 42000, | 921 | 42000, |
922 | servers[ 0 ].videos[ 3 ].id, | 922 | servers[0].videos[3].id, |
923 | 43000, | 923 | 43000, |
924 | servers[ 0 ].videos[ 4 ].id | 924 | servers[0].videos[4].id |
925 | ] | 925 | ] |
926 | const res = await doVideosExistInMyPlaylist(servers[ 0 ].url, servers[ 0 ].accessToken, videoIds) | 926 | const res = await doVideosExistInMyPlaylist(servers[0].url, servers[0].accessToken, videoIds) |
927 | const obj = res.body as VideoExistInPlaylist | 927 | const obj = res.body as VideoExistInPlaylist |
928 | 928 | ||
929 | { | 929 | { |
930 | const elem = obj[ servers[ 0 ].videos[ 0 ].id ] | 930 | const elem = obj[servers[0].videos[0].id] |
931 | expect(elem).to.have.lengthOf(1) | 931 | expect(elem).to.have.lengthOf(1) |
932 | expect(elem[ 0 ].playlistElementId).to.exist | 932 | expect(elem[0].playlistElementId).to.exist |
933 | expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id) | 933 | expect(elem[0].playlistId).to.equal(playlistServer1Id) |
934 | expect(elem[ 0 ].startTimestamp).to.equal(15) | 934 | expect(elem[0].startTimestamp).to.equal(15) |
935 | expect(elem[ 0 ].stopTimestamp).to.equal(28) | 935 | expect(elem[0].stopTimestamp).to.equal(28) |
936 | } | 936 | } |
937 | 937 | ||
938 | { | 938 | { |
939 | const elem = obj[ servers[ 0 ].videos[ 3 ].id ] | 939 | const elem = obj[servers[0].videos[3].id] |
940 | expect(elem).to.have.lengthOf(1) | 940 | expect(elem).to.have.lengthOf(1) |
941 | expect(elem[ 0 ].playlistElementId).to.equal(playlistElementServer1Video4) | 941 | expect(elem[0].playlistElementId).to.equal(playlistElementServer1Video4) |
942 | expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id) | 942 | expect(elem[0].playlistId).to.equal(playlistServer1Id) |
943 | expect(elem[ 0 ].startTimestamp).to.equal(1) | 943 | expect(elem[0].startTimestamp).to.equal(1) |
944 | expect(elem[ 0 ].stopTimestamp).to.equal(35) | 944 | expect(elem[0].stopTimestamp).to.equal(35) |
945 | } | 945 | } |
946 | 946 | ||
947 | { | 947 | { |
948 | const elem = obj[ servers[ 0 ].videos[ 4 ].id ] | 948 | const elem = obj[servers[0].videos[4].id] |
949 | expect(elem).to.have.lengthOf(1) | 949 | expect(elem).to.have.lengthOf(1) |
950 | expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id) | 950 | expect(elem[0].playlistId).to.equal(playlistServer1Id) |
951 | expect(elem[ 0 ].startTimestamp).to.equal(45) | 951 | expect(elem[0].startTimestamp).to.equal(45) |
952 | expect(elem[ 0 ].stopTimestamp).to.equal(null) | 952 | expect(elem[0].stopTimestamp).to.equal(null) |
953 | } | 953 | } |
954 | 954 | ||
955 | expect(obj[ 42000 ]).to.have.lengthOf(0) | 955 | expect(obj[42000]).to.have.lengthOf(0) |
956 | expect(obj[ 43000 ]).to.have.lengthOf(0) | 956 | expect(obj[43000]).to.have.lengthOf(0) |
957 | }) | 957 | }) |
958 | 958 | ||
959 | it('Should automatically update updatedAt field of playlists', async function () { | 959 | it('Should automatically update updatedAt field of playlists', async function () { |
960 | const server = servers[ 1 ] | 960 | const server = servers[1] |
961 | const videoId = servers[ 1 ].videos[ 5 ].id | 961 | const videoId = servers[1].videos[5].id |
962 | 962 | ||
963 | async function getPlaylistNames () { | 963 | async function getPlaylistNames () { |
964 | const res = await getAccountPlaylistsListWithToken(server.url, server.accessToken, 'root', 0, 5, undefined, '-updatedAt') | 964 | const res = await getAccountPlaylistsListWithToken(server.url, server.accessToken, 'root', 0, 5, undefined, '-updatedAt') |
@@ -974,8 +974,8 @@ describe('Test video playlists', function () { | |||
974 | const element2 = res2.body.videoPlaylistElement.id | 974 | const element2 = res2.body.videoPlaylistElement.id |
975 | 975 | ||
976 | const names1 = await getPlaylistNames() | 976 | const names1 = await getPlaylistNames() |
977 | expect(names1[ 0 ]).to.equal('playlist 3 updated') | 977 | expect(names1[0]).to.equal('playlist 3 updated') |
978 | expect(names1[ 1 ]).to.equal('playlist 2') | 978 | expect(names1[1]).to.equal('playlist 2') |
979 | 979 | ||
980 | await removeVideoFromPlaylist({ | 980 | await removeVideoFromPlaylist({ |
981 | url: server.url, | 981 | url: server.url, |
@@ -985,8 +985,8 @@ describe('Test video playlists', function () { | |||
985 | }) | 985 | }) |
986 | 986 | ||
987 | const names2 = await getPlaylistNames() | 987 | const names2 = await getPlaylistNames() |
988 | expect(names2[ 0 ]).to.equal('playlist 2') | 988 | expect(names2[0]).to.equal('playlist 2') |
989 | expect(names2[ 1 ]).to.equal('playlist 3 updated') | 989 | expect(names2[1]).to.equal('playlist 3 updated') |
990 | 990 | ||
991 | await removeVideoFromPlaylist({ | 991 | await removeVideoFromPlaylist({ |
992 | url: server.url, | 992 | url: server.url, |
@@ -996,23 +996,23 @@ describe('Test video playlists', function () { | |||
996 | }) | 996 | }) |
997 | 997 | ||
998 | const names3 = await getPlaylistNames() | 998 | const names3 = await getPlaylistNames() |
999 | expect(names3[ 0 ]).to.equal('playlist 3 updated') | 999 | expect(names3[0]).to.equal('playlist 3 updated') |
1000 | expect(names3[ 1 ]).to.equal('playlist 2') | 1000 | expect(names3[1]).to.equal('playlist 2') |
1001 | }) | 1001 | }) |
1002 | 1002 | ||
1003 | it('Should delete some elements', async function () { | 1003 | it('Should delete some elements', async function () { |
1004 | this.timeout(30000) | 1004 | this.timeout(30000) |
1005 | 1005 | ||
1006 | await removeVideoFromPlaylist({ | 1006 | await removeVideoFromPlaylist({ |
1007 | url: servers[ 0 ].url, | 1007 | url: servers[0].url, |
1008 | token: servers[ 0 ].accessToken, | 1008 | token: servers[0].accessToken, |
1009 | playlistId: playlistServer1Id, | 1009 | playlistId: playlistServer1Id, |
1010 | playlistElementId: playlistElementServer1Video4 | 1010 | playlistElementId: playlistElementServer1Video4 |
1011 | }) | 1011 | }) |
1012 | 1012 | ||
1013 | await removeVideoFromPlaylist({ | 1013 | await removeVideoFromPlaylist({ |
1014 | url: servers[ 0 ].url, | 1014 | url: servers[0].url, |
1015 | token: servers[ 0 ].accessToken, | 1015 | token: servers[0].accessToken, |
1016 | playlistId: playlistServer1Id, | 1016 | playlistId: playlistServer1Id, |
1017 | playlistElementId: playlistElementNSFW | 1017 | playlistElementId: playlistElementNSFW |
1018 | }) | 1018 | }) |
@@ -1027,17 +1027,17 @@ describe('Test video playlists', function () { | |||
1027 | const elements: VideoPlaylistElement[] = res.body.data | 1027 | const elements: VideoPlaylistElement[] = res.body.data |
1028 | expect(elements).to.have.lengthOf(4) | 1028 | expect(elements).to.have.lengthOf(4) |
1029 | 1029 | ||
1030 | expect(elements[ 0 ].video.name).to.equal('video 0 server 1') | 1030 | expect(elements[0].video.name).to.equal('video 0 server 1') |
1031 | expect(elements[ 0 ].position).to.equal(1) | 1031 | expect(elements[0].position).to.equal(1) |
1032 | 1032 | ||
1033 | expect(elements[ 1 ].video.name).to.equal('video 2 server 3') | 1033 | expect(elements[1].video.name).to.equal('video 2 server 3') |
1034 | expect(elements[ 1 ].position).to.equal(2) | 1034 | expect(elements[1].position).to.equal(2) |
1035 | 1035 | ||
1036 | expect(elements[ 2 ].video.name).to.equal('video 1 server 3') | 1036 | expect(elements[2].video.name).to.equal('video 1 server 3') |
1037 | expect(elements[ 2 ].position).to.equal(3) | 1037 | expect(elements[2].position).to.equal(3) |
1038 | 1038 | ||
1039 | expect(elements[ 3 ].video.name).to.equal('video 4 server 1') | 1039 | expect(elements[3].video.name).to.equal('video 4 server 1') |
1040 | expect(elements[ 3 ].position).to.equal(4) | 1040 | expect(elements[3].position).to.equal(4) |
1041 | } | 1041 | } |
1042 | }) | 1042 | }) |
1043 | 1043 | ||
@@ -1045,12 +1045,12 @@ describe('Test video playlists', function () { | |||
1045 | this.timeout(30000) | 1045 | this.timeout(30000) |
1046 | 1046 | ||
1047 | const res = await createVideoPlaylist({ | 1047 | const res = await createVideoPlaylist({ |
1048 | url: servers[ 0 ].url, | 1048 | url: servers[0].url, |
1049 | token: servers[ 0 ].accessToken, | 1049 | token: servers[0].accessToken, |
1050 | playlistAttrs: { | 1050 | playlistAttrs: { |
1051 | displayName: 'my super public playlist', | 1051 | displayName: 'my super public playlist', |
1052 | privacy: VideoPlaylistPrivacy.PUBLIC, | 1052 | privacy: VideoPlaylistPrivacy.PUBLIC, |
1053 | videoChannelId: servers[ 0 ].videoChannel.id | 1053 | videoChannelId: servers[0].videoChannel.id |
1054 | } | 1054 | } |
1055 | }) | 1055 | }) |
1056 | const videoPlaylistIds = res.body.videoPlaylist | 1056 | const videoPlaylistIds = res.body.videoPlaylist |
@@ -1062,16 +1062,16 @@ describe('Test video playlists', function () { | |||
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | const playlistAttrs = { privacy: VideoPlaylistPrivacy.PRIVATE } | 1064 | const playlistAttrs = { privacy: VideoPlaylistPrivacy.PRIVATE } |
1065 | await updateVideoPlaylist({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, playlistId: videoPlaylistIds.id, playlistAttrs }) | 1065 | await updateVideoPlaylist({ url: servers[0].url, token: servers[0].accessToken, playlistId: videoPlaylistIds.id, playlistAttrs }) |
1066 | 1066 | ||
1067 | await waitJobs(servers) | 1067 | await waitJobs(servers) |
1068 | 1068 | ||
1069 | for (const server of [ servers[ 1 ], servers[ 2 ] ]) { | 1069 | for (const server of [ servers[1], servers[2] ]) { |
1070 | await getVideoPlaylist(server.url, videoPlaylistIds.uuid, 404) | 1070 | await getVideoPlaylist(server.url, videoPlaylistIds.uuid, 404) |
1071 | } | 1071 | } |
1072 | await getVideoPlaylist(servers[ 0 ].url, videoPlaylistIds.uuid, 401) | 1072 | await getVideoPlaylist(servers[0].url, videoPlaylistIds.uuid, 401) |
1073 | 1073 | ||
1074 | await getVideoPlaylistWithToken(servers[ 0 ].url, servers[ 0 ].accessToken, videoPlaylistIds.uuid, 200) | 1074 | await getVideoPlaylistWithToken(servers[0].url, servers[0].accessToken, videoPlaylistIds.uuid, 200) |
1075 | }) | 1075 | }) |
1076 | }) | 1076 | }) |
1077 | 1077 | ||
@@ -1080,7 +1080,7 @@ describe('Test video playlists', function () { | |||
1080 | it('Should delete the playlist on server 1 and delete on server 2 and 3', async function () { | 1080 | it('Should delete the playlist on server 1 and delete on server 2 and 3', async function () { |
1081 | this.timeout(30000) | 1081 | this.timeout(30000) |
1082 | 1082 | ||
1083 | await deleteVideoPlaylist(servers[ 0 ].url, servers[ 0 ].accessToken, playlistServer1Id) | 1083 | await deleteVideoPlaylist(servers[0].url, servers[0].accessToken, playlistServer1Id) |
1084 | 1084 | ||
1085 | await waitJobs(servers) | 1085 | await waitJobs(servers) |
1086 | 1086 | ||
@@ -1103,15 +1103,15 @@ describe('Test video playlists', function () { | |||
1103 | const finder = data => data.find(p => p.displayName === 'my super playlist') | 1103 | const finder = data => data.find(p => p.displayName === 'my super playlist') |
1104 | 1104 | ||
1105 | { | 1105 | { |
1106 | const res = await getVideoPlaylistsList(servers[ 2 ].url, 0, 5) | 1106 | const res = await getVideoPlaylistsList(servers[2].url, 0, 5) |
1107 | expect(res.body.total).to.equal(3) | 1107 | expect(res.body.total).to.equal(3) |
1108 | expect(finder(res.body.data)).to.not.be.undefined | 1108 | expect(finder(res.body.data)).to.not.be.undefined |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | await unfollow(servers[ 2 ].url, servers[ 2 ].accessToken, servers[ 0 ]) | 1111 | await unfollow(servers[2].url, servers[2].accessToken, servers[0]) |
1112 | 1112 | ||
1113 | { | 1113 | { |
1114 | const res = await getVideoPlaylistsList(servers[ 2 ].url, 0, 5) | 1114 | const res = await getVideoPlaylistsList(servers[2].url, 0, 5) |
1115 | expect(res.body.total).to.equal(1) | 1115 | expect(res.body.total).to.equal(1) |
1116 | 1116 | ||
1117 | expect(finder(res.body.data)).to.be.undefined | 1117 | expect(finder(res.body.data)).to.be.undefined |
@@ -1121,12 +1121,12 @@ describe('Test video playlists', function () { | |||
1121 | it('Should delete a channel and put the associated playlist in private mode', async function () { | 1121 | it('Should delete a channel and put the associated playlist in private mode', async function () { |
1122 | this.timeout(30000) | 1122 | this.timeout(30000) |
1123 | 1123 | ||
1124 | const res = await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'super_channel', displayName: 'super channel' }) | 1124 | const res = await addVideoChannel(servers[0].url, servers[0].accessToken, { name: 'super_channel', displayName: 'super channel' }) |
1125 | const videoChannelId = res.body.videoChannel.id | 1125 | const videoChannelId = res.body.videoChannel.id |
1126 | 1126 | ||
1127 | const res2 = await createVideoPlaylist({ | 1127 | const res2 = await createVideoPlaylist({ |
1128 | url: servers[ 0 ].url, | 1128 | url: servers[0].url, |
1129 | token: servers[ 0 ].accessToken, | 1129 | token: servers[0].accessToken, |
1130 | playlistAttrs: { | 1130 | playlistAttrs: { |
1131 | displayName: 'channel playlist', | 1131 | displayName: 'channel playlist', |
1132 | privacy: VideoPlaylistPrivacy.PUBLIC, | 1132 | privacy: VideoPlaylistPrivacy.PUBLIC, |
@@ -1137,15 +1137,15 @@ describe('Test video playlists', function () { | |||
1137 | 1137 | ||
1138 | await waitJobs(servers) | 1138 | await waitJobs(servers) |
1139 | 1139 | ||
1140 | await deleteVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, 'super_channel') | 1140 | await deleteVideoChannel(servers[0].url, servers[0].accessToken, 'super_channel') |
1141 | 1141 | ||
1142 | await waitJobs(servers) | 1142 | await waitJobs(servers) |
1143 | 1143 | ||
1144 | const res3 = await getVideoPlaylistWithToken(servers[ 0 ].url, servers[ 0 ].accessToken, videoPlaylistUUID) | 1144 | const res3 = await getVideoPlaylistWithToken(servers[0].url, servers[0].accessToken, videoPlaylistUUID) |
1145 | expect(res3.body.displayName).to.equal('channel playlist') | 1145 | expect(res3.body.displayName).to.equal('channel playlist') |
1146 | expect(res3.body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE) | 1146 | expect(res3.body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE) |
1147 | 1147 | ||
1148 | await getVideoPlaylist(servers[ 1 ].url, videoPlaylistUUID, 404) | 1148 | await getVideoPlaylist(servers[1].url, videoPlaylistUUID, 404) |
1149 | }) | 1149 | }) |
1150 | 1150 | ||
1151 | it('Should delete an account and delete its playlists', async function () { | 1151 | it('Should delete an account and delete its playlists', async function () { |
@@ -1153,20 +1153,20 @@ describe('Test video playlists', function () { | |||
1153 | 1153 | ||
1154 | const user = { username: 'user_1', password: 'password' } | 1154 | const user = { username: 'user_1', password: 'password' } |
1155 | const res = await createUser({ | 1155 | const res = await createUser({ |
1156 | url: servers[ 0 ].url, | 1156 | url: servers[0].url, |
1157 | accessToken: servers[ 0 ].accessToken, | 1157 | accessToken: servers[0].accessToken, |
1158 | username: user.username, | 1158 | username: user.username, |
1159 | password: user.password | 1159 | password: user.password |
1160 | }) | 1160 | }) |
1161 | 1161 | ||
1162 | const userId = res.body.user.id | 1162 | const userId = res.body.user.id |
1163 | const userAccessToken = await userLogin(servers[ 0 ], user) | 1163 | const userAccessToken = await userLogin(servers[0], user) |
1164 | 1164 | ||
1165 | const resChannel = await getMyUserInformation(servers[ 0 ].url, userAccessToken) | 1165 | const resChannel = await getMyUserInformation(servers[0].url, userAccessToken) |
1166 | const userChannel = (resChannel.body as User).videoChannels[ 0 ] | 1166 | const userChannel = (resChannel.body as User).videoChannels[0] |
1167 | 1167 | ||
1168 | await createVideoPlaylist({ | 1168 | await createVideoPlaylist({ |
1169 | url: servers[ 0 ].url, | 1169 | url: servers[0].url, |
1170 | token: userAccessToken, | 1170 | token: userAccessToken, |
1171 | playlistAttrs: { | 1171 | playlistAttrs: { |
1172 | displayName: 'playlist to be deleted', | 1172 | displayName: 'playlist to be deleted', |
@@ -1180,17 +1180,17 @@ describe('Test video playlists', function () { | |||
1180 | const finder = data => data.find(p => p.displayName === 'playlist to be deleted') | 1180 | const finder = data => data.find(p => p.displayName === 'playlist to be deleted') |
1181 | 1181 | ||
1182 | { | 1182 | { |
1183 | for (const server of [ servers[ 0 ], servers[ 1 ] ]) { | 1183 | for (const server of [ servers[0], servers[1] ]) { |
1184 | const res = await getVideoPlaylistsList(server.url, 0, 15) | 1184 | const res = await getVideoPlaylistsList(server.url, 0, 15) |
1185 | expect(finder(res.body.data)).to.not.be.undefined | 1185 | expect(finder(res.body.data)).to.not.be.undefined |
1186 | } | 1186 | } |
1187 | } | 1187 | } |
1188 | 1188 | ||
1189 | await removeUser(servers[ 0 ].url, userId, servers[ 0 ].accessToken) | 1189 | await removeUser(servers[0].url, userId, servers[0].accessToken) |
1190 | await waitJobs(servers) | 1190 | await waitJobs(servers) |
1191 | 1191 | ||
1192 | { | 1192 | { |
1193 | for (const server of [ servers[ 0 ], servers[ 1 ] ]) { | 1193 | for (const server of [ servers[0], servers[1] ]) { |
1194 | const res = await getVideoPlaylistsList(server.url, 0, 15) | 1194 | const res = await getVideoPlaylistsList(server.url, 0, 15) |
1195 | expect(finder(res.body.data)).to.be.undefined | 1195 | expect(finder(res.body.data)).to.be.undefined |
1196 | } | 1196 | } |
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts index e630ca84a..4bbbb90f3 100644 --- a/server/tests/api/videos/video-privacy.ts +++ b/server/tests/api/videos/video-privacy.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
@@ -6,7 +6,8 @@ import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enu | |||
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | flushAndRunMultipleServers, | 8 | flushAndRunMultipleServers, |
9 | getVideosList, getVideosListWithToken, | 9 | getVideosList, |
10 | getVideosListWithToken, | ||
10 | ServerInfo, | 11 | ServerInfo, |
11 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
12 | uploadVideo | 13 | uploadVideo |
@@ -110,7 +111,7 @@ describe('Test video privacy', function () { | |||
110 | username: 'hello', | 111 | username: 'hello', |
111 | password: 'super password' | 112 | password: 'super password' |
112 | } | 113 | } |
113 | await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password }) | 114 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) |
114 | 115 | ||
115 | anotherUserToken = await userLogin(servers[0], user) | 116 | anotherUserToken = await userLogin(servers[0], user) |
116 | await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, 403) | 117 | await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, 403) |
@@ -174,7 +175,7 @@ describe('Test video privacy', function () { | |||
174 | privacy: VideoPrivacy.PUBLIC | 175 | privacy: VideoPrivacy.PUBLIC |
175 | } | 176 | } |
176 | 177 | ||
177 | await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, privateVideoId, attribute) | 178 | await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, attribute) |
178 | } | 179 | } |
179 | 180 | ||
180 | { | 181 | { |
@@ -182,7 +183,7 @@ describe('Test video privacy', function () { | |||
182 | name: 'internal video becomes public', | 183 | name: 'internal video becomes public', |
183 | privacy: VideoPrivacy.PUBLIC | 184 | privacy: VideoPrivacy.PUBLIC |
184 | } | 185 | } |
185 | await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, internalVideoId, attribute) | 186 | await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, attribute) |
186 | } | 187 | } |
187 | 188 | ||
188 | await waitJobs(servers) | 189 | await waitJobs(servers) |
diff --git a/server/tests/api/videos/video-schedule-update.ts b/server/tests/api/videos/video-schedule-update.ts index 65a8eafb8..204f43611 100644 --- a/server/tests/api/videos/video-schedule-update.ts +++ b/server/tests/api/videos/video-schedule-update.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
@@ -10,7 +10,6 @@ import { | |||
10 | getMyVideos, | 10 | getMyVideos, |
11 | getVideosList, | 11 | getVideosList, |
12 | getVideoWithToken, | 12 | getVideoWithToken, |
13 | killallServers, | ||
14 | ServerInfo, | 13 | ServerInfo, |
15 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
16 | updateVideo, | 15 | updateVideo, |
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 4be74901a..13b3530b1 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts | |||
@@ -1,29 +1,40 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' | 6 | import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' |
7 | import { audio, canDoQuickTranscode, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' | 7 | import { |
8 | audio, | ||
9 | canDoQuickTranscode, | ||
10 | getVideoFileBitrate, | ||
11 | getVideoFileFPS, | ||
12 | getVideoFileResolution, | ||
13 | getMetadataFromFile | ||
14 | } from '../../../helpers/ffmpeg-utils' | ||
8 | import { | 15 | import { |
9 | buildAbsoluteFixturePath, | 16 | buildAbsoluteFixturePath, |
10 | cleanupTests, | 17 | cleanupTests, |
11 | doubleFollow, | 18 | doubleFollow, |
12 | flushAndRunMultipleServers, | 19 | flushAndRunMultipleServers, |
13 | generateHighBitrateVideo, | 20 | generateHighBitrateVideo, |
21 | generateVideoWithFramerate, | ||
14 | getMyVideos, | 22 | getMyVideos, |
15 | getVideo, | 23 | getVideo, |
24 | getVideoFileMetadataUrl, | ||
16 | getVideosList, | 25 | getVideosList, |
17 | makeGetRequest, | 26 | makeGetRequest, |
18 | root, | 27 | root, |
19 | ServerInfo, | 28 | ServerInfo, |
20 | setAccessTokensToServers, | 29 | setAccessTokensToServers, |
21 | uploadVideo, | 30 | uploadVideo, uploadVideoAndGetId, |
22 | waitJobs, | 31 | waitJobs, |
23 | webtorrentAdd | 32 | webtorrentAdd |
24 | } from '../../../../shared/extra-utils' | 33 | } from '../../../../shared/extra-utils' |
25 | import { join } from 'path' | 34 | import { join } from 'path' |
26 | import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' | 35 | import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' |
36 | import { FfprobeData } from 'fluent-ffmpeg' | ||
37 | import { VideoFileMetadata } from '@shared/models/videos/video-file-metadata' | ||
27 | 38 | ||
28 | const expect = chai.expect | 39 | const expect = chai.expect |
29 | 40 | ||
@@ -55,19 +66,19 @@ describe('Test video transcoding', function () { | |||
55 | 66 | ||
56 | for (const server of servers) { | 67 | for (const server of servers) { |
57 | const res = await getVideosList(server.url) | 68 | const res = await getVideosList(server.url) |
58 | const video = res.body.data[ 0 ] | 69 | const video = res.body.data[0] |
59 | 70 | ||
60 | const res2 = await getVideo(server.url, video.id) | 71 | const res2 = await getVideo(server.url, video.id) |
61 | const videoDetails = res2.body | 72 | const videoDetails = res2.body |
62 | expect(videoDetails.files).to.have.lengthOf(1) | 73 | expect(videoDetails.files).to.have.lengthOf(1) |
63 | 74 | ||
64 | const magnetUri = videoDetails.files[ 0 ].magnetUri | 75 | const magnetUri = videoDetails.files[0].magnetUri |
65 | expect(magnetUri).to.match(/\.webm/) | 76 | expect(magnetUri).to.match(/\.webm/) |
66 | 77 | ||
67 | const torrent = await webtorrentAdd(magnetUri, true) | 78 | const torrent = await webtorrentAdd(magnetUri, true) |
68 | expect(torrent.files).to.be.an('array') | 79 | expect(torrent.files).to.be.an('array') |
69 | expect(torrent.files.length).to.equal(1) | 80 | expect(torrent.files.length).to.equal(1) |
70 | expect(torrent.files[ 0 ].path).match(/\.webm$/) | 81 | expect(torrent.files[0].path).match(/\.webm$/) |
71 | } | 82 | } |
72 | }) | 83 | }) |
73 | 84 | ||
@@ -92,13 +103,13 @@ describe('Test video transcoding', function () { | |||
92 | 103 | ||
93 | expect(videoDetails.files).to.have.lengthOf(4) | 104 | expect(videoDetails.files).to.have.lengthOf(4) |
94 | 105 | ||
95 | const magnetUri = videoDetails.files[ 0 ].magnetUri | 106 | const magnetUri = videoDetails.files[0].magnetUri |
96 | expect(magnetUri).to.match(/\.mp4/) | 107 | expect(magnetUri).to.match(/\.mp4/) |
97 | 108 | ||
98 | const torrent = await webtorrentAdd(magnetUri, true) | 109 | const torrent = await webtorrentAdd(magnetUri, true) |
99 | expect(torrent.files).to.be.an('array') | 110 | expect(torrent.files).to.be.an('array') |
100 | expect(torrent.files.length).to.equal(1) | 111 | expect(torrent.files.length).to.equal(1) |
101 | expect(torrent.files[ 0 ].path).match(/\.mp4$/) | 112 | expect(torrent.files[0].path).match(/\.mp4$/) |
102 | } | 113 | } |
103 | }) | 114 | }) |
104 | 115 | ||
@@ -126,8 +137,8 @@ describe('Test video transcoding', function () { | |||
126 | const probe = await audio.get(path) | 137 | const probe = await audio.get(path) |
127 | 138 | ||
128 | if (probe.audioStream) { | 139 | if (probe.audioStream) { |
129 | expect(probe.audioStream[ 'codec_name' ]).to.be.equal('aac') | 140 | expect(probe.audioStream['codec_name']).to.be.equal('aac') |
130 | expect(probe.audioStream[ 'bit_rate' ]).to.be.at.most(384 * 8000) | 141 | expect(probe.audioStream['bit_rate']).to.be.at.most(384 * 8000) |
131 | } else { | 142 | } else { |
132 | this.fail('Could not retrieve the audio stream on ' + probe.absolutePath) | 143 | this.fail('Could not retrieve the audio stream on ' + probe.absolutePath) |
133 | } | 144 | } |
@@ -211,10 +222,10 @@ describe('Test video transcoding', function () { | |||
211 | const videoDetails: VideoDetails = res2.body | 222 | const videoDetails: VideoDetails = res2.body |
212 | 223 | ||
213 | expect(videoDetails.files).to.have.lengthOf(4) | 224 | expect(videoDetails.files).to.have.lengthOf(4) |
214 | expect(videoDetails.files[ 0 ].fps).to.be.above(58).and.below(62) | 225 | expect(videoDetails.files[0].fps).to.be.above(58).and.below(62) |
215 | expect(videoDetails.files[ 1 ].fps).to.be.below(31) | 226 | expect(videoDetails.files[1].fps).to.be.below(31) |
216 | expect(videoDetails.files[ 2 ].fps).to.be.below(31) | 227 | expect(videoDetails.files[2].fps).to.be.below(31) |
217 | expect(videoDetails.files[ 3 ].fps).to.be.below(31) | 228 | expect(videoDetails.files[3].fps).to.be.below(31) |
218 | 229 | ||
219 | for (const resolution of [ '240', '360', '480' ]) { | 230 | for (const resolution of [ '240', '360', '480' ]) { |
220 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4') | 231 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4') |
@@ -240,11 +251,11 @@ describe('Test video transcoding', function () { | |||
240 | fixture: 'video_short1.webm', | 251 | fixture: 'video_short1.webm', |
241 | waitTranscoding: true | 252 | waitTranscoding: true |
242 | } | 253 | } |
243 | const resVideo = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributes) | 254 | const resVideo = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) |
244 | const videoId = resVideo.body.video.uuid | 255 | const videoId = resVideo.body.video.uuid |
245 | 256 | ||
246 | // Should be in transcode state | 257 | // Should be in transcode state |
247 | const { body } = await getVideo(servers[ 1 ].url, videoId) | 258 | const { body } = await getVideo(servers[1].url, videoId) |
248 | expect(body.name).to.equal('waiting video') | 259 | expect(body.name).to.equal('waiting video') |
249 | expect(body.state.id).to.equal(VideoState.TO_TRANSCODE) | 260 | expect(body.state.id).to.equal(VideoState.TO_TRANSCODE) |
250 | expect(body.state.label).to.equal('To transcode') | 261 | expect(body.state.label).to.equal('To transcode') |
@@ -310,7 +321,7 @@ describe('Test video transcoding', function () { | |||
310 | 321 | ||
311 | const video = res.body.data.find(v => v.name === videoAttributes.name) | 322 | const video = res.body.data.find(v => v.name === videoAttributes.name) |
312 | 323 | ||
313 | for (const resolution of ['240', '360', '480', '720', '1080']) { | 324 | for (const resolution of [ '240', '360', '480', '720', '1080' ]) { |
314 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4') | 325 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4') |
315 | const bitrate = await getVideoFileBitrate(path) | 326 | const bitrate = await getVideoFileBitrate(path) |
316 | const fps = await getVideoFileFPS(path) | 327 | const fps = await getVideoFileFPS(path) |
@@ -340,7 +351,7 @@ describe('Test video transcoding', function () { | |||
340 | fixture | 351 | fixture |
341 | } | 352 | } |
342 | 353 | ||
343 | await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributes) | 354 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) |
344 | 355 | ||
345 | await waitJobs(servers) | 356 | await waitJobs(servers) |
346 | 357 | ||
@@ -353,7 +364,7 @@ describe('Test video transcoding', function () { | |||
353 | 364 | ||
354 | expect(videoDetails.files).to.have.lengthOf(4) | 365 | expect(videoDetails.files).to.have.lengthOf(4) |
355 | 366 | ||
356 | const magnetUri = videoDetails.files[ 0 ].magnetUri | 367 | const magnetUri = videoDetails.files[0].magnetUri |
357 | expect(magnetUri).to.contain('.mp4') | 368 | expect(magnetUri).to.contain('.mp4') |
358 | } | 369 | } |
359 | } | 370 | } |
@@ -370,7 +381,7 @@ describe('Test video transcoding', function () { | |||
370 | this.timeout(60000) | 381 | this.timeout(60000) |
371 | 382 | ||
372 | const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' } | 383 | const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' } |
373 | await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributesArg) | 384 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg) |
374 | 385 | ||
375 | await waitJobs(servers) | 386 | await waitJobs(servers) |
376 | 387 | ||
@@ -386,7 +397,7 @@ describe('Test video transcoding', function () { | |||
386 | await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: 200 }) | 397 | await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: 200 }) |
387 | await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: 200 }) | 398 | await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: 200 }) |
388 | 399 | ||
389 | const magnetUri = videoDetails.files[ 0 ].magnetUri | 400 | const magnetUri = videoDetails.files[0].magnetUri |
390 | expect(magnetUri).to.contain('.mp4') | 401 | expect(magnetUri).to.contain('.mp4') |
391 | } | 402 | } |
392 | }) | 403 | }) |
@@ -395,7 +406,7 @@ describe('Test video transcoding', function () { | |||
395 | this.timeout(60000) | 406 | this.timeout(60000) |
396 | 407 | ||
397 | const videoAttributesArg = { name: 'audio_without_preview', fixture: 'sample.ogg' } | 408 | const videoAttributesArg = { name: 'audio_without_preview', fixture: 'sample.ogg' } |
398 | await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributesArg) | 409 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg) |
399 | 410 | ||
400 | await waitJobs(servers) | 411 | await waitJobs(servers) |
401 | 412 | ||
@@ -411,11 +422,109 @@ describe('Test video transcoding', function () { | |||
411 | await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: 200 }) | 422 | await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: 200 }) |
412 | await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: 200 }) | 423 | await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: 200 }) |
413 | 424 | ||
414 | const magnetUri = videoDetails.files[ 0 ].magnetUri | 425 | const magnetUri = videoDetails.files[0].magnetUri |
415 | expect(magnetUri).to.contain('.mp4') | 426 | expect(magnetUri).to.contain('.mp4') |
416 | } | 427 | } |
417 | }) | 428 | }) |
418 | 429 | ||
430 | it('Should downscale to the closest divisor standard framerate', async function () { | ||
431 | this.timeout(160000) | ||
432 | |||
433 | let tempFixturePath: string | ||
434 | |||
435 | { | ||
436 | tempFixturePath = await generateVideoWithFramerate(59) | ||
437 | |||
438 | const fps = await getVideoFileFPS(tempFixturePath) | ||
439 | expect(fps).to.be.equal(59) | ||
440 | } | ||
441 | |||
442 | const videoAttributes = { | ||
443 | name: '59fps video', | ||
444 | description: '59fps video', | ||
445 | fixture: tempFixturePath | ||
446 | } | ||
447 | |||
448 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) | ||
449 | |||
450 | await waitJobs(servers) | ||
451 | |||
452 | for (const server of servers) { | ||
453 | const res = await getVideosList(server.url) | ||
454 | |||
455 | const video = res.body.data.find(v => v.name === videoAttributes.name) | ||
456 | |||
457 | { | ||
458 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') | ||
459 | const fps = await getVideoFileFPS(path) | ||
460 | expect(fps).to.be.equal(25) | ||
461 | } | ||
462 | |||
463 | { | ||
464 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-720.mp4') | ||
465 | const fps = await getVideoFileFPS(path) | ||
466 | expect(fps).to.be.equal(59) | ||
467 | } | ||
468 | } | ||
469 | }) | ||
470 | |||
471 | it('Should provide valid ffprobe data', async function () { | ||
472 | this.timeout(160000) | ||
473 | |||
474 | const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'ffprobe data' })).uuid | ||
475 | await waitJobs(servers) | ||
476 | |||
477 | { | ||
478 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', videoUUID + '-240.mp4') | ||
479 | const metadata = await getMetadataFromFile<VideoFileMetadata>(path) | ||
480 | |||
481 | // expected format properties | ||
482 | for (const p of [ | ||
483 | 'tags.encoder', | ||
484 | 'format_long_name', | ||
485 | 'size', | ||
486 | 'bit_rate' | ||
487 | ]) { | ||
488 | expect(metadata.format).to.have.nested.property(p) | ||
489 | } | ||
490 | |||
491 | // expected stream properties | ||
492 | for (const p of [ | ||
493 | 'codec_long_name', | ||
494 | 'profile', | ||
495 | 'width', | ||
496 | 'height', | ||
497 | 'display_aspect_ratio', | ||
498 | 'avg_frame_rate', | ||
499 | 'pix_fmt' | ||
500 | ]) { | ||
501 | expect(metadata.streams[0]).to.have.nested.property(p) | ||
502 | } | ||
503 | |||
504 | expect(metadata).to.not.have.nested.property('format.filename') | ||
505 | } | ||
506 | |||
507 | for (const server of servers) { | ||
508 | const res2 = await getVideo(server.url, videoUUID) | ||
509 | const videoDetails: VideoDetails = res2.body | ||
510 | |||
511 | const videoFiles = videoDetails.files | ||
512 | .concat(videoDetails.streamingPlaylists[0].files) | ||
513 | expect(videoFiles).to.have.lengthOf(8) | ||
514 | |||
515 | for (const file of videoFiles) { | ||
516 | expect(file.metadata).to.be.undefined | ||
517 | expect(file.metadataUrl).to.exist | ||
518 | expect(file.metadataUrl).to.contain(servers[1].url) | ||
519 | expect(file.metadataUrl).to.contain(videoUUID) | ||
520 | |||
521 | const res3 = await getVideoFileMetadataUrl(file.metadataUrl) | ||
522 | const metadata: FfprobeData = res3.body | ||
523 | expect(metadata).to.have.nested.property('format.size') | ||
524 | } | ||
525 | } | ||
526 | }) | ||
527 | |||
419 | after(async function () { | 528 | after(async function () { |
420 | await cleanupTests(servers) | 529 | await cleanupTests(servers) |
421 | }) | 530 | }) |
diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts index e1e65260f..95e12e43c 100644 --- a/server/tests/api/videos/videos-filter.ts +++ b/server/tests/api/videos/videos-filter.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
@@ -7,8 +7,6 @@ import { | |||
7 | createUser, | 7 | createUser, |
8 | doubleFollow, | 8 | doubleFollow, |
9 | flushAndRunMultipleServers, | 9 | flushAndRunMultipleServers, |
10 | flushTests, | ||
11 | killallServers, | ||
12 | makeGetRequest, | 10 | makeGetRequest, |
13 | ServerInfo, | 11 | ServerInfo, |
14 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
@@ -98,7 +96,7 @@ describe('Test videos filter validator', function () { | |||
98 | const namesResults = await getVideosNames(server, server.accessToken, 'local') | 96 | const namesResults = await getVideosNames(server, server.accessToken, 'local') |
99 | for (const names of namesResults) { | 97 | for (const names of namesResults) { |
100 | expect(names).to.have.lengthOf(1) | 98 | expect(names).to.have.lengthOf(1) |
101 | expect(names[ 0 ]).to.equal('public ' + server.serverNumber) | 99 | expect(names[0]).to.equal('public ' + server.serverNumber) |
102 | } | 100 | } |
103 | } | 101 | } |
104 | }) | 102 | }) |
@@ -111,9 +109,9 @@ describe('Test videos filter validator', function () { | |||
111 | for (const names of namesResults) { | 109 | for (const names of namesResults) { |
112 | expect(names).to.have.lengthOf(3) | 110 | expect(names).to.have.lengthOf(3) |
113 | 111 | ||
114 | expect(names[ 0 ]).to.equal('public ' + server.serverNumber) | 112 | expect(names[0]).to.equal('public ' + server.serverNumber) |
115 | expect(names[ 1 ]).to.equal('unlisted ' + server.serverNumber) | 113 | expect(names[1]).to.equal('unlisted ' + server.serverNumber) |
116 | expect(names[ 2 ]).to.equal('private ' + server.serverNumber) | 114 | expect(names[2]).to.equal('private ' + server.serverNumber) |
117 | } | 115 | } |
118 | } | 116 | } |
119 | } | 117 | } |
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts index c7e55c1ab..6f90e9a57 100644 --- a/server/tests/api/videos/videos-history.ts +++ b/server/tests/api/videos/videos-history.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts index 975a5c87a..d38bcb6eb 100644 --- a/server/tests/api/videos/videos-overview.ts +++ b/server/tests/api/videos/videos-overview.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils' | 5 | import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo, wait } from '../../../../shared/extra-utils' |
6 | import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews' | 6 | import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews' |
7 | import { VideosOverview } from '../../../../shared/models/overviews' | 7 | import { VideosOverview } from '../../../../shared/models/overviews' |
8 | 8 | ||
@@ -20,7 +20,7 @@ describe('Test a videos overview', function () { | |||
20 | }) | 20 | }) |
21 | 21 | ||
22 | it('Should send empty overview', async function () { | 22 | it('Should send empty overview', async function () { |
23 | const res = await getVideosOverview(server.url) | 23 | const res = await getVideosOverview(server.url, 1) |
24 | 24 | ||
25 | const overview: VideosOverview = res.body | 25 | const overview: VideosOverview = res.body |
26 | expect(overview.tags).to.have.lengthOf(0) | 26 | expect(overview.tags).to.have.lengthOf(0) |
@@ -31,15 +31,15 @@ describe('Test a videos overview', function () { | |||
31 | it('Should upload 5 videos in a specific category, tag and channel but not include them in overview', async function () { | 31 | it('Should upload 5 videos in a specific category, tag and channel but not include them in overview', async function () { |
32 | this.timeout(15000) | 32 | this.timeout(15000) |
33 | 33 | ||
34 | for (let i = 0; i < 5; i++) { | 34 | await wait(3000) |
35 | await uploadVideo(server.url, server.accessToken, { | 35 | |
36 | name: 'video ' + i, | 36 | await uploadVideo(server.url, server.accessToken, { |
37 | category: 3, | 37 | name: 'video 0', |
38 | tags: [ 'coucou1', 'coucou2' ] | 38 | category: 3, |
39 | }) | 39 | tags: [ 'coucou1', 'coucou2' ] |
40 | } | 40 | }) |
41 | 41 | ||
42 | const res = await getVideosOverview(server.url) | 42 | const res = await getVideosOverview(server.url, 1) |
43 | 43 | ||
44 | const overview: VideosOverview = res.body | 44 | const overview: VideosOverview = res.body |
45 | expect(overview.tags).to.have.lengthOf(0) | 45 | expect(overview.tags).to.have.lengthOf(0) |
@@ -48,27 +48,55 @@ describe('Test a videos overview', function () { | |||
48 | }) | 48 | }) |
49 | 49 | ||
50 | it('Should upload another video and include all videos in the overview', async function () { | 50 | it('Should upload another video and include all videos in the overview', async function () { |
51 | await uploadVideo(server.url, server.accessToken, { | 51 | this.timeout(15000) |
52 | name: 'video 5', | ||
53 | category: 3, | ||
54 | tags: [ 'coucou1', 'coucou2' ] | ||
55 | }) | ||
56 | 52 | ||
57 | const res = await getVideosOverview(server.url) | 53 | for (let i = 1; i < 6; i++) { |
54 | await uploadVideo(server.url, server.accessToken, { | ||
55 | name: 'video ' + i, | ||
56 | category: 3, | ||
57 | tags: [ 'coucou1', 'coucou2' ] | ||
58 | }) | ||
59 | } | ||
58 | 60 | ||
59 | const overview: VideosOverview = res.body | 61 | await wait(3000) |
60 | expect(overview.tags).to.have.lengthOf(2) | 62 | |
61 | expect(overview.categories).to.have.lengthOf(1) | 63 | { |
62 | expect(overview.channels).to.have.lengthOf(1) | 64 | const res = await getVideosOverview(server.url, 1) |
65 | |||
66 | const overview: VideosOverview = res.body | ||
67 | expect(overview.tags).to.have.lengthOf(1) | ||
68 | expect(overview.categories).to.have.lengthOf(1) | ||
69 | expect(overview.channels).to.have.lengthOf(1) | ||
70 | } | ||
71 | |||
72 | { | ||
73 | const res = await getVideosOverview(server.url, 2) | ||
74 | |||
75 | const overview: VideosOverview = res.body | ||
76 | expect(overview.tags).to.have.lengthOf(1) | ||
77 | expect(overview.categories).to.have.lengthOf(0) | ||
78 | expect(overview.channels).to.have.lengthOf(0) | ||
79 | } | ||
63 | }) | 80 | }) |
64 | 81 | ||
65 | it('Should have the correct overview', async function () { | 82 | it('Should have the correct overview', async function () { |
66 | const res = await getVideosOverview(server.url) | 83 | const res1 = await getVideosOverview(server.url, 1) |
84 | const res2 = await getVideosOverview(server.url, 2) | ||
67 | 85 | ||
68 | const overview: VideosOverview = res.body | 86 | const overview1: VideosOverview = res1.body |
87 | const overview2: VideosOverview = res2.body | ||
88 | |||
89 | const tmp = [ | ||
90 | overview1.tags, | ||
91 | overview1.categories, | ||
92 | overview1.channels, | ||
93 | overview2.tags | ||
94 | ] | ||
95 | |||
96 | for (const arr of tmp) { | ||
97 | expect(arr).to.have.lengthOf(1) | ||
69 | 98 | ||
70 | for (const attr of [ 'tags', 'categories', 'channels' ]) { | 99 | const obj = arr[0] |
71 | const obj = overview[attr][0] | ||
72 | 100 | ||
73 | expect(obj.videos).to.have.lengthOf(6) | 101 | expect(obj.videos).to.have.lengthOf(6) |
74 | expect(obj.videos[0].name).to.equal('video 5') | 102 | expect(obj.videos[0].name).to.equal('video 5') |
@@ -79,12 +107,13 @@ describe('Test a videos overview', function () { | |||
79 | expect(obj.videos[5].name).to.equal('video 0') | 107 | expect(obj.videos[5].name).to.equal('video 0') |
80 | } | 108 | } |
81 | 109 | ||
82 | expect(overview.tags.find(t => t.tag === 'coucou1')).to.not.be.undefined | 110 | const tags = [ overview1.tags[0].tag, overview2.tags[0].tag ] |
83 | expect(overview.tags.find(t => t.tag === 'coucou2')).to.not.be.undefined | 111 | expect(tags.find(t => t === 'coucou1')).to.not.be.undefined |
112 | expect(tags.find(t => t === 'coucou2')).to.not.be.undefined | ||
84 | 113 | ||
85 | expect(overview.categories[0].category.id).to.equal(3) | 114 | expect(overview1.categories[0].category.id).to.equal(3) |
86 | 115 | ||
87 | expect(overview.channels[0].channel.name).to.equal('root_channel') | 116 | expect(overview1.channels[0].channel.name).to.equal('root_channel') |
88 | }) | 117 | }) |
89 | 118 | ||
90 | after(async function () { | 119 | after(async function () { |
diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts index fbddd40f4..d063d7973 100644 --- a/server/tests/api/videos/videos-views-cleaner.ts +++ b/server/tests/api/videos/videos-views-cleaner.ts | |||
@@ -1,20 +1,22 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { | 5 | import { |
6 | cleanupTests, | ||
7 | closeAllSequelize, | ||
8 | countVideoViewsOf, | ||
9 | doubleFollow, | ||
6 | flushAndRunMultipleServers, | 10 | flushAndRunMultipleServers, |
7 | flushTests, | ||
8 | killallServers, | 11 | killallServers, |
9 | reRunServer, | 12 | reRunServer, |
10 | flushAndRunServer, | ||
11 | ServerInfo, | 13 | ServerInfo, |
12 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
13 | uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests, closeAllSequelize | 15 | uploadVideoAndGetId, |
16 | viewVideo, | ||
17 | wait, | ||
18 | waitJobs | ||
14 | } from '../../../../shared/extra-utils' | 19 | } from '../../../../shared/extra-utils' |
15 | import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews' | ||
16 | import { VideosOverview } from '../../../../shared/models/overviews' | ||
17 | import { listMyVideosHistory } from '../../../../shared/extra-utils/videos/video-history' | ||
18 | 20 | ||
19 | const expect = chai.expect | 21 | const expect = chai.expect |
20 | 22 | ||