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