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