]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
0e1dc3e7 | 2 | |
d50acfab | 3 | import 'mocha' |
2b02c520 | 4 | import * as chai from 'chai' |
f595d394 | 5 | import * as request from 'supertest' |
12edc149 | 6 | import { HttpStatusCode } from '@shared/core-utils' |
0e1dc3e7 | 7 | import { |
3d470a53 | 8 | buildAbsoluteFixturePath, |
89231874 | 9 | checkTmpIsEmpty, |
7243f84d C |
10 | checkVideoFilesWereRemoved, |
11 | cleanupTests, | |
b64c950a C |
12 | completeVideoCheck, |
13 | createUser, | |
14 | dateIsValid, | |
15 | doubleFollow, | |
16 | flushAndRunMultipleServers, | |
3cd0734f | 17 | getLocalVideos, |
b64c950a | 18 | getVideo, |
b64c950a | 19 | getVideosList, |
b64c950a C |
20 | rateVideo, |
21 | removeVideo, | |
22 | ServerInfo, | |
23 | setAccessTokensToServers, | |
24 | testImage, | |
25 | updateVideo, | |
26 | uploadVideo, | |
b64c950a C |
27 | viewVideo, |
28 | wait, | |
12edc149 | 29 | waitJobs, |
b64c950a | 30 | webtorrentAdd |
12edc149 C |
31 | } from '@shared/extra-utils' |
32 | import { VideoCommentThreadTree, VideoPrivacy } from '@shared/models' | |
0e1dc3e7 C |
33 | |
34 | const expect = chai.expect | |
35 | ||
9a27cdc2 | 36 | describe('Test multiple servers', function () { |
0e1dc3e7 C |
37 | let servers: ServerInfo[] = [] |
38 | const toRemove = [] | |
39 | let videoUUID = '' | |
5f04dd2f | 40 | let videoChannelId: number |
0e1dc3e7 C |
41 | |
42 | before(async function () { | |
43 | this.timeout(120000) | |
44 | ||
45 | servers = await flushAndRunMultipleServers(3) | |
46 | ||
47 | // Get the access tokens | |
48 | await setAccessTokensToServers(servers) | |
49 | ||
48dce1c9 C |
50 | { |
51 | const videoChannel = { | |
8a19bee1 | 52 | name: 'super_channel_name', |
08c1efbe | 53 | displayName: 'my channel', |
48dce1c9 C |
54 | description: 'super channel' |
55 | } | |
a5461888 C |
56 | await servers[0].channelsCommand.create({ attributes: videoChannel }) |
57 | const { data } = await servers[0].channelsCommand.list({ start: 0, count: 1 }) | |
58 | videoChannelId = data[0].id | |
5f04dd2f | 59 | } |
5f04dd2f | 60 | |
9a27cdc2 C |
61 | // Server 1 and server 2 follow each other |
62 | await doubleFollow(servers[0], servers[1]) | |
63 | // Server 1 and server 3 follow each other | |
64 | await doubleFollow(servers[0], servers[2]) | |
65 | // Server 2 and server 3 follow each other | |
66 | await doubleFollow(servers[1], servers[2]) | |
0e1dc3e7 C |
67 | }) |
68 | ||
9a27cdc2 | 69 | it('Should not have videos for all servers', async function () { |
0e1dc3e7 C |
70 | for (const server of servers) { |
71 | const res = await getVideosList(server.url) | |
72 | const videos = res.body.data | |
73 | expect(videos).to.be.an('array') | |
74 | expect(videos.length).to.equal(0) | |
75 | } | |
76 | }) | |
77 | ||
9a27cdc2 C |
78 | describe('Should upload the video and propagate on each server', function () { |
79 | it('Should upload the video on server 1 and propagate on each server', async function () { | |
652b3056 | 80 | this.timeout(25000) |
0e1dc3e7 C |
81 | |
82 | const videoAttributes = { | |
9a27cdc2 | 83 | name: 'my super name for server 1', |
0e1dc3e7 C |
84 | category: 5, |
85 | licence: 4, | |
9d3ef9fe | 86 | language: 'ja', |
0e1dc3e7 | 87 | nsfw: true, |
9a27cdc2 | 88 | description: 'my super description for server 1', |
2422c46b | 89 | support: 'my super support text for server 1', |
7519127b | 90 | originallyPublishedAt: '2019-02-10T13:38:14.449Z', |
0e1dc3e7 | 91 | tags: [ 'tag1p1', 'tag2p1' ], |
5f04dd2f | 92 | channelId: videoChannelId, |
0e1dc3e7 C |
93 | fixture: 'video_short1.webm' |
94 | } | |
95 | await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) | |
96 | ||
3cd0734f | 97 | await waitJobs(servers) |
0e1dc3e7 | 98 | |
9a27cdc2 | 99 | // All servers should have this video |
53a61317 | 100 | let publishedAt: string = null |
0e1dc3e7 | 101 | for (const server of servers) { |
48f07b4a | 102 | const isLocal = server.port === servers[0].port |
b1f5b93e C |
103 | const checkAttributes = { |
104 | name: 'my super name for server 1', | |
105 | category: 5, | |
106 | licence: 4, | |
9d3ef9fe | 107 | language: 'ja', |
b1f5b93e C |
108 | nsfw: true, |
109 | description: 'my super description for server 1', | |
2422c46b | 110 | support: 'my super support text for server 1', |
7519127b | 111 | originallyPublishedAt: '2019-02-10T13:38:14.449Z', |
b64c950a C |
112 | account: { |
113 | name: 'root', | |
7243f84d | 114 | host: 'localhost:' + servers[0].port |
b64c950a | 115 | }, |
b1f5b93e | 116 | isLocal, |
53a61317 | 117 | publishedAt, |
b1f5b93e C |
118 | duration: 10, |
119 | tags: [ 'tag1p1', 'tag2p1' ], | |
120 | privacy: VideoPrivacy.PUBLIC, | |
47564bbe | 121 | commentsEnabled: true, |
7f2cfe3a | 122 | downloadEnabled: true, |
b1f5b93e | 123 | channel: { |
f6eebcb3 C |
124 | displayName: 'my channel', |
125 | name: 'super_channel_name', | |
b1f5b93e C |
126 | description: 'super channel', |
127 | isLocal | |
128 | }, | |
8b0d42ee | 129 | fixture: 'video_short1.webm', |
b1f5b93e C |
130 | files: [ |
131 | { | |
132 | resolution: 720, | |
133 | size: 572456 | |
134 | } | |
135 | ] | |
136 | } | |
0e1dc3e7 C |
137 | |
138 | const res = await getVideosList(server.url) | |
0e1dc3e7 C |
139 | const videos = res.body.data |
140 | expect(videos).to.be.an('array') | |
141 | expect(videos.length).to.equal(1) | |
142 | const video = videos[0] | |
0e1dc3e7 | 143 | |
b1f5b93e | 144 | await completeVideoCheck(server.url, video, checkAttributes) |
53a61317 | 145 | publishedAt = video.publishedAt |
0e1dc3e7 C |
146 | } |
147 | }) | |
148 | ||
9a27cdc2 | 149 | it('Should upload the video on server 2 and propagate on each server', async function () { |
f1273314 | 150 | this.timeout(100000) |
0e1dc3e7 | 151 | |
5f04dd2f C |
152 | const user = { |
153 | username: 'user1', | |
154 | password: 'super_password' | |
155 | } | |
a1587156 | 156 | await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) |
41d1d075 | 157 | const userAccessToken = await servers[1].loginCommand.getAccessToken(user) |
5f04dd2f | 158 | |
0e1dc3e7 | 159 | const videoAttributes = { |
9a27cdc2 | 160 | name: 'my super name for server 2', |
0e1dc3e7 C |
161 | category: 4, |
162 | licence: 3, | |
9d3ef9fe | 163 | language: 'de', |
0e1dc3e7 | 164 | nsfw: true, |
9a27cdc2 | 165 | description: 'my super description for server 2', |
2422c46b | 166 | support: 'my super support text for server 2', |
0e1dc3e7 | 167 | tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ], |
ac81d1a0 C |
168 | fixture: 'video_short2.webm', |
169 | thumbnailfile: 'thumbnail.jpg', | |
170 | previewfile: 'preview.jpg' | |
0e1dc3e7 | 171 | } |
f6d6e7f8 | 172 | await uploadVideo(servers[1].url, userAccessToken, videoAttributes, HttpStatusCode.OK_200, 'resumable') |
0e1dc3e7 | 173 | |
572f8d3d | 174 | // Transcoding |
3cd0734f | 175 | await waitJobs(servers) |
0e1dc3e7 | 176 | |
9a27cdc2 | 177 | // All servers should have this video |
0e1dc3e7 | 178 | for (const server of servers) { |
7243f84d | 179 | const isLocal = server.url === 'http://localhost:' + servers[1].port |
b1f5b93e C |
180 | const checkAttributes = { |
181 | name: 'my super name for server 2', | |
182 | category: 4, | |
183 | licence: 3, | |
9d3ef9fe | 184 | language: 'de', |
b1f5b93e C |
185 | nsfw: true, |
186 | description: 'my super description for server 2', | |
2422c46b | 187 | support: 'my super support text for server 2', |
b64c950a C |
188 | account: { |
189 | name: 'user1', | |
7243f84d | 190 | host: 'localhost:' + servers[1].port |
b64c950a | 191 | }, |
b1f5b93e | 192 | isLocal, |
47564bbe | 193 | commentsEnabled: true, |
7f2cfe3a | 194 | downloadEnabled: true, |
b1f5b93e C |
195 | duration: 5, |
196 | tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ], | |
197 | privacy: VideoPrivacy.PUBLIC, | |
198 | channel: { | |
f6eebcb3 C |
199 | displayName: 'Main user1 channel', |
200 | name: 'user1_channel', | |
b1f5b93e C |
201 | description: 'super channel', |
202 | isLocal | |
203 | }, | |
204 | fixture: 'video_short2.webm', | |
205 | files: [ | |
206 | { | |
207 | resolution: 240, | |
33ff70ba | 208 | size: 270000 |
b1f5b93e C |
209 | }, |
210 | { | |
211 | resolution: 360, | |
33ff70ba | 212 | size: 359000 |
b1f5b93e C |
213 | }, |
214 | { | |
215 | resolution: 480, | |
33ff70ba | 216 | size: 465000 |
b1f5b93e C |
217 | }, |
218 | { | |
219 | resolution: 720, | |
33ff70ba | 220 | size: 788000 |
b1f5b93e | 221 | } |
ac81d1a0 C |
222 | ], |
223 | thumbnailfile: 'thumbnail', | |
224 | previewfile: 'preview' | |
b1f5b93e | 225 | } |
0e1dc3e7 C |
226 | |
227 | const res = await getVideosList(server.url) | |
0e1dc3e7 C |
228 | const videos = res.body.data |
229 | expect(videos).to.be.an('array') | |
230 | expect(videos.length).to.equal(2) | |
231 | const video = videos[1] | |
0e1dc3e7 | 232 | |
b1f5b93e | 233 | await completeVideoCheck(server.url, video, checkAttributes) |
0e1dc3e7 C |
234 | } |
235 | }) | |
236 | ||
9a27cdc2 | 237 | it('Should upload two videos on server 3 and propagate on each server', async function () { |
0e1dc3e7 C |
238 | this.timeout(45000) |
239 | ||
240 | const videoAttributes1 = { | |
9a27cdc2 | 241 | name: 'my super name for server 3', |
0e1dc3e7 C |
242 | category: 6, |
243 | licence: 5, | |
9d3ef9fe | 244 | language: 'de', |
0e1dc3e7 | 245 | nsfw: true, |
9a27cdc2 | 246 | description: 'my super description for server 3', |
2422c46b | 247 | support: 'my super support text for server 3', |
0e1dc3e7 C |
248 | tags: [ 'tag1p3' ], |
249 | fixture: 'video_short3.webm' | |
250 | } | |
251 | await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1) | |
252 | ||
253 | const videoAttributes2 = { | |
9a27cdc2 | 254 | name: 'my super name for server 3-2', |
0e1dc3e7 C |
255 | category: 7, |
256 | licence: 6, | |
9d3ef9fe | 257 | language: 'ko', |
0e1dc3e7 | 258 | nsfw: false, |
9a27cdc2 | 259 | description: 'my super description for server 3-2', |
2422c46b | 260 | support: 'my super support text for server 3-2', |
0e1dc3e7 C |
261 | tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], |
262 | fixture: 'video_short.webm' | |
263 | } | |
264 | await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2) | |
265 | ||
3cd0734f | 266 | await waitJobs(servers) |
0e1dc3e7 | 267 | |
9a27cdc2 | 268 | // All servers should have this video |
0e1dc3e7 | 269 | for (const server of servers) { |
7243f84d | 270 | const isLocal = server.url === 'http://localhost:' + servers[2].port |
0e1dc3e7 C |
271 | const res = await getVideosList(server.url) |
272 | ||
273 | const videos = res.body.data | |
274 | expect(videos).to.be.an('array') | |
275 | expect(videos.length).to.equal(4) | |
276 | ||
277 | // We not sure about the order of the two last uploads | |
278 | let video1 = null | |
279 | let video2 = null | |
9a27cdc2 | 280 | if (videos[2].name === 'my super name for server 3') { |
0e1dc3e7 C |
281 | video1 = videos[2] |
282 | video2 = videos[3] | |
283 | } else { | |
284 | video1 = videos[3] | |
285 | video2 = videos[2] | |
286 | } | |
287 | ||
b1f5b93e C |
288 | const checkAttributesVideo1 = { |
289 | name: 'my super name for server 3', | |
290 | category: 6, | |
291 | licence: 5, | |
9d3ef9fe | 292 | language: 'de', |
b1f5b93e C |
293 | nsfw: true, |
294 | description: 'my super description for server 3', | |
2422c46b | 295 | support: 'my super support text for server 3', |
b64c950a C |
296 | account: { |
297 | name: 'root', | |
7243f84d | 298 | host: 'localhost:' + servers[2].port |
b64c950a | 299 | }, |
b1f5b93e C |
300 | isLocal, |
301 | duration: 5, | |
47564bbe | 302 | commentsEnabled: true, |
7f2cfe3a | 303 | downloadEnabled: true, |
b1f5b93e C |
304 | tags: [ 'tag1p3' ], |
305 | privacy: VideoPrivacy.PUBLIC, | |
306 | channel: { | |
f6eebcb3 C |
307 | displayName: 'Main root channel', |
308 | name: 'root_channel', | |
b1f5b93e C |
309 | description: '', |
310 | isLocal | |
311 | }, | |
312 | fixture: 'video_short3.webm', | |
313 | files: [ | |
314 | { | |
315 | resolution: 720, | |
316 | size: 292677 | |
317 | } | |
318 | ] | |
0e1dc3e7 | 319 | } |
b1f5b93e C |
320 | await completeVideoCheck(server.url, video1, checkAttributesVideo1) |
321 | ||
322 | const checkAttributesVideo2 = { | |
323 | name: 'my super name for server 3-2', | |
324 | category: 7, | |
325 | licence: 6, | |
9d3ef9fe | 326 | language: 'ko', |
b1f5b93e C |
327 | nsfw: false, |
328 | description: 'my super description for server 3-2', | |
2422c46b | 329 | support: 'my super support text for server 3-2', |
b64c950a C |
330 | account: { |
331 | name: 'root', | |
7243f84d | 332 | host: 'localhost:' + servers[2].port |
b64c950a | 333 | }, |
47564bbe | 334 | commentsEnabled: true, |
7f2cfe3a | 335 | downloadEnabled: true, |
b1f5b93e C |
336 | isLocal, |
337 | duration: 5, | |
338 | tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], | |
339 | privacy: VideoPrivacy.PUBLIC, | |
340 | channel: { | |
f6eebcb3 C |
341 | displayName: 'Main root channel', |
342 | name: 'root_channel', | |
b1f5b93e C |
343 | description: '', |
344 | isLocal | |
345 | }, | |
8b0d42ee | 346 | fixture: 'video_short.webm', |
b1f5b93e C |
347 | files: [ |
348 | { | |
349 | resolution: 720, | |
350 | size: 218910 | |
351 | } | |
352 | ] | |
0e1dc3e7 | 353 | } |
b1f5b93e | 354 | await completeVideoCheck(server.url, video2, checkAttributesVideo2) |
0e1dc3e7 C |
355 | } |
356 | }) | |
357 | }) | |
358 | ||
066e94c5 C |
359 | describe('It should list local videos', function () { |
360 | it('Should list only local videos on server 1', async function () { | |
361 | const { body } = await getLocalVideos(servers[0].url) | |
362 | ||
363 | expect(body.total).to.equal(1) | |
364 | expect(body.data).to.be.an('array') | |
365 | expect(body.data.length).to.equal(1) | |
366 | expect(body.data[0].name).to.equal('my super name for server 1') | |
367 | }) | |
368 | ||
369 | it('Should list only local videos on server 2', async function () { | |
370 | const { body } = await getLocalVideos(servers[1].url) | |
371 | ||
372 | expect(body.total).to.equal(1) | |
373 | expect(body.data).to.be.an('array') | |
374 | expect(body.data.length).to.equal(1) | |
375 | expect(body.data[0].name).to.equal('my super name for server 2') | |
376 | }) | |
377 | ||
378 | it('Should list only local videos on server 3', async function () { | |
379 | const { body } = await getLocalVideos(servers[2].url) | |
380 | ||
381 | expect(body.total).to.equal(2) | |
382 | expect(body.data).to.be.an('array') | |
383 | expect(body.data.length).to.equal(2) | |
384 | expect(body.data[0].name).to.equal('my super name for server 3') | |
385 | expect(body.data[1].name).to.equal('my super name for server 3-2') | |
386 | }) | |
387 | }) | |
388 | ||
0e1dc3e7 | 389 | describe('Should seed the uploaded video', function () { |
9a27cdc2 | 390 | it('Should add the file 1 by asking server 3', async function () { |
572f8d3d | 391 | this.timeout(10000) |
0e1dc3e7 C |
392 | |
393 | const res = await getVideosList(servers[2].url) | |
394 | ||
395 | const video = res.body.data[0] | |
396 | toRemove.push(res.body.data[2]) | |
397 | toRemove.push(res.body.data[3]) | |
398 | ||
5f04dd2f C |
399 | const res2 = await getVideo(servers[2].url, video.id) |
400 | const videoDetails = res2.body | |
401 | ||
b1f5b93e | 402 | const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) |
0e1dc3e7 C |
403 | expect(torrent.files).to.be.an('array') |
404 | expect(torrent.files.length).to.equal(1) | |
405 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
406 | }) | |
407 | ||
9a27cdc2 | 408 | it('Should add the file 2 by asking server 1', async function () { |
572f8d3d | 409 | this.timeout(10000) |
0e1dc3e7 C |
410 | |
411 | const res = await getVideosList(servers[0].url) | |
412 | ||
413 | const video = res.body.data[1] | |
5f04dd2f C |
414 | const res2 = await getVideo(servers[0].url, video.id) |
415 | const videoDetails = res2.body | |
0e1dc3e7 | 416 | |
b1f5b93e | 417 | const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) |
0e1dc3e7 C |
418 | expect(torrent.files).to.be.an('array') |
419 | expect(torrent.files.length).to.equal(1) | |
420 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
421 | }) | |
422 | ||
9a27cdc2 | 423 | it('Should add the file 3 by asking server 2', async function () { |
572f8d3d | 424 | this.timeout(10000) |
0e1dc3e7 C |
425 | |
426 | const res = await getVideosList(servers[1].url) | |
427 | ||
428 | const video = res.body.data[2] | |
5f04dd2f C |
429 | const res2 = await getVideo(servers[1].url, video.id) |
430 | const videoDetails = res2.body | |
0e1dc3e7 | 431 | |
b1f5b93e | 432 | const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) |
0e1dc3e7 C |
433 | expect(torrent.files).to.be.an('array') |
434 | expect(torrent.files.length).to.equal(1) | |
435 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
436 | }) | |
437 | ||
9a27cdc2 | 438 | it('Should add the file 3-2 by asking server 1', async function () { |
572f8d3d | 439 | this.timeout(10000) |
0e1dc3e7 C |
440 | |
441 | const res = await getVideosList(servers[0].url) | |
442 | ||
443 | const video = res.body.data[3] | |
5f04dd2f C |
444 | const res2 = await getVideo(servers[0].url, video.id) |
445 | const videoDetails = res2.body | |
0e1dc3e7 | 446 | |
5f04dd2f | 447 | const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri) |
0e1dc3e7 C |
448 | expect(torrent.files).to.be.an('array') |
449 | expect(torrent.files.length).to.equal(1) | |
450 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
451 | }) | |
14d3270f | 452 | |
9a27cdc2 | 453 | it('Should add the file 2 in 360p by asking server 1', async function () { |
572f8d3d | 454 | this.timeout(10000) |
14d3270f C |
455 | |
456 | const res = await getVideosList(servers[0].url) | |
457 | ||
9a27cdc2 | 458 | const video = res.body.data.find(v => v.name === 'my super name for server 2') |
5f04dd2f C |
459 | const res2 = await getVideo(servers[0].url, video.id) |
460 | const videoDetails = res2.body | |
461 | ||
5d00a3d7 | 462 | const file = videoDetails.files.find(f => f.resolution.id === 360) |
14d3270f C |
463 | expect(file).not.to.be.undefined |
464 | ||
465 | const torrent = await webtorrentAdd(file.magnetUri) | |
466 | expect(torrent.files).to.be.an('array') | |
467 | expect(torrent.files.length).to.equal(1) | |
468 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
469 | }) | |
0e1dc3e7 C |
470 | }) |
471 | ||
472 | describe('Should update video views, likes and dislikes', function () { | |
9a27cdc2 C |
473 | let localVideosServer3 = [] |
474 | let remoteVideosServer1 = [] | |
475 | let remoteVideosServer2 = [] | |
476 | let remoteVideosServer3 = [] | |
0e1dc3e7 C |
477 | |
478 | before(async function () { | |
479 | const res1 = await getVideosList(servers[0].url) | |
9a27cdc2 | 480 | remoteVideosServer1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.uuid) |
0e1dc3e7 C |
481 | |
482 | const res2 = await getVideosList(servers[1].url) | |
9a27cdc2 | 483 | remoteVideosServer2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.uuid) |
0e1dc3e7 C |
484 | |
485 | const res3 = await getVideosList(servers[2].url) | |
9a27cdc2 C |
486 | localVideosServer3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.uuid) |
487 | remoteVideosServer3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.uuid) | |
0e1dc3e7 C |
488 | }) |
489 | ||
490 | it('Should view multiple videos on owned servers', async function () { | |
6b616860 | 491 | this.timeout(30000) |
0e1dc3e7 | 492 | |
b5c0e955 | 493 | await viewVideo(servers[2].url, localVideosServer3[0]) |
511765c9 | 494 | await wait(1000) |
b5c0e955 C |
495 | |
496 | await viewVideo(servers[2].url, localVideosServer3[0]) | |
511765c9 | 497 | await viewVideo(servers[2].url, localVideosServer3[1]) |
b5c0e955 | 498 | |
511765c9 | 499 | await wait(1000) |
b5c0e955 | 500 | |
0b353d1d C |
501 | await viewVideo(servers[2].url, localVideosServer3[0]) |
502 | await viewVideo(servers[2].url, localVideosServer3[0]) | |
0e1dc3e7 | 503 | |
3cd0734f | 504 | await waitJobs(servers) |
0e1dc3e7 | 505 | |
6b616860 C |
506 | // Wait the repeatable job |
507 | await wait(6000) | |
508 | ||
c883db6d C |
509 | await waitJobs(servers) |
510 | ||
0e1dc3e7 C |
511 | for (const server of servers) { |
512 | const res = await getVideosList(server.url) | |
513 | ||
514 | const videos = res.body.data | |
9a27cdc2 C |
515 | const video0 = videos.find(v => v.uuid === localVideosServer3[0]) |
516 | const video1 = videos.find(v => v.uuid === localVideosServer3[1]) | |
5f04dd2f | 517 | |
1f3e9fec C |
518 | expect(video0.views).to.equal(3) |
519 | expect(video1.views).to.equal(1) | |
0e1dc3e7 C |
520 | } |
521 | }) | |
522 | ||
523 | it('Should view multiple videos on each servers', async function () { | |
24163420 | 524 | this.timeout(45000) |
0e1dc3e7 C |
525 | |
526 | const tasks: Promise<any>[] = [] | |
1f3e9fec C |
527 | tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0])) |
528 | tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0])) | |
529 | tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0])) | |
530 | tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0])) | |
531 | tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1])) | |
532 | tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1])) | |
533 | tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1])) | |
534 | tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) | |
535 | tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) | |
536 | tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) | |
0e1dc3e7 C |
537 | |
538 | await Promise.all(tasks) | |
539 | ||
3cd0734f | 540 | await waitJobs(servers) |
0e1dc3e7 | 541 | |
6b616860 | 542 | // Wait the repeatable job |
24163420 | 543 | await wait(16000) |
6b616860 | 544 | |
c883db6d C |
545 | await waitJobs(servers) |
546 | ||
0e1dc3e7 C |
547 | let baseVideos = null |
548 | ||
549 | for (const server of servers) { | |
550 | const res = await getVideosList(server.url) | |
551 | ||
552 | const videos = res.body.data | |
553 | ||
554 | // Initialize base videos for future comparisons | |
555 | if (baseVideos === null) { | |
556 | baseVideos = videos | |
35a097b8 | 557 | continue |
0e1dc3e7 C |
558 | } |
559 | ||
560 | for (const baseVideo of baseVideos) { | |
561 | const sameVideo = videos.find(video => video.name === baseVideo.name) | |
562 | expect(baseVideo.views).to.equal(sameVideo.views) | |
563 | } | |
564 | } | |
565 | }) | |
566 | ||
567 | it('Should like and dislikes videos on different services', async function () { | |
185eabe1 | 568 | this.timeout(50000) |
0e1dc3e7 | 569 | |
94a5ff8a | 570 | await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like') |
2ba92871 | 571 | await wait(500) |
94a5ff8a | 572 | await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike') |
2ba92871 | 573 | await wait(500) |
94a5ff8a C |
574 | await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like') |
575 | await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like') | |
2ba92871 | 576 | await wait(500) |
94a5ff8a C |
577 | await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike') |
578 | await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike') | |
2ba92871 | 579 | await wait(500) |
94a5ff8a | 580 | await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like') |
0e1dc3e7 | 581 | |
3cd0734f | 582 | await waitJobs(servers) |
021c4265 | 583 | await wait(5000) |
0d8ecb75 | 584 | await waitJobs(servers) |
0e1dc3e7 C |
585 | |
586 | let baseVideos = null | |
587 | for (const server of servers) { | |
588 | const res = await getVideosList(server.url) | |
589 | ||
590 | const videos = res.body.data | |
591 | ||
592 | // Initialize base videos for future comparisons | |
593 | if (baseVideos === null) { | |
594 | baseVideos = videos | |
35a097b8 | 595 | continue |
0e1dc3e7 C |
596 | } |
597 | ||
35a097b8 | 598 | for (const baseVideo of baseVideos) { |
0e1dc3e7 C |
599 | const sameVideo = videos.find(video => video.name === baseVideo.name) |
600 | expect(baseVideo.likes).to.equal(sameVideo.likes) | |
601 | expect(baseVideo.dislikes).to.equal(sameVideo.dislikes) | |
35a097b8 | 602 | } |
0e1dc3e7 C |
603 | } |
604 | }) | |
605 | }) | |
606 | ||
607 | describe('Should manipulate these videos', function () { | |
9a27cdc2 | 608 | it('Should update the video 3 by asking server 3', async function () { |
572f8d3d | 609 | this.timeout(10000) |
0e1dc3e7 C |
610 | |
611 | const attributes = { | |
612 | name: 'my super video updated', | |
613 | category: 10, | |
614 | licence: 7, | |
9d3ef9fe | 615 | language: 'fr', |
0e1dc3e7 C |
616 | nsfw: true, |
617 | description: 'my super description updated', | |
2422c46b | 618 | support: 'my super support text updated', |
ac81d1a0 C |
619 | tags: [ 'tag_up_1', 'tag_up_2' ], |
620 | thumbnailfile: 'thumbnail.jpg', | |
7519127b | 621 | originallyPublishedAt: '2019-02-11T13:38:14.449Z', |
ac81d1a0 | 622 | previewfile: 'preview.jpg' |
0e1dc3e7 C |
623 | } |
624 | ||
625 | await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes) | |
626 | ||
3cd0734f | 627 | await waitJobs(servers) |
0e1dc3e7 C |
628 | }) |
629 | ||
9a27cdc2 | 630 | it('Should have the video 3 updated on each server', async function () { |
572f8d3d | 631 | this.timeout(10000) |
0e1dc3e7 C |
632 | |
633 | for (const server of servers) { | |
634 | const res = await getVideosList(server.url) | |
635 | ||
636 | const videos = res.body.data | |
637 | const videoUpdated = videos.find(video => video.name === 'my super video updated') | |
0e1dc3e7 | 638 | expect(!!videoUpdated).to.be.true |
0e1dc3e7 | 639 | |
7243f84d | 640 | const isLocal = server.url === 'http://localhost:' + servers[2].port |
b1f5b93e C |
641 | const checkAttributes = { |
642 | name: 'my super video updated', | |
643 | category: 10, | |
644 | licence: 7, | |
9d3ef9fe | 645 | language: 'fr', |
b1f5b93e C |
646 | nsfw: true, |
647 | description: 'my super description updated', | |
2422c46b | 648 | support: 'my super support text updated', |
7519127b | 649 | originallyPublishedAt: '2019-02-11T13:38:14.449Z', |
b64c950a C |
650 | account: { |
651 | name: 'root', | |
7243f84d | 652 | host: 'localhost:' + servers[2].port |
b64c950a | 653 | }, |
b1f5b93e C |
654 | isLocal, |
655 | duration: 5, | |
47564bbe | 656 | commentsEnabled: true, |
7f2cfe3a | 657 | downloadEnabled: true, |
b1f5b93e C |
658 | tags: [ 'tag_up_1', 'tag_up_2' ], |
659 | privacy: VideoPrivacy.PUBLIC, | |
660 | channel: { | |
f6eebcb3 C |
661 | displayName: 'Main root channel', |
662 | name: 'root_channel', | |
b1f5b93e C |
663 | description: '', |
664 | isLocal | |
665 | }, | |
666 | fixture: 'video_short3.webm', | |
667 | files: [ | |
668 | { | |
669 | resolution: 720, | |
670 | size: 292677 | |
671 | } | |
ac81d1a0 C |
672 | ], |
673 | thumbnailfile: 'thumbnail', | |
674 | previewfile: 'preview' | |
b1f5b93e C |
675 | } |
676 | await completeVideoCheck(server.url, videoUpdated, checkAttributes) | |
0e1dc3e7 C |
677 | } |
678 | }) | |
679 | ||
9a27cdc2 | 680 | it('Should remove the videos 3 and 3-2 by asking server 3', async function () { |
572f8d3d | 681 | this.timeout(10000) |
0e1dc3e7 C |
682 | |
683 | await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id) | |
684 | await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id) | |
685 | ||
3cd0734f | 686 | await waitJobs(servers) |
0e1dc3e7 C |
687 | }) |
688 | ||
f05a1c30 C |
689 | it('Should not have files of videos 3 and 3-2 on each server', async function () { |
690 | for (const server of servers) { | |
6c5065a0 C |
691 | await checkVideoFilesWereRemoved(toRemove[0].uuid, server) |
692 | await checkVideoFilesWereRemoved(toRemove[1].uuid, server) | |
f05a1c30 C |
693 | } |
694 | }) | |
695 | ||
9a27cdc2 | 696 | it('Should have videos 1 and 3 on each server', async function () { |
0e1dc3e7 C |
697 | for (const server of servers) { |
698 | const res = await getVideosList(server.url) | |
699 | ||
700 | const videos = res.body.data | |
701 | expect(videos).to.be.an('array') | |
702 | expect(videos.length).to.equal(2) | |
703 | expect(videos[0].name).not.to.equal(videos[1].name) | |
704 | expect(videos[0].name).not.to.equal(toRemove[0].name) | |
705 | expect(videos[1].name).not.to.equal(toRemove[0].name) | |
706 | expect(videos[0].name).not.to.equal(toRemove[1].name) | |
707 | expect(videos[1].name).not.to.equal(toRemove[1].name) | |
708 | ||
9a27cdc2 | 709 | videoUUID = videos.find(video => video.name === 'my super name for server 1').uuid |
0e1dc3e7 C |
710 | } |
711 | }) | |
712 | ||
9a27cdc2 | 713 | it('Should get the same video by UUID on each server', async function () { |
0e1dc3e7 C |
714 | let baseVideo = null |
715 | for (const server of servers) { | |
716 | const res = await getVideo(server.url, videoUUID) | |
717 | ||
718 | const video = res.body | |
719 | ||
720 | if (baseVideo === null) { | |
721 | baseVideo = video | |
35a097b8 | 722 | continue |
0e1dc3e7 C |
723 | } |
724 | ||
725 | expect(baseVideo.name).to.equal(video.name) | |
726 | expect(baseVideo.uuid).to.equal(video.uuid) | |
5d00a3d7 C |
727 | expect(baseVideo.category.id).to.equal(video.category.id) |
728 | expect(baseVideo.language.id).to.equal(video.language.id) | |
729 | expect(baseVideo.licence.id).to.equal(video.licence.id) | |
0e1dc3e7 | 730 | expect(baseVideo.nsfw).to.equal(video.nsfw) |
b64c950a C |
731 | expect(baseVideo.account.name).to.equal(video.account.name) |
732 | expect(baseVideo.account.displayName).to.equal(video.account.displayName) | |
733 | expect(baseVideo.account.url).to.equal(video.account.url) | |
734 | expect(baseVideo.account.host).to.equal(video.account.host) | |
0e1dc3e7 C |
735 | expect(baseVideo.tags).to.deep.equal(video.tags) |
736 | } | |
737 | }) | |
738 | ||
9a27cdc2 | 739 | it('Should get the preview from each server', async function () { |
0e1dc3e7 C |
740 | for (const server of servers) { |
741 | const res = await getVideo(server.url, videoUUID) | |
742 | const video = res.body | |
743 | ||
7b0956ec | 744 | await testImage(server.url, 'video_short1-preview.webm', video.previewPath) |
0e1dc3e7 C |
745 | } |
746 | }) | |
747 | }) | |
748 | ||
d50acfab | 749 | describe('Should comment these videos', function () { |
73c08093 C |
750 | let childOfFirstChild: VideoCommentThreadTree |
751 | ||
d50acfab C |
752 | it('Should add comment (threads and replies)', async function () { |
753 | this.timeout(25000) | |
754 | ||
755 | { | |
756 | const text = 'my super first comment' | |
12edc149 | 757 | await servers[0].commentsCommand.createThread({ videoId: videoUUID, text }) |
d50acfab C |
758 | } |
759 | ||
760 | { | |
761 | const text = 'my super second comment' | |
12edc149 | 762 | await servers[2].commentsCommand.createThread({ videoId: videoUUID, text }) |
d50acfab C |
763 | } |
764 | ||
3cd0734f | 765 | await waitJobs(servers) |
d50acfab C |
766 | |
767 | { | |
12edc149 | 768 | const threadId = await servers[1].commentsCommand.findCommentId({ videoId: videoUUID, text: 'my super first comment' }) |
d50acfab C |
769 | |
770 | const text = 'my super answer to thread 1' | |
12edc149 | 771 | await servers[1].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text }) |
d50acfab C |
772 | } |
773 | ||
3cd0734f | 774 | await waitJobs(servers) |
d50acfab C |
775 | |
776 | { | |
12edc149 | 777 | const threadId = await servers[2].commentsCommand.findCommentId({ videoId: videoUUID, text: 'my super first comment' }) |
d50acfab | 778 | |
12edc149 C |
779 | const body = await servers[2].commentsCommand.getThread({ videoId: videoUUID, threadId }) |
780 | const childCommentId = body.children[0].comment.id | |
d50acfab C |
781 | |
782 | const text3 = 'my second answer to thread 1' | |
12edc149 | 783 | await servers[2].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 }) |
d50acfab C |
784 | |
785 | const text2 = 'my super answer to answer of thread 1' | |
12edc149 | 786 | await servers[2].commentsCommand.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 }) |
d50acfab C |
787 | } |
788 | ||
3cd0734f | 789 | await waitJobs(servers) |
d50acfab C |
790 | }) |
791 | ||
792 | it('Should have these threads', async function () { | |
793 | for (const server of servers) { | |
12edc149 | 794 | const body = await server.commentsCommand.listThreads({ videoId: videoUUID }) |
d50acfab | 795 | |
12edc149 C |
796 | expect(body.total).to.equal(2) |
797 | expect(body.data).to.be.an('array') | |
798 | expect(body.data).to.have.lengthOf(2) | |
d50acfab C |
799 | |
800 | { | |
12edc149 | 801 | const comment = body.data.find(c => c.text === 'my super first comment') |
d50acfab C |
802 | expect(comment).to.not.be.undefined |
803 | expect(comment.inReplyToCommentId).to.be.null | |
804 | expect(comment.account.name).to.equal('root') | |
7243f84d | 805 | expect(comment.account.host).to.equal('localhost:' + servers[0].port) |
d50acfab C |
806 | expect(comment.totalReplies).to.equal(3) |
807 | expect(dateIsValid(comment.createdAt as string)).to.be.true | |
808 | expect(dateIsValid(comment.updatedAt as string)).to.be.true | |
809 | } | |
810 | ||
811 | { | |
12edc149 | 812 | const comment = body.data.find(c => c.text === 'my super second comment') |
d50acfab C |
813 | expect(comment).to.not.be.undefined |
814 | expect(comment.inReplyToCommentId).to.be.null | |
815 | expect(comment.account.name).to.equal('root') | |
7243f84d | 816 | expect(comment.account.host).to.equal('localhost:' + servers[2].port) |
d50acfab C |
817 | expect(comment.totalReplies).to.equal(0) |
818 | expect(dateIsValid(comment.createdAt as string)).to.be.true | |
819 | expect(dateIsValid(comment.updatedAt as string)).to.be.true | |
820 | } | |
821 | } | |
822 | }) | |
823 | ||
824 | it('Should have these comments', async function () { | |
825 | for (const server of servers) { | |
12edc149 C |
826 | const body = await server.commentsCommand.listThreads({ videoId: videoUUID }) |
827 | const threadId = body.data.find(c => c.text === 'my super first comment').id | |
d50acfab | 828 | |
12edc149 | 829 | const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId }) |
d50acfab | 830 | |
d50acfab C |
831 | expect(tree.comment.text).equal('my super first comment') |
832 | expect(tree.comment.account.name).equal('root') | |
7243f84d | 833 | expect(tree.comment.account.host).equal('localhost:' + servers[0].port) |
d50acfab C |
834 | expect(tree.children).to.have.lengthOf(2) |
835 | ||
836 | const firstChild = tree.children[0] | |
837 | expect(firstChild.comment.text).to.equal('my super answer to thread 1') | |
838 | expect(firstChild.comment.account.name).equal('root') | |
7243f84d | 839 | expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port) |
d50acfab C |
840 | expect(firstChild.children).to.have.lengthOf(1) |
841 | ||
73c08093 | 842 | childOfFirstChild = firstChild.children[0] |
d50acfab C |
843 | expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1') |
844 | expect(childOfFirstChild.comment.account.name).equal('root') | |
7243f84d | 845 | expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port) |
d50acfab C |
846 | expect(childOfFirstChild.children).to.have.lengthOf(0) |
847 | ||
848 | const secondChild = tree.children[1] | |
849 | expect(secondChild.comment.text).to.equal('my second answer to thread 1') | |
850 | expect(secondChild.comment.account.name).equal('root') | |
7243f84d | 851 | expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port) |
d50acfab C |
852 | expect(secondChild.children).to.have.lengthOf(0) |
853 | } | |
854 | }) | |
47564bbe | 855 | |
73c08093 C |
856 | it('Should delete a reply', async function () { |
857 | this.timeout(10000) | |
858 | ||
12edc149 | 859 | await servers[2].commentsCommand.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id }) |
73c08093 | 860 | |
3cd0734f | 861 | await waitJobs(servers) |
73c08093 C |
862 | }) |
863 | ||
69222afa | 864 | it('Should have this comment marked as deleted', async function () { |
73c08093 | 865 | for (const server of servers) { |
12edc149 C |
866 | const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID }) |
867 | const threadId = data.find(c => c.text === 'my super first comment').id | |
73c08093 | 868 | |
12edc149 | 869 | const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId }) |
73c08093 C |
870 | expect(tree.comment.text).equal('my super first comment') |
871 | ||
872 | const firstChild = tree.children[0] | |
873 | expect(firstChild.comment.text).to.equal('my super answer to thread 1') | |
69222afa JM |
874 | expect(firstChild.children).to.have.lengthOf(1) |
875 | ||
876 | const deletedComment = firstChild.children[0].comment | |
877 | expect(deletedComment.isDeleted).to.be.true | |
878 | expect(deletedComment.deletedAt).to.not.be.null | |
879 | expect(deletedComment.account).to.be.null | |
880 | expect(deletedComment.text).to.equal('') | |
73c08093 C |
881 | |
882 | const secondChild = tree.children[1] | |
883 | expect(secondChild.comment.text).to.equal('my second answer to thread 1') | |
884 | } | |
885 | }) | |
886 | ||
4cb6d457 C |
887 | it('Should delete the thread comments', async function () { |
888 | this.timeout(10000) | |
889 | ||
12edc149 C |
890 | const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID }) |
891 | const commentId = data.find(c => c.text === 'my super first comment').id | |
892 | await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId }) | |
4cb6d457 | 893 | |
3cd0734f | 894 | await waitJobs(servers) |
4cb6d457 C |
895 | }) |
896 | ||
69222afa | 897 | it('Should have the threads marked as deleted on other servers too', async function () { |
4cb6d457 | 898 | for (const server of servers) { |
12edc149 | 899 | const body = await server.commentsCommand.listThreads({ videoId: videoUUID }) |
4cb6d457 | 900 | |
12edc149 C |
901 | expect(body.total).to.equal(2) |
902 | expect(body.data).to.be.an('array') | |
903 | expect(body.data).to.have.lengthOf(2) | |
4cb6d457 C |
904 | |
905 | { | |
12edc149 | 906 | const comment = body.data[0] |
4cb6d457 C |
907 | expect(comment).to.not.be.undefined |
908 | expect(comment.inReplyToCommentId).to.be.null | |
909 | expect(comment.account.name).to.equal('root') | |
7243f84d | 910 | expect(comment.account.host).to.equal('localhost:' + servers[2].port) |
4cb6d457 C |
911 | expect(comment.totalReplies).to.equal(0) |
912 | expect(dateIsValid(comment.createdAt as string)).to.be.true | |
913 | expect(dateIsValid(comment.updatedAt as string)).to.be.true | |
914 | } | |
69222afa JM |
915 | |
916 | { | |
12edc149 | 917 | const deletedComment = body.data[1] |
69222afa JM |
918 | expect(deletedComment).to.not.be.undefined |
919 | expect(deletedComment.isDeleted).to.be.true | |
920 | expect(deletedComment.deletedAt).to.not.be.null | |
921 | expect(deletedComment.text).to.equal('') | |
922 | expect(deletedComment.inReplyToCommentId).to.be.null | |
923 | expect(deletedComment.account).to.be.null | |
99cb53fd | 924 | expect(deletedComment.totalReplies).to.equal(2) |
69222afa JM |
925 | expect(dateIsValid(deletedComment.createdAt as string)).to.be.true |
926 | expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true | |
927 | expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true | |
928 | } | |
4cb6d457 C |
929 | } |
930 | }) | |
931 | ||
511765c9 | 932 | it('Should delete a remote thread by the origin server', async function () { |
b5206dfc JM |
933 | this.timeout(5000) |
934 | ||
12edc149 C |
935 | const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID }) |
936 | const commentId = data.find(c => c.text === 'my super second comment').id | |
937 | await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId }) | |
511765c9 C |
938 | |
939 | await waitJobs(servers) | |
940 | }) | |
941 | ||
69222afa | 942 | it('Should have the threads marked as deleted on other servers too', async function () { |
511765c9 | 943 | for (const server of servers) { |
12edc149 | 944 | const body = await server.commentsCommand.listThreads({ videoId: videoUUID }) |
511765c9 | 945 | |
12edc149 C |
946 | expect(body.total).to.equal(2) |
947 | expect(body.data).to.have.lengthOf(2) | |
69222afa JM |
948 | |
949 | { | |
12edc149 | 950 | const comment = body.data[0] |
69222afa JM |
951 | expect(comment.text).to.equal('') |
952 | expect(comment.isDeleted).to.be.true | |
953 | expect(comment.createdAt).to.not.be.null | |
954 | expect(comment.deletedAt).to.not.be.null | |
955 | expect(comment.account).to.be.null | |
956 | expect(comment.totalReplies).to.equal(0) | |
957 | } | |
958 | ||
959 | { | |
12edc149 | 960 | const comment = body.data[1] |
69222afa JM |
961 | expect(comment.text).to.equal('') |
962 | expect(comment.isDeleted).to.be.true | |
963 | expect(comment.createdAt).to.not.be.null | |
964 | expect(comment.deletedAt).to.not.be.null | |
965 | expect(comment.account).to.be.null | |
99cb53fd | 966 | expect(comment.totalReplies).to.equal(2) |
69222afa | 967 | } |
511765c9 C |
968 | } |
969 | }) | |
970 | ||
53a94c7c | 971 | it('Should disable comments and download', async function () { |
47564bbe C |
972 | this.timeout(20000) |
973 | ||
974 | const attributes = { | |
53a94c7c C |
975 | commentsEnabled: false, |
976 | downloadEnabled: false | |
47564bbe C |
977 | } |
978 | ||
979 | await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes) | |
980 | ||
3cd0734f | 981 | await waitJobs(servers) |
47564bbe C |
982 | |
983 | for (const server of servers) { | |
984 | const res = await getVideo(server.url, videoUUID) | |
985 | expect(res.body.commentsEnabled).to.be.false | |
53a94c7c | 986 | expect(res.body.downloadEnabled).to.be.false |
47564bbe C |
987 | |
988 | const text = 'my super forbidden comment' | |
12edc149 | 989 | await server.commentsCommand.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 }) |
47564bbe C |
990 | } |
991 | }) | |
d50acfab C |
992 | }) |
993 | ||
f595d394 C |
994 | describe('With minimum parameters', function () { |
995 | it('Should upload and propagate the video', async function () { | |
2186386c | 996 | this.timeout(60000) |
f595d394 C |
997 | |
998 | const path = '/api/v1/videos/upload' | |
999 | ||
1000 | const req = request(servers[1].url) | |
1001 | .post(path) | |
1002 | .set('Accept', 'application/json') | |
1003 | .set('Authorization', 'Bearer ' + servers[1].accessToken) | |
1004 | .field('name', 'minimum parameters') | |
1005 | .field('privacy', '1') | |
f595d394 C |
1006 | .field('channelId', '1') |
1007 | ||
3d470a53 | 1008 | await req.attach('videofile', buildAbsoluteFixturePath('video_short.webm')) |
f2eb23cd | 1009 | .expect(HttpStatusCode.OK_200) |
f595d394 | 1010 | |
3cd0734f | 1011 | await waitJobs(servers) |
f595d394 C |
1012 | |
1013 | for (const server of servers) { | |
1014 | const res = await getVideosList(server.url) | |
1015 | const video = res.body.data.find(v => v.name === 'minimum parameters') | |
1016 | ||
7243f84d | 1017 | const isLocal = server.url === 'http://localhost:' + servers[1].port |
b1f5b93e C |
1018 | const checkAttributes = { |
1019 | name: 'minimum parameters', | |
1020 | category: null, | |
1021 | licence: null, | |
1022 | language: null, | |
1023 | nsfw: false, | |
1024 | description: null, | |
2422c46b | 1025 | support: null, |
b64c950a C |
1026 | account: { |
1027 | name: 'root', | |
7243f84d | 1028 | host: 'localhost:' + servers[1].port |
b64c950a | 1029 | }, |
b1f5b93e C |
1030 | isLocal, |
1031 | duration: 5, | |
210709a9 | 1032 | commentsEnabled: true, |
7519127b | 1033 | downloadEnabled: true, |
a1587156 | 1034 | tags: [], |
b1f5b93e C |
1035 | privacy: VideoPrivacy.PUBLIC, |
1036 | channel: { | |
f6eebcb3 C |
1037 | displayName: 'Main root channel', |
1038 | name: 'root_channel', | |
b1f5b93e C |
1039 | description: '', |
1040 | isLocal | |
1041 | }, | |
1042 | fixture: 'video_short.webm', | |
1043 | files: [ | |
1044 | { | |
1045 | resolution: 720, | |
7519c4a2 | 1046 | size: 59000 |
b1f5b93e C |
1047 | }, |
1048 | { | |
1049 | resolution: 480, | |
7519c4a2 | 1050 | size: 34000 |
b1f5b93e C |
1051 | }, |
1052 | { | |
1053 | resolution: 360, | |
7519c4a2 | 1054 | size: 31000 |
b1f5b93e C |
1055 | }, |
1056 | { | |
1057 | resolution: 240, | |
7519c4a2 | 1058 | size: 23000 |
b1f5b93e C |
1059 | } |
1060 | ] | |
1061 | } | |
1062 | await completeVideoCheck(server.url, video, checkAttributes) | |
f595d394 C |
1063 | } |
1064 | }) | |
1065 | }) | |
1066 | ||
89231874 C |
1067 | describe('TMP directory', function () { |
1068 | it('Should have an empty tmp directory', async function () { | |
1069 | for (const server of servers) { | |
1070 | await checkTmpIsEmpty(server) | |
1071 | } | |
1072 | }) | |
1073 | }) | |
1074 | ||
7c3b7976 C |
1075 | after(async function () { |
1076 | await cleanupTests(servers) | |
0e1dc3e7 C |
1077 | }) |
1078 | }) |