]>
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 () { |
9a27cdc2 | 401 | it('Should add the file 1 by asking server 3', async function () { |
b18a501a | 402 | this.timeout(30000) |
0e1dc3e7 | 403 | |
89d241a7 | 404 | const { data } = await servers[2].videos.list() |
0e1dc3e7 | 405 | |
d23dd9fb C |
406 | const video = data[0] |
407 | toRemove.push(data[2]) | |
408 | toRemove.push(data[3]) | |
5f04dd2f | 409 | |
89d241a7 | 410 | const videoDetails = await servers[2].videos.get({ id: video.id }) |
d102de1b C |
411 | |
412 | await checkWebTorrentWorks(videoDetails.files[0].magnetUri) | |
0e1dc3e7 C |
413 | }) |
414 | ||
9a27cdc2 | 415 | it('Should add the file 2 by asking server 1', async function () { |
b18a501a | 416 | this.timeout(30000) |
0e1dc3e7 | 417 | |
89d241a7 | 418 | const { data } = await servers[0].videos.list() |
0e1dc3e7 | 419 | |
d23dd9fb | 420 | const video = data[1] |
89d241a7 | 421 | const videoDetails = await servers[0].videos.get({ id: video.id }) |
0e1dc3e7 | 422 | |
d102de1b | 423 | await checkWebTorrentWorks(videoDetails.files[0].magnetUri) |
0e1dc3e7 C |
424 | }) |
425 | ||
9a27cdc2 | 426 | it('Should add the file 3 by asking server 2', async function () { |
b18a501a | 427 | this.timeout(30000) |
0e1dc3e7 | 428 | |
89d241a7 | 429 | const { data } = await servers[1].videos.list() |
0e1dc3e7 | 430 | |
d23dd9fb | 431 | const video = data[2] |
89d241a7 | 432 | const videoDetails = await servers[1].videos.get({ id: video.id }) |
0e1dc3e7 | 433 | |
d102de1b | 434 | await checkWebTorrentWorks(videoDetails.files[0].magnetUri) |
0e1dc3e7 C |
435 | }) |
436 | ||
9a27cdc2 | 437 | it('Should add the file 3-2 by asking server 1', async function () { |
b18a501a | 438 | this.timeout(30000) |
0e1dc3e7 | 439 | |
89d241a7 | 440 | const { data } = await servers[0].videos.list() |
0e1dc3e7 | 441 | |
d23dd9fb | 442 | const video = data[3] |
89d241a7 | 443 | const videoDetails = await servers[0].videos.get({ id: video.id }) |
0e1dc3e7 | 444 | |
d102de1b | 445 | await checkWebTorrentWorks(videoDetails.files[0].magnetUri) |
0e1dc3e7 | 446 | }) |
14d3270f | 447 | |
9a27cdc2 | 448 | it('Should add the file 2 in 360p by asking server 1', async function () { |
b18a501a | 449 | this.timeout(30000) |
14d3270f | 450 | |
89d241a7 | 451 | const { data } = await servers[0].videos.list() |
14d3270f | 452 | |
d23dd9fb | 453 | const video = data.find(v => v.name === 'my super name for server 2') |
89d241a7 | 454 | const videoDetails = await servers[0].videos.get({ id: video.id }) |
5f04dd2f | 455 | |
5d00a3d7 | 456 | const file = videoDetails.files.find(f => f.resolution.id === 360) |
14d3270f C |
457 | expect(file).not.to.be.undefined |
458 | ||
d102de1b | 459 | await checkWebTorrentWorks(file.magnetUri) |
14d3270f | 460 | }) |
0e1dc3e7 C |
461 | }) |
462 | ||
463 | describe('Should update video views, likes and dislikes', function () { | |
9a27cdc2 C |
464 | let localVideosServer3 = [] |
465 | let remoteVideosServer1 = [] | |
466 | let remoteVideosServer2 = [] | |
467 | let remoteVideosServer3 = [] | |
0e1dc3e7 C |
468 | |
469 | before(async function () { | |
d23dd9fb | 470 | { |
89d241a7 | 471 | const { data } = await servers[0].videos.list() |
d23dd9fb C |
472 | remoteVideosServer1 = data.filter(video => video.isLocal === false).map(video => video.uuid) |
473 | } | |
0e1dc3e7 | 474 | |
d23dd9fb | 475 | { |
89d241a7 | 476 | const { data } = await servers[1].videos.list() |
d23dd9fb C |
477 | remoteVideosServer2 = data.filter(video => video.isLocal === false).map(video => video.uuid) |
478 | } | |
0e1dc3e7 | 479 | |
d23dd9fb | 480 | { |
89d241a7 | 481 | const { data } = await servers[2].videos.list() |
d23dd9fb C |
482 | localVideosServer3 = data.filter(video => video.isLocal === true).map(video => video.uuid) |
483 | remoteVideosServer3 = data.filter(video => video.isLocal === false).map(video => video.uuid) | |
484 | } | |
0e1dc3e7 C |
485 | }) |
486 | ||
487 | it('Should view multiple videos on owned servers', async function () { | |
6b616860 | 488 | this.timeout(30000) |
0e1dc3e7 | 489 | |
b2111066 | 490 | await servers[2].views.simulateView({ id: localVideosServer3[0] }) |
511765c9 | 491 | await wait(1000) |
b5c0e955 | 492 | |
b2111066 C |
493 | await servers[2].views.simulateView({ id: localVideosServer3[0] }) |
494 | await servers[2].views.simulateView({ id: localVideosServer3[1] }) | |
b5c0e955 | 495 | |
511765c9 | 496 | await wait(1000) |
b5c0e955 | 497 | |
b2111066 C |
498 | await servers[2].views.simulateView({ id: localVideosServer3[0] }) |
499 | await servers[2].views.simulateView({ id: localVideosServer3[0] }) | |
0e1dc3e7 | 500 | |
3cd0734f | 501 | await waitJobs(servers) |
0e1dc3e7 | 502 | |
b2111066 C |
503 | for (const server of servers) { |
504 | await server.debug.sendCommand({ body: { command: 'process-video-views-buffer' } }) | |
505 | } | |
6b616860 | 506 | |
c883db6d C |
507 | await waitJobs(servers) |
508 | ||
0e1dc3e7 | 509 | for (const server of servers) { |
89d241a7 | 510 | const { data } = await server.videos.list() |
0e1dc3e7 | 511 | |
d23dd9fb C |
512 | const video0 = data.find(v => v.uuid === localVideosServer3[0]) |
513 | const video1 = data.find(v => v.uuid === localVideosServer3[1]) | |
5f04dd2f | 514 | |
1f3e9fec C |
515 | expect(video0.views).to.equal(3) |
516 | expect(video1.views).to.equal(1) | |
0e1dc3e7 C |
517 | } |
518 | }) | |
519 | ||
520 | it('Should view multiple videos on each servers', async function () { | |
24163420 | 521 | this.timeout(45000) |
0e1dc3e7 C |
522 | |
523 | const tasks: Promise<any>[] = [] | |
b2111066 C |
524 | tasks.push(servers[0].views.simulateView({ id: remoteVideosServer1[0] })) |
525 | tasks.push(servers[1].views.simulateView({ id: remoteVideosServer2[0] })) | |
526 | tasks.push(servers[1].views.simulateView({ id: remoteVideosServer2[0] })) | |
527 | tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[0] })) | |
528 | tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[1] })) | |
529 | tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[1] })) | |
530 | tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[1] })) | |
531 | tasks.push(servers[2].views.simulateView({ id: localVideosServer3[1] })) | |
532 | tasks.push(servers[2].views.simulateView({ id: localVideosServer3[1] })) | |
533 | tasks.push(servers[2].views.simulateView({ id: localVideosServer3[1] })) | |
0e1dc3e7 C |
534 | |
535 | await Promise.all(tasks) | |
536 | ||
3cd0734f | 537 | await waitJobs(servers) |
0e1dc3e7 | 538 | |
b2111066 C |
539 | for (const server of servers) { |
540 | await server.debug.sendCommand({ body: { command: 'process-video-views-buffer' } }) | |
541 | } | |
6b616860 | 542 | |
c883db6d C |
543 | await waitJobs(servers) |
544 | ||
0e1dc3e7 C |
545 | let baseVideos = null |
546 | ||
547 | for (const server of servers) { | |
89d241a7 | 548 | const { data } = await server.videos.list() |
0e1dc3e7 C |
549 | |
550 | // Initialize base videos for future comparisons | |
551 | if (baseVideos === null) { | |
d23dd9fb | 552 | baseVideos = data |
35a097b8 | 553 | continue |
0e1dc3e7 C |
554 | } |
555 | ||
556 | for (const baseVideo of baseVideos) { | |
d23dd9fb | 557 | const sameVideo = data.find(video => video.name === baseVideo.name) |
0e1dc3e7 C |
558 | expect(baseVideo.views).to.equal(sameVideo.views) |
559 | } | |
560 | } | |
561 | }) | |
562 | ||
563 | it('Should like and dislikes videos on different services', async function () { | |
185eabe1 | 564 | this.timeout(50000) |
0e1dc3e7 | 565 | |
89d241a7 | 566 | await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' }) |
2ba92871 | 567 | await wait(500) |
89d241a7 | 568 | await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'dislike' }) |
2ba92871 | 569 | await wait(500) |
89d241a7 C |
570 | await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' }) |
571 | await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'like' }) | |
2ba92871 | 572 | await wait(500) |
89d241a7 C |
573 | await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'dislike' }) |
574 | await servers[2].videos.rate({ id: remoteVideosServer3[1], rating: 'dislike' }) | |
2ba92871 | 575 | await wait(500) |
89d241a7 | 576 | await servers[2].videos.rate({ id: remoteVideosServer3[0], rating: 'like' }) |
0e1dc3e7 | 577 | |
3cd0734f | 578 | await waitJobs(servers) |
021c4265 | 579 | await wait(5000) |
0d8ecb75 | 580 | await waitJobs(servers) |
0e1dc3e7 C |
581 | |
582 | let baseVideos = null | |
583 | for (const server of servers) { | |
89d241a7 | 584 | const { data } = await server.videos.list() |
0e1dc3e7 C |
585 | |
586 | // Initialize base videos for future comparisons | |
587 | if (baseVideos === null) { | |
d23dd9fb | 588 | baseVideos = data |
35a097b8 | 589 | continue |
0e1dc3e7 C |
590 | } |
591 | ||
35a097b8 | 592 | for (const baseVideo of baseVideos) { |
d23dd9fb | 593 | const sameVideo = data.find(video => video.name === baseVideo.name) |
57e4e1c1 C |
594 | expect(baseVideo.likes).to.equal(sameVideo.likes, `Likes of ${sameVideo.uuid} do not correspond`) |
595 | expect(baseVideo.dislikes).to.equal(sameVideo.dislikes, `Dislikes of ${sameVideo.uuid} do not correspond`) | |
35a097b8 | 596 | } |
0e1dc3e7 C |
597 | } |
598 | }) | |
599 | }) | |
600 | ||
601 | describe('Should manipulate these videos', function () { | |
d78b51aa C |
602 | let updatedAtMin: Date |
603 | ||
604 | it('Should update video 3', async function () { | |
b18a501a | 605 | this.timeout(30000) |
0e1dc3e7 C |
606 | |
607 | const attributes = { | |
608 | name: 'my super video updated', | |
609 | category: 10, | |
610 | licence: 7, | |
9d3ef9fe | 611 | language: 'fr', |
0e1dc3e7 C |
612 | nsfw: true, |
613 | description: 'my super description updated', | |
2422c46b | 614 | support: 'my super support text updated', |
ac81d1a0 C |
615 | tags: [ 'tag_up_1', 'tag_up_2' ], |
616 | thumbnailfile: 'thumbnail.jpg', | |
7519127b | 617 | originallyPublishedAt: '2019-02-11T13:38:14.449Z', |
ac81d1a0 | 618 | previewfile: 'preview.jpg' |
0e1dc3e7 C |
619 | } |
620 | ||
d78b51aa | 621 | updatedAtMin = new Date() |
89d241a7 | 622 | await servers[2].videos.update({ id: toRemove[0].id, attributes }) |
0e1dc3e7 | 623 | |
3cd0734f | 624 | await waitJobs(servers) |
0e1dc3e7 C |
625 | }) |
626 | ||
9a27cdc2 | 627 | it('Should have the video 3 updated on each server', async function () { |
b18a501a | 628 | this.timeout(30000) |
0e1dc3e7 C |
629 | |
630 | for (const server of servers) { | |
89d241a7 | 631 | const { data } = await server.videos.list() |
0e1dc3e7 | 632 | |
d23dd9fb | 633 | const videoUpdated = data.find(video => video.name === 'my super video updated') |
0e1dc3e7 | 634 | expect(!!videoUpdated).to.be.true |
0e1dc3e7 | 635 | |
d78b51aa C |
636 | expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin) |
637 | ||
2732eeff | 638 | const isLocal = server.url === servers[2].url |
b1f5b93e C |
639 | const checkAttributes = { |
640 | name: 'my super video updated', | |
641 | category: 10, | |
642 | licence: 7, | |
9d3ef9fe | 643 | language: 'fr', |
b1f5b93e C |
644 | nsfw: true, |
645 | description: 'my super description updated', | |
2422c46b | 646 | support: 'my super support text updated', |
7519127b | 647 | originallyPublishedAt: '2019-02-11T13:38:14.449Z', |
b64c950a C |
648 | account: { |
649 | name: 'root', | |
2732eeff | 650 | host: servers[2].host |
b64c950a | 651 | }, |
b1f5b93e C |
652 | isLocal, |
653 | duration: 5, | |
47564bbe | 654 | commentsEnabled: true, |
7f2cfe3a | 655 | downloadEnabled: true, |
b1f5b93e C |
656 | tags: [ 'tag_up_1', 'tag_up_2' ], |
657 | privacy: VideoPrivacy.PUBLIC, | |
658 | channel: { | |
f6eebcb3 C |
659 | displayName: 'Main root channel', |
660 | name: 'root_channel', | |
b1f5b93e C |
661 | description: '', |
662 | isLocal | |
663 | }, | |
664 | fixture: 'video_short3.webm', | |
665 | files: [ | |
666 | { | |
667 | resolution: 720, | |
668 | size: 292677 | |
669 | } | |
ac81d1a0 C |
670 | ], |
671 | thumbnailfile: 'thumbnail', | |
672 | previewfile: 'preview' | |
b1f5b93e | 673 | } |
d102de1b | 674 | await completeVideoCheck({ server, originServer: servers[2], videoUUID: videoUpdated.uuid, attributes: checkAttributes }) |
0e1dc3e7 C |
675 | } |
676 | }) | |
677 | ||
5cf027bd | 678 | it('Should only update thumbnail and update updatedAt attribute', async function () { |
b18a501a | 679 | this.timeout(30000) |
5cf027bd C |
680 | |
681 | const attributes = { | |
682 | thumbnailfile: 'thumbnail.jpg' | |
683 | } | |
684 | ||
685 | updatedAtMin = new Date() | |
686 | await servers[2].videos.update({ id: toRemove[0].id, attributes }) | |
687 | ||
688 | await waitJobs(servers) | |
689 | ||
690 | for (const server of servers) { | |
691 | const { data } = await server.videos.list() | |
692 | ||
693 | const videoUpdated = data.find(video => video.name === 'my super video updated') | |
694 | expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin) | |
695 | } | |
696 | }) | |
697 | ||
83903cb6 C |
698 | it('Should remove the videos 3 and 3-2 by asking server 3 and correctly delete files', async function () { |
699 | this.timeout(30000) | |
0e1dc3e7 | 700 | |
83903cb6 C |
701 | for (const id of [ toRemove[0].id, toRemove[1].id ]) { |
702 | await saveVideoInServers(servers, id) | |
0e1dc3e7 | 703 | |
83903cb6 | 704 | await servers[2].videos.remove({ id }) |
0e1dc3e7 | 705 | |
83903cb6 C |
706 | await waitJobs(servers) |
707 | ||
708 | for (const server of servers) { | |
709 | await checkVideoFilesWereRemoved({ server, video: server.store.videoDetails }) | |
710 | } | |
f05a1c30 C |
711 | } |
712 | }) | |
713 | ||
9a27cdc2 | 714 | it('Should have videos 1 and 3 on each server', async function () { |
0e1dc3e7 | 715 | for (const server of servers) { |
89d241a7 | 716 | const { data } = await server.videos.list() |
d23dd9fb C |
717 | |
718 | expect(data).to.be.an('array') | |
719 | expect(data.length).to.equal(2) | |
720 | expect(data[0].name).not.to.equal(data[1].name) | |
721 | expect(data[0].name).not.to.equal(toRemove[0].name) | |
722 | expect(data[1].name).not.to.equal(toRemove[0].name) | |
723 | expect(data[0].name).not.to.equal(toRemove[1].name) | |
724 | expect(data[1].name).not.to.equal(toRemove[1].name) | |
725 | ||
726 | videoUUID = data.find(video => video.name === 'my super name for server 1').uuid | |
0e1dc3e7 C |
727 | } |
728 | }) | |
729 | ||
9a27cdc2 | 730 | it('Should get the same video by UUID on each server', async function () { |
0e1dc3e7 C |
731 | let baseVideo = null |
732 | for (const server of servers) { | |
89d241a7 | 733 | const video = await server.videos.get({ id: videoUUID }) |
0e1dc3e7 C |
734 | |
735 | if (baseVideo === null) { | |
736 | baseVideo = video | |
35a097b8 | 737 | continue |
0e1dc3e7 C |
738 | } |
739 | ||
740 | expect(baseVideo.name).to.equal(video.name) | |
741 | expect(baseVideo.uuid).to.equal(video.uuid) | |
5d00a3d7 C |
742 | expect(baseVideo.category.id).to.equal(video.category.id) |
743 | expect(baseVideo.language.id).to.equal(video.language.id) | |
744 | expect(baseVideo.licence.id).to.equal(video.licence.id) | |
0e1dc3e7 | 745 | expect(baseVideo.nsfw).to.equal(video.nsfw) |
b64c950a C |
746 | expect(baseVideo.account.name).to.equal(video.account.name) |
747 | expect(baseVideo.account.displayName).to.equal(video.account.displayName) | |
748 | expect(baseVideo.account.url).to.equal(video.account.url) | |
749 | expect(baseVideo.account.host).to.equal(video.account.host) | |
0e1dc3e7 C |
750 | expect(baseVideo.tags).to.deep.equal(video.tags) |
751 | } | |
752 | }) | |
753 | ||
9a27cdc2 | 754 | it('Should get the preview from each server', async function () { |
0e1dc3e7 | 755 | for (const server of servers) { |
89d241a7 | 756 | const video = await server.videos.get({ id: videoUUID }) |
0e1dc3e7 | 757 | |
7b0956ec | 758 | await testImage(server.url, 'video_short1-preview.webm', video.previewPath) |
0e1dc3e7 C |
759 | } |
760 | }) | |
761 | }) | |
762 | ||
d50acfab | 763 | describe('Should comment these videos', function () { |
73c08093 C |
764 | let childOfFirstChild: VideoCommentThreadTree |
765 | ||
d50acfab C |
766 | it('Should add comment (threads and replies)', async function () { |
767 | this.timeout(25000) | |
768 | ||
769 | { | |
770 | const text = 'my super first comment' | |
89d241a7 | 771 | await servers[0].comments.createThread({ videoId: videoUUID, text }) |
d50acfab C |
772 | } |
773 | ||
774 | { | |
775 | const text = 'my super second comment' | |
89d241a7 | 776 | await servers[2].comments.createThread({ videoId: videoUUID, text }) |
d50acfab C |
777 | } |
778 | ||
3cd0734f | 779 | await waitJobs(servers) |
d50acfab C |
780 | |
781 | { | |
89d241a7 | 782 | const threadId = await servers[1].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' }) |
d50acfab C |
783 | |
784 | const text = 'my super answer to thread 1' | |
89d241a7 | 785 | await servers[1].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text }) |
d50acfab C |
786 | } |
787 | ||
3cd0734f | 788 | await waitJobs(servers) |
d50acfab C |
789 | |
790 | { | |
89d241a7 | 791 | const threadId = await servers[2].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' }) |
d50acfab | 792 | |
89d241a7 | 793 | const body = await servers[2].comments.getThread({ videoId: videoUUID, threadId }) |
12edc149 | 794 | const childCommentId = body.children[0].comment.id |
d50acfab C |
795 | |
796 | const text3 = 'my second answer to thread 1' | |
89d241a7 | 797 | await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 }) |
d50acfab C |
798 | |
799 | const text2 = 'my super answer to answer of thread 1' | |
89d241a7 | 800 | await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 }) |
d50acfab C |
801 | } |
802 | ||
3cd0734f | 803 | await waitJobs(servers) |
d50acfab C |
804 | }) |
805 | ||
806 | it('Should have these threads', async function () { | |
807 | for (const server of servers) { | |
89d241a7 | 808 | const body = await server.comments.listThreads({ videoId: videoUUID }) |
d50acfab | 809 | |
12edc149 C |
810 | expect(body.total).to.equal(2) |
811 | expect(body.data).to.be.an('array') | |
812 | expect(body.data).to.have.lengthOf(2) | |
d50acfab C |
813 | |
814 | { | |
12edc149 | 815 | const comment = body.data.find(c => c.text === 'my super first comment') |
d50acfab C |
816 | expect(comment).to.not.be.undefined |
817 | expect(comment.inReplyToCommentId).to.be.null | |
818 | expect(comment.account.name).to.equal('root') | |
2732eeff | 819 | expect(comment.account.host).to.equal(servers[0].host) |
d50acfab C |
820 | expect(comment.totalReplies).to.equal(3) |
821 | expect(dateIsValid(comment.createdAt as string)).to.be.true | |
822 | expect(dateIsValid(comment.updatedAt as string)).to.be.true | |
823 | } | |
824 | ||
825 | { | |
12edc149 | 826 | const comment = body.data.find(c => c.text === 'my super second comment') |
d50acfab C |
827 | expect(comment).to.not.be.undefined |
828 | expect(comment.inReplyToCommentId).to.be.null | |
829 | expect(comment.account.name).to.equal('root') | |
2732eeff | 830 | expect(comment.account.host).to.equal(servers[2].host) |
d50acfab C |
831 | expect(comment.totalReplies).to.equal(0) |
832 | expect(dateIsValid(comment.createdAt as string)).to.be.true | |
833 | expect(dateIsValid(comment.updatedAt as string)).to.be.true | |
834 | } | |
835 | } | |
836 | }) | |
837 | ||
838 | it('Should have these comments', async function () { | |
839 | for (const server of servers) { | |
89d241a7 | 840 | const body = await server.comments.listThreads({ videoId: videoUUID }) |
12edc149 | 841 | const threadId = body.data.find(c => c.text === 'my super first comment').id |
d50acfab | 842 | |
89d241a7 | 843 | const tree = await server.comments.getThread({ videoId: videoUUID, threadId }) |
d50acfab | 844 | |
d50acfab C |
845 | expect(tree.comment.text).equal('my super first comment') |
846 | expect(tree.comment.account.name).equal('root') | |
2732eeff | 847 | expect(tree.comment.account.host).equal(servers[0].host) |
d50acfab C |
848 | expect(tree.children).to.have.lengthOf(2) |
849 | ||
850 | const firstChild = tree.children[0] | |
851 | expect(firstChild.comment.text).to.equal('my super answer to thread 1') | |
852 | expect(firstChild.comment.account.name).equal('root') | |
2732eeff | 853 | expect(firstChild.comment.account.host).equal(servers[1].host) |
d50acfab C |
854 | expect(firstChild.children).to.have.lengthOf(1) |
855 | ||
73c08093 | 856 | childOfFirstChild = firstChild.children[0] |
d50acfab C |
857 | expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1') |
858 | expect(childOfFirstChild.comment.account.name).equal('root') | |
2732eeff | 859 | expect(childOfFirstChild.comment.account.host).equal(servers[2].host) |
d50acfab C |
860 | expect(childOfFirstChild.children).to.have.lengthOf(0) |
861 | ||
862 | const secondChild = tree.children[1] | |
863 | expect(secondChild.comment.text).to.equal('my second answer to thread 1') | |
864 | expect(secondChild.comment.account.name).equal('root') | |
2732eeff | 865 | expect(secondChild.comment.account.host).equal(servers[2].host) |
d50acfab C |
866 | expect(secondChild.children).to.have.lengthOf(0) |
867 | } | |
868 | }) | |
47564bbe | 869 | |
73c08093 | 870 | it('Should delete a reply', async function () { |
b18a501a | 871 | this.timeout(30000) |
73c08093 | 872 | |
89d241a7 | 873 | await servers[2].comments.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id }) |
73c08093 | 874 | |
3cd0734f | 875 | await waitJobs(servers) |
73c08093 C |
876 | }) |
877 | ||
69222afa | 878 | it('Should have this comment marked as deleted', async function () { |
73c08093 | 879 | for (const server of servers) { |
89d241a7 | 880 | const { data } = await server.comments.listThreads({ videoId: videoUUID }) |
12edc149 | 881 | const threadId = data.find(c => c.text === 'my super first comment').id |
73c08093 | 882 | |
89d241a7 | 883 | const tree = await server.comments.getThread({ videoId: videoUUID, threadId }) |
73c08093 C |
884 | expect(tree.comment.text).equal('my super first comment') |
885 | ||
886 | const firstChild = tree.children[0] | |
887 | expect(firstChild.comment.text).to.equal('my super answer to thread 1') | |
69222afa JM |
888 | expect(firstChild.children).to.have.lengthOf(1) |
889 | ||
890 | const deletedComment = firstChild.children[0].comment | |
891 | expect(deletedComment.isDeleted).to.be.true | |
892 | expect(deletedComment.deletedAt).to.not.be.null | |
893 | expect(deletedComment.account).to.be.null | |
894 | expect(deletedComment.text).to.equal('') | |
73c08093 C |
895 | |
896 | const secondChild = tree.children[1] | |
897 | expect(secondChild.comment.text).to.equal('my second answer to thread 1') | |
898 | } | |
899 | }) | |
900 | ||
4cb6d457 | 901 | it('Should delete the thread comments', async function () { |
b18a501a | 902 | this.timeout(30000) |
4cb6d457 | 903 | |
89d241a7 | 904 | const { data } = await servers[0].comments.listThreads({ videoId: videoUUID }) |
12edc149 | 905 | const commentId = data.find(c => c.text === 'my super first comment').id |
89d241a7 | 906 | await servers[0].comments.delete({ videoId: videoUUID, commentId }) |
4cb6d457 | 907 | |
3cd0734f | 908 | await waitJobs(servers) |
4cb6d457 C |
909 | }) |
910 | ||
69222afa | 911 | it('Should have the threads marked as deleted on other servers too', async function () { |
4cb6d457 | 912 | for (const server of servers) { |
89d241a7 | 913 | const body = await server.comments.listThreads({ videoId: videoUUID }) |
4cb6d457 | 914 | |
12edc149 C |
915 | expect(body.total).to.equal(2) |
916 | expect(body.data).to.be.an('array') | |
917 | expect(body.data).to.have.lengthOf(2) | |
4cb6d457 C |
918 | |
919 | { | |
12edc149 | 920 | const comment = body.data[0] |
4cb6d457 C |
921 | expect(comment).to.not.be.undefined |
922 | expect(comment.inReplyToCommentId).to.be.null | |
923 | expect(comment.account.name).to.equal('root') | |
2732eeff | 924 | expect(comment.account.host).to.equal(servers[2].host) |
4cb6d457 C |
925 | expect(comment.totalReplies).to.equal(0) |
926 | expect(dateIsValid(comment.createdAt as string)).to.be.true | |
927 | expect(dateIsValid(comment.updatedAt as string)).to.be.true | |
928 | } | |
69222afa JM |
929 | |
930 | { | |
12edc149 | 931 | const deletedComment = body.data[1] |
69222afa JM |
932 | expect(deletedComment).to.not.be.undefined |
933 | expect(deletedComment.isDeleted).to.be.true | |
934 | expect(deletedComment.deletedAt).to.not.be.null | |
935 | expect(deletedComment.text).to.equal('') | |
936 | expect(deletedComment.inReplyToCommentId).to.be.null | |
937 | expect(deletedComment.account).to.be.null | |
99cb53fd | 938 | expect(deletedComment.totalReplies).to.equal(2) |
69222afa JM |
939 | expect(dateIsValid(deletedComment.createdAt as string)).to.be.true |
940 | expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true | |
941 | expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true | |
942 | } | |
4cb6d457 C |
943 | } |
944 | }) | |
945 | ||
511765c9 | 946 | it('Should delete a remote thread by the origin server', async function () { |
b5206dfc JM |
947 | this.timeout(5000) |
948 | ||
89d241a7 | 949 | const { data } = await servers[0].comments.listThreads({ videoId: videoUUID }) |
12edc149 | 950 | const commentId = data.find(c => c.text === 'my super second comment').id |
89d241a7 | 951 | await servers[0].comments.delete({ videoId: videoUUID, commentId }) |
511765c9 C |
952 | |
953 | await waitJobs(servers) | |
954 | }) | |
955 | ||
69222afa | 956 | it('Should have the threads marked as deleted on other servers too', async function () { |
511765c9 | 957 | for (const server of servers) { |
89d241a7 | 958 | const body = await server.comments.listThreads({ videoId: videoUUID }) |
511765c9 | 959 | |
12edc149 C |
960 | expect(body.total).to.equal(2) |
961 | expect(body.data).to.have.lengthOf(2) | |
69222afa JM |
962 | |
963 | { | |
12edc149 | 964 | const comment = body.data[0] |
69222afa JM |
965 | expect(comment.text).to.equal('') |
966 | expect(comment.isDeleted).to.be.true | |
967 | expect(comment.createdAt).to.not.be.null | |
968 | expect(comment.deletedAt).to.not.be.null | |
969 | expect(comment.account).to.be.null | |
970 | expect(comment.totalReplies).to.equal(0) | |
971 | } | |
972 | ||
973 | { | |
12edc149 | 974 | const comment = body.data[1] |
69222afa JM |
975 | expect(comment.text).to.equal('') |
976 | expect(comment.isDeleted).to.be.true | |
977 | expect(comment.createdAt).to.not.be.null | |
978 | expect(comment.deletedAt).to.not.be.null | |
979 | expect(comment.account).to.be.null | |
99cb53fd | 980 | expect(comment.totalReplies).to.equal(2) |
69222afa | 981 | } |
511765c9 C |
982 | } |
983 | }) | |
984 | ||
53a94c7c | 985 | it('Should disable comments and download', async function () { |
47564bbe C |
986 | this.timeout(20000) |
987 | ||
988 | const attributes = { | |
53a94c7c C |
989 | commentsEnabled: false, |
990 | downloadEnabled: false | |
47564bbe C |
991 | } |
992 | ||
89d241a7 | 993 | await servers[0].videos.update({ id: videoUUID, attributes }) |
47564bbe | 994 | |
3cd0734f | 995 | await waitJobs(servers) |
47564bbe C |
996 | |
997 | for (const server of servers) { | |
89d241a7 | 998 | const video = await server.videos.get({ id: videoUUID }) |
d23dd9fb C |
999 | expect(video.commentsEnabled).to.be.false |
1000 | expect(video.downloadEnabled).to.be.false | |
47564bbe C |
1001 | |
1002 | const text = 'my super forbidden comment' | |
89d241a7 | 1003 | await server.comments.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 }) |
47564bbe C |
1004 | } |
1005 | }) | |
d50acfab C |
1006 | }) |
1007 | ||
f595d394 C |
1008 | describe('With minimum parameters', function () { |
1009 | it('Should upload and propagate the video', async function () { | |
e9fc9e03 | 1010 | this.timeout(120000) |
f595d394 C |
1011 | |
1012 | const path = '/api/v1/videos/upload' | |
1013 | ||
1014 | const req = request(servers[1].url) | |
1015 | .post(path) | |
1016 | .set('Accept', 'application/json') | |
1017 | .set('Authorization', 'Bearer ' + servers[1].accessToken) | |
1018 | .field('name', 'minimum parameters') | |
1019 | .field('privacy', '1') | |
f595d394 C |
1020 | .field('channelId', '1') |
1021 | ||
3d470a53 | 1022 | await req.attach('videofile', buildAbsoluteFixturePath('video_short.webm')) |
f2eb23cd | 1023 | .expect(HttpStatusCode.OK_200) |
f595d394 | 1024 | |
3cd0734f | 1025 | await waitJobs(servers) |
f595d394 C |
1026 | |
1027 | for (const server of servers) { | |
89d241a7 | 1028 | const { data } = await server.videos.list() |
d23dd9fb | 1029 | const video = data.find(v => v.name === 'minimum parameters') |
f595d394 | 1030 | |
2732eeff | 1031 | const isLocal = server.url === servers[1].url |
b1f5b93e C |
1032 | const checkAttributes = { |
1033 | name: 'minimum parameters', | |
1034 | category: null, | |
1035 | licence: null, | |
1036 | language: null, | |
1037 | nsfw: false, | |
1038 | description: null, | |
2422c46b | 1039 | support: null, |
b64c950a C |
1040 | account: { |
1041 | name: 'root', | |
2732eeff | 1042 | host: servers[1].host |
b64c950a | 1043 | }, |
b1f5b93e C |
1044 | isLocal, |
1045 | duration: 5, | |
210709a9 | 1046 | commentsEnabled: true, |
7519127b | 1047 | downloadEnabled: true, |
a1587156 | 1048 | tags: [], |
b1f5b93e C |
1049 | privacy: VideoPrivacy.PUBLIC, |
1050 | channel: { | |
f6eebcb3 C |
1051 | displayName: 'Main root channel', |
1052 | name: 'root_channel', | |
b1f5b93e C |
1053 | description: '', |
1054 | isLocal | |
1055 | }, | |
1056 | fixture: 'video_short.webm', | |
1057 | files: [ | |
1058 | { | |
1059 | resolution: 720, | |
d78b51aa | 1060 | size: 61000 |
b1f5b93e C |
1061 | }, |
1062 | { | |
1063 | resolution: 480, | |
d78b51aa | 1064 | size: 40000 |
b1f5b93e C |
1065 | }, |
1066 | { | |
1067 | resolution: 360, | |
d78b51aa | 1068 | size: 32000 |
b1f5b93e C |
1069 | }, |
1070 | { | |
1071 | resolution: 240, | |
7519c4a2 | 1072 | size: 23000 |
b1f5b93e C |
1073 | } |
1074 | ] | |
1075 | } | |
d102de1b | 1076 | await completeVideoCheck({ server, originServer: servers[1], videoUUID: video.uuid, attributes: checkAttributes }) |
f595d394 C |
1077 | } |
1078 | }) | |
1079 | }) | |
1080 | ||
89231874 C |
1081 | describe('TMP directory', function () { |
1082 | it('Should have an empty tmp directory', async function () { | |
1083 | for (const server of servers) { | |
1084 | await checkTmpIsEmpty(server) | |
1085 | } | |
1086 | }) | |
1087 | }) | |
1088 | ||
7c3b7976 C |
1089 | after(async function () { |
1090 | await cleanupTests(servers) | |
0e1dc3e7 C |
1091 | }) |
1092 | }) |