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