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