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