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