diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
commit | a24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch) | |
tree | a54b0f6c921ba83a6e909cd0ced325b2d4b8863c /server/tests/api/videos/multiple-servers.ts | |
parent | 5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff) | |
parent | c63830f15403ac4e750829f27d8bbbdc9a59282c (diff) | |
download | PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip |
Merge branch 'next' into develop
Diffstat (limited to 'server/tests/api/videos/multiple-servers.ts')
-rw-r--r-- | server/tests/api/videos/multiple-servers.ts | 459 |
1 files changed, 213 insertions, 246 deletions
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index a8c8a889b..d916abb09 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -3,49 +3,28 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import * as request from 'supertest' | 5 | import * as request from 'supertest' |
6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
7 | import { | 6 | import { |
8 | addVideoChannel, | ||
9 | buildAbsoluteFixturePath, | 7 | buildAbsoluteFixturePath, |
10 | checkTmpIsEmpty, | 8 | checkTmpIsEmpty, |
11 | checkVideoFilesWereRemoved, | 9 | checkVideoFilesWereRemoved, |
12 | cleanupTests, | 10 | cleanupTests, |
13 | completeVideoCheck, | 11 | completeVideoCheck, |
14 | createUser, | 12 | createMultipleServers, |
15 | dateIsValid, | 13 | dateIsValid, |
16 | doubleFollow, | 14 | doubleFollow, |
17 | flushAndRunMultipleServers, | 15 | PeerTubeServer, |
18 | getLocalVideos, | ||
19 | getVideo, | ||
20 | getVideoChannelsList, | ||
21 | getVideosList, | ||
22 | rateVideo, | ||
23 | removeVideo, | ||
24 | ServerInfo, | ||
25 | setAccessTokensToServers, | 16 | setAccessTokensToServers, |
26 | testImage, | 17 | testImage, |
27 | updateVideo, | ||
28 | uploadVideo, | ||
29 | userLogin, | ||
30 | viewVideo, | ||
31 | wait, | 18 | wait, |
19 | waitJobs, | ||
32 | webtorrentAdd | 20 | webtorrentAdd |
33 | } from '../../../../shared/extra-utils' | 21 | } from '@shared/extra-utils' |
34 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 22 | import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models' |
35 | import { | ||
36 | addVideoCommentReply, | ||
37 | addVideoCommentThread, | ||
38 | deleteVideoComment, | ||
39 | findCommentId, | ||
40 | getVideoCommentThreads, | ||
41 | getVideoThreadComments | ||
42 | } from '../../../../shared/extra-utils/videos/video-comments' | ||
43 | import { VideoComment, VideoCommentThreadTree, VideoPrivacy } from '../../../../shared/models/videos' | ||
44 | 23 | ||
45 | const expect = chai.expect | 24 | const expect = chai.expect |
46 | 25 | ||
47 | describe('Test multiple servers', function () { | 26 | describe('Test multiple servers', function () { |
48 | let servers: ServerInfo[] = [] | 27 | let servers: PeerTubeServer[] = [] |
49 | const toRemove = [] | 28 | const toRemove = [] |
50 | let videoUUID = '' | 29 | let videoUUID = '' |
51 | let videoChannelId: number | 30 | let videoChannelId: number |
@@ -53,7 +32,7 @@ describe('Test multiple servers', function () { | |||
53 | before(async function () { | 32 | before(async function () { |
54 | this.timeout(120000) | 33 | this.timeout(120000) |
55 | 34 | ||
56 | servers = await flushAndRunMultipleServers(3) | 35 | servers = await createMultipleServers(3) |
57 | 36 | ||
58 | // Get the access tokens | 37 | // Get the access tokens |
59 | await setAccessTokensToServers(servers) | 38 | await setAccessTokensToServers(servers) |
@@ -64,9 +43,9 @@ describe('Test multiple servers', function () { | |||
64 | displayName: 'my channel', | 43 | displayName: 'my channel', |
65 | description: 'super channel' | 44 | description: 'super channel' |
66 | } | 45 | } |
67 | await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel) | 46 | await servers[0].channels.create({ attributes: videoChannel }) |
68 | const channelRes = await getVideoChannelsList(servers[0].url, 0, 1) | 47 | const { data } = await servers[0].channels.list({ start: 0, count: 1 }) |
69 | videoChannelId = channelRes.body.data[0].id | 48 | videoChannelId = data[0].id |
70 | } | 49 | } |
71 | 50 | ||
72 | // Server 1 and server 2 follow each other | 51 | // Server 1 and server 2 follow each other |
@@ -79,10 +58,9 @@ describe('Test multiple servers', function () { | |||
79 | 58 | ||
80 | it('Should not have videos for all servers', async function () { | 59 | it('Should not have videos for all servers', async function () { |
81 | for (const server of servers) { | 60 | for (const server of servers) { |
82 | const res = await getVideosList(server.url) | 61 | const { data } = await server.videos.list() |
83 | const videos = res.body.data | 62 | expect(data).to.be.an('array') |
84 | expect(videos).to.be.an('array') | 63 | expect(data.length).to.equal(0) |
85 | expect(videos.length).to.equal(0) | ||
86 | } | 64 | } |
87 | }) | 65 | }) |
88 | 66 | ||
@@ -90,7 +68,7 @@ describe('Test multiple servers', function () { | |||
90 | it('Should upload the video on server 1 and propagate on each server', async function () { | 68 | it('Should upload the video on server 1 and propagate on each server', async function () { |
91 | this.timeout(25000) | 69 | this.timeout(25000) |
92 | 70 | ||
93 | const videoAttributes = { | 71 | const attributes = { |
94 | name: 'my super name for server 1', | 72 | name: 'my super name for server 1', |
95 | category: 5, | 73 | category: 5, |
96 | licence: 4, | 74 | licence: 4, |
@@ -103,7 +81,7 @@ describe('Test multiple servers', function () { | |||
103 | channelId: videoChannelId, | 81 | channelId: videoChannelId, |
104 | fixture: 'video_short1.webm' | 82 | fixture: 'video_short1.webm' |
105 | } | 83 | } |
106 | await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) | 84 | await servers[0].videos.upload({ attributes }) |
107 | 85 | ||
108 | await waitJobs(servers) | 86 | await waitJobs(servers) |
109 | 87 | ||
@@ -146,14 +124,13 @@ describe('Test multiple servers', function () { | |||
146 | ] | 124 | ] |
147 | } | 125 | } |
148 | 126 | ||
149 | const res = await getVideosList(server.url) | 127 | const { data } = await server.videos.list() |
150 | const videos = res.body.data | 128 | expect(data).to.be.an('array') |
151 | expect(videos).to.be.an('array') | 129 | expect(data.length).to.equal(1) |
152 | expect(videos.length).to.equal(1) | 130 | const video = data[0] |
153 | const video = videos[0] | ||
154 | 131 | ||
155 | await completeVideoCheck(server.url, video, checkAttributes) | 132 | await completeVideoCheck(server, video, checkAttributes) |
156 | publishedAt = video.publishedAt | 133 | publishedAt = video.publishedAt as string |
157 | } | 134 | } |
158 | }) | 135 | }) |
159 | 136 | ||
@@ -164,10 +141,10 @@ describe('Test multiple servers', function () { | |||
164 | username: 'user1', | 141 | username: 'user1', |
165 | password: 'super_password' | 142 | password: 'super_password' |
166 | } | 143 | } |
167 | await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) | 144 | await servers[1].users.create({ username: user.username, password: user.password }) |
168 | const userAccessToken = await userLogin(servers[1], user) | 145 | const userAccessToken = await servers[1].login.getAccessToken(user) |
169 | 146 | ||
170 | const videoAttributes = { | 147 | const attributes = { |
171 | name: 'my super name for server 2', | 148 | name: 'my super name for server 2', |
172 | category: 4, | 149 | category: 4, |
173 | licence: 3, | 150 | licence: 3, |
@@ -180,7 +157,7 @@ describe('Test multiple servers', function () { | |||
180 | thumbnailfile: 'thumbnail.jpg', | 157 | thumbnailfile: 'thumbnail.jpg', |
181 | previewfile: 'preview.jpg' | 158 | previewfile: 'preview.jpg' |
182 | } | 159 | } |
183 | await uploadVideo(servers[1].url, userAccessToken, videoAttributes, HttpStatusCode.OK_200, 'resumable') | 160 | await servers[1].videos.upload({ token: userAccessToken, attributes, mode: 'resumable' }) |
184 | 161 | ||
185 | // Transcoding | 162 | // Transcoding |
186 | await waitJobs(servers) | 163 | await waitJobs(servers) |
@@ -235,65 +212,67 @@ describe('Test multiple servers', function () { | |||
235 | previewfile: 'preview' | 212 | previewfile: 'preview' |
236 | } | 213 | } |
237 | 214 | ||
238 | const res = await getVideosList(server.url) | 215 | const { data } = await server.videos.list() |
239 | const videos = res.body.data | 216 | expect(data).to.be.an('array') |
240 | expect(videos).to.be.an('array') | 217 | expect(data.length).to.equal(2) |
241 | expect(videos.length).to.equal(2) | 218 | const video = data[1] |
242 | const video = videos[1] | ||
243 | 219 | ||
244 | await completeVideoCheck(server.url, video, checkAttributes) | 220 | await completeVideoCheck(server, video, checkAttributes) |
245 | } | 221 | } |
246 | }) | 222 | }) |
247 | 223 | ||
248 | it('Should upload two videos on server 3 and propagate on each server', async function () { | 224 | it('Should upload two videos on server 3 and propagate on each server', async function () { |
249 | this.timeout(45000) | 225 | this.timeout(45000) |
250 | 226 | ||
251 | const videoAttributes1 = { | 227 | { |
252 | name: 'my super name for server 3', | 228 | const attributes = { |
253 | category: 6, | 229 | name: 'my super name for server 3', |
254 | licence: 5, | 230 | category: 6, |
255 | language: 'de', | 231 | licence: 5, |
256 | nsfw: true, | 232 | language: 'de', |
257 | description: 'my super description for server 3', | 233 | nsfw: true, |
258 | support: 'my super support text for server 3', | 234 | description: 'my super description for server 3', |
259 | tags: [ 'tag1p3' ], | 235 | support: 'my super support text for server 3', |
260 | fixture: 'video_short3.webm' | 236 | tags: [ 'tag1p3' ], |
237 | fixture: 'video_short3.webm' | ||
238 | } | ||
239 | await servers[2].videos.upload({ attributes }) | ||
261 | } | 240 | } |
262 | await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1) | 241 | |
263 | 242 | { | |
264 | const videoAttributes2 = { | 243 | const attributes = { |
265 | name: 'my super name for server 3-2', | 244 | name: 'my super name for server 3-2', |
266 | category: 7, | 245 | category: 7, |
267 | licence: 6, | 246 | licence: 6, |
268 | language: 'ko', | 247 | language: 'ko', |
269 | nsfw: false, | 248 | nsfw: false, |
270 | description: 'my super description for server 3-2', | 249 | description: 'my super description for server 3-2', |
271 | support: 'my super support text for server 3-2', | 250 | support: 'my super support text for server 3-2', |
272 | tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], | 251 | tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], |
273 | fixture: 'video_short.webm' | 252 | fixture: 'video_short.webm' |
253 | } | ||
254 | await servers[2].videos.upload({ attributes }) | ||
274 | } | 255 | } |
275 | await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2) | ||
276 | 256 | ||
277 | await waitJobs(servers) | 257 | await waitJobs(servers) |
278 | 258 | ||
279 | // All servers should have this video | 259 | // All servers should have this video |
280 | for (const server of servers) { | 260 | for (const server of servers) { |
281 | const isLocal = server.url === 'http://localhost:' + servers[2].port | 261 | const isLocal = server.url === 'http://localhost:' + servers[2].port |
282 | const res = await getVideosList(server.url) | 262 | const { data } = await server.videos.list() |
283 | 263 | ||
284 | const videos = res.body.data | 264 | expect(data).to.be.an('array') |
285 | expect(videos).to.be.an('array') | 265 | expect(data.length).to.equal(4) |
286 | expect(videos.length).to.equal(4) | ||
287 | 266 | ||
288 | // We not sure about the order of the two last uploads | 267 | // We not sure about the order of the two last uploads |
289 | let video1 = null | 268 | let video1 = null |
290 | let video2 = null | 269 | let video2 = null |
291 | if (videos[2].name === 'my super name for server 3') { | 270 | if (data[2].name === 'my super name for server 3') { |
292 | video1 = videos[2] | 271 | video1 = data[2] |
293 | video2 = videos[3] | 272 | video2 = data[3] |
294 | } else { | 273 | } else { |
295 | video1 = videos[3] | 274 | video1 = data[3] |
296 | video2 = videos[2] | 275 | video2 = data[2] |
297 | } | 276 | } |
298 | 277 | ||
299 | const checkAttributesVideo1 = { | 278 | const checkAttributesVideo1 = { |
@@ -328,7 +307,7 @@ describe('Test multiple servers', function () { | |||
328 | } | 307 | } |
329 | ] | 308 | ] |
330 | } | 309 | } |
331 | await completeVideoCheck(server.url, video1, checkAttributesVideo1) | 310 | await completeVideoCheck(server, video1, checkAttributesVideo1) |
332 | 311 | ||
333 | const checkAttributesVideo2 = { | 312 | const checkAttributesVideo2 = { |
334 | name: 'my super name for server 3-2', | 313 | name: 'my super name for server 3-2', |
@@ -362,38 +341,38 @@ describe('Test multiple servers', function () { | |||
362 | } | 341 | } |
363 | ] | 342 | ] |
364 | } | 343 | } |
365 | await completeVideoCheck(server.url, video2, checkAttributesVideo2) | 344 | await completeVideoCheck(server, video2, checkAttributesVideo2) |
366 | } | 345 | } |
367 | }) | 346 | }) |
368 | }) | 347 | }) |
369 | 348 | ||
370 | describe('It should list local videos', function () { | 349 | describe('It should list local videos', function () { |
371 | it('Should list only local videos on server 1', async function () { | 350 | it('Should list only local videos on server 1', async function () { |
372 | const { body } = await getLocalVideos(servers[0].url) | 351 | const { data, total } = await servers[0].videos.list({ filter: 'local' }) |
373 | 352 | ||
374 | expect(body.total).to.equal(1) | 353 | expect(total).to.equal(1) |
375 | expect(body.data).to.be.an('array') | 354 | expect(data).to.be.an('array') |
376 | expect(body.data.length).to.equal(1) | 355 | expect(data.length).to.equal(1) |
377 | expect(body.data[0].name).to.equal('my super name for server 1') | 356 | expect(data[0].name).to.equal('my super name for server 1') |
378 | }) | 357 | }) |
379 | 358 | ||
380 | it('Should list only local videos on server 2', async function () { | 359 | it('Should list only local videos on server 2', async function () { |
381 | const { body } = await getLocalVideos(servers[1].url) | 360 | const { data, total } = await servers[1].videos.list({ filter: 'local' }) |
382 | 361 | ||
383 | expect(body.total).to.equal(1) | 362 | expect(total).to.equal(1) |
384 | expect(body.data).to.be.an('array') | 363 | expect(data).to.be.an('array') |
385 | expect(body.data.length).to.equal(1) | 364 | expect(data.length).to.equal(1) |
386 | expect(body.data[0].name).to.equal('my super name for server 2') | 365 | expect(data[0].name).to.equal('my super name for server 2') |
387 | }) | 366 | }) |
388 | 367 | ||
389 | it('Should list only local videos on server 3', async function () { | 368 | it('Should list only local videos on server 3', async function () { |
390 | const { body } = await getLocalVideos(servers[2].url) | 369 | const { data, total } = await servers[2].videos.list({ filter: 'local' }) |
391 | 370 | ||
392 | expect(body.total).to.equal(2) | 371 | expect(total).to.equal(2) |
393 | expect(body.data).to.be.an('array') | 372 | expect(data).to.be.an('array') |
394 | expect(body.data.length).to.equal(2) | 373 | expect(data.length).to.equal(2) |
395 | expect(body.data[0].name).to.equal('my super name for server 3') | 374 | expect(data[0].name).to.equal('my super name for server 3') |
396 | expect(body.data[1].name).to.equal('my super name for server 3-2') | 375 | expect(data[1].name).to.equal('my super name for server 3-2') |
397 | }) | 376 | }) |
398 | }) | 377 | }) |
399 | 378 | ||
@@ -401,15 +380,13 @@ describe('Test multiple servers', function () { | |||
401 | it('Should add the file 1 by asking server 3', async function () { | 380 | it('Should add the file 1 by asking server 3', async function () { |
402 | this.timeout(10000) | 381 | this.timeout(10000) |
403 | 382 | ||
404 | const res = await getVideosList(servers[2].url) | 383 | const { data } = await servers[2].videos.list() |
405 | |||
406 | const video = res.body.data[0] | ||
407 | toRemove.push(res.body.data[2]) | ||
408 | toRemove.push(res.body.data[3]) | ||
409 | 384 | ||
410 | const res2 = await getVideo(servers[2].url, video.id) | 385 | const video = data[0] |
411 | const videoDetails = res2.body | 386 | toRemove.push(data[2]) |
387 | toRemove.push(data[3]) | ||
412 | 388 | ||
389 | const videoDetails = await servers[2].videos.get({ id: video.id }) | ||
413 | const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) | 390 | const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) |
414 | expect(torrent.files).to.be.an('array') | 391 | expect(torrent.files).to.be.an('array') |
415 | expect(torrent.files.length).to.equal(1) | 392 | expect(torrent.files.length).to.equal(1) |
@@ -419,11 +396,10 @@ describe('Test multiple servers', function () { | |||
419 | it('Should add the file 2 by asking server 1', async function () { | 396 | it('Should add the file 2 by asking server 1', async function () { |
420 | this.timeout(10000) | 397 | this.timeout(10000) |
421 | 398 | ||
422 | const res = await getVideosList(servers[0].url) | 399 | const { data } = await servers[0].videos.list() |
423 | 400 | ||
424 | const video = res.body.data[1] | 401 | const video = data[1] |
425 | const res2 = await getVideo(servers[0].url, video.id) | 402 | const videoDetails = await servers[0].videos.get({ id: video.id }) |
426 | const videoDetails = res2.body | ||
427 | 403 | ||
428 | const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) | 404 | const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) |
429 | expect(torrent.files).to.be.an('array') | 405 | expect(torrent.files).to.be.an('array') |
@@ -434,11 +410,10 @@ describe('Test multiple servers', function () { | |||
434 | it('Should add the file 3 by asking server 2', async function () { | 410 | it('Should add the file 3 by asking server 2', async function () { |
435 | this.timeout(10000) | 411 | this.timeout(10000) |
436 | 412 | ||
437 | const res = await getVideosList(servers[1].url) | 413 | const { data } = await servers[1].videos.list() |
438 | 414 | ||
439 | const video = res.body.data[2] | 415 | const video = data[2] |
440 | const res2 = await getVideo(servers[1].url, video.id) | 416 | const videoDetails = await servers[1].videos.get({ id: video.id }) |
441 | const videoDetails = res2.body | ||
442 | 417 | ||
443 | const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) | 418 | const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) |
444 | expect(torrent.files).to.be.an('array') | 419 | expect(torrent.files).to.be.an('array') |
@@ -449,11 +424,10 @@ describe('Test multiple servers', function () { | |||
449 | it('Should add the file 3-2 by asking server 1', async function () { | 424 | it('Should add the file 3-2 by asking server 1', async function () { |
450 | this.timeout(10000) | 425 | this.timeout(10000) |
451 | 426 | ||
452 | const res = await getVideosList(servers[0].url) | 427 | const { data } = await servers[0].videos.list() |
453 | 428 | ||
454 | const video = res.body.data[3] | 429 | const video = data[3] |
455 | const res2 = await getVideo(servers[0].url, video.id) | 430 | const videoDetails = await servers[0].videos.get({ id: video.id }) |
456 | const videoDetails = res2.body | ||
457 | 431 | ||
458 | const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri) | 432 | const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri) |
459 | expect(torrent.files).to.be.an('array') | 433 | expect(torrent.files).to.be.an('array') |
@@ -464,11 +438,10 @@ describe('Test multiple servers', function () { | |||
464 | it('Should add the file 2 in 360p by asking server 1', async function () { | 438 | it('Should add the file 2 in 360p by asking server 1', async function () { |
465 | this.timeout(10000) | 439 | this.timeout(10000) |
466 | 440 | ||
467 | const res = await getVideosList(servers[0].url) | 441 | const { data } = await servers[0].videos.list() |
468 | 442 | ||
469 | const video = res.body.data.find(v => v.name === 'my super name for server 2') | 443 | const video = data.find(v => v.name === 'my super name for server 2') |
470 | const res2 = await getVideo(servers[0].url, video.id) | 444 | const videoDetails = await servers[0].videos.get({ id: video.id }) |
471 | const videoDetails = res2.body | ||
472 | 445 | ||
473 | const file = videoDetails.files.find(f => f.resolution.id === 360) | 446 | const file = videoDetails.files.find(f => f.resolution.id === 360) |
474 | expect(file).not.to.be.undefined | 447 | expect(file).not.to.be.undefined |
@@ -487,30 +460,36 @@ describe('Test multiple servers', function () { | |||
487 | let remoteVideosServer3 = [] | 460 | let remoteVideosServer3 = [] |
488 | 461 | ||
489 | before(async function () { | 462 | before(async function () { |
490 | const res1 = await getVideosList(servers[0].url) | 463 | { |
491 | remoteVideosServer1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.uuid) | 464 | const { data } = await servers[0].videos.list() |
465 | remoteVideosServer1 = data.filter(video => video.isLocal === false).map(video => video.uuid) | ||
466 | } | ||
492 | 467 | ||
493 | const res2 = await getVideosList(servers[1].url) | 468 | { |
494 | remoteVideosServer2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.uuid) | 469 | const { data } = await servers[1].videos.list() |
470 | remoteVideosServer2 = data.filter(video => video.isLocal === false).map(video => video.uuid) | ||
471 | } | ||
495 | 472 | ||
496 | const res3 = await getVideosList(servers[2].url) | 473 | { |
497 | localVideosServer3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.uuid) | 474 | const { data } = await servers[2].videos.list() |
498 | remoteVideosServer3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.uuid) | 475 | localVideosServer3 = data.filter(video => video.isLocal === true).map(video => video.uuid) |
476 | remoteVideosServer3 = data.filter(video => video.isLocal === false).map(video => video.uuid) | ||
477 | } | ||
499 | }) | 478 | }) |
500 | 479 | ||
501 | it('Should view multiple videos on owned servers', async function () { | 480 | it('Should view multiple videos on owned servers', async function () { |
502 | this.timeout(30000) | 481 | this.timeout(30000) |
503 | 482 | ||
504 | await viewVideo(servers[2].url, localVideosServer3[0]) | 483 | await servers[2].videos.view({ id: localVideosServer3[0] }) |
505 | await wait(1000) | 484 | await wait(1000) |
506 | 485 | ||
507 | await viewVideo(servers[2].url, localVideosServer3[0]) | 486 | await servers[2].videos.view({ id: localVideosServer3[0] }) |
508 | await viewVideo(servers[2].url, localVideosServer3[1]) | 487 | await servers[2].videos.view({ id: localVideosServer3[1] }) |
509 | 488 | ||
510 | await wait(1000) | 489 | await wait(1000) |
511 | 490 | ||
512 | await viewVideo(servers[2].url, localVideosServer3[0]) | 491 | await servers[2].videos.view({ id: localVideosServer3[0] }) |
513 | await viewVideo(servers[2].url, localVideosServer3[0]) | 492 | await servers[2].videos.view({ id: localVideosServer3[0] }) |
514 | 493 | ||
515 | await waitJobs(servers) | 494 | await waitJobs(servers) |
516 | 495 | ||
@@ -520,11 +499,10 @@ describe('Test multiple servers', function () { | |||
520 | await waitJobs(servers) | 499 | await waitJobs(servers) |
521 | 500 | ||
522 | for (const server of servers) { | 501 | for (const server of servers) { |
523 | const res = await getVideosList(server.url) | 502 | const { data } = await server.videos.list() |
524 | 503 | ||
525 | const videos = res.body.data | 504 | const video0 = data.find(v => v.uuid === localVideosServer3[0]) |
526 | const video0 = videos.find(v => v.uuid === localVideosServer3[0]) | 505 | const video1 = data.find(v => v.uuid === localVideosServer3[1]) |
527 | const video1 = videos.find(v => v.uuid === localVideosServer3[1]) | ||
528 | 506 | ||
529 | expect(video0.views).to.equal(3) | 507 | expect(video0.views).to.equal(3) |
530 | expect(video1.views).to.equal(1) | 508 | expect(video1.views).to.equal(1) |
@@ -535,16 +513,16 @@ describe('Test multiple servers', function () { | |||
535 | this.timeout(45000) | 513 | this.timeout(45000) |
536 | 514 | ||
537 | const tasks: Promise<any>[] = [] | 515 | const tasks: Promise<any>[] = [] |
538 | tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0])) | 516 | tasks.push(servers[0].videos.view({ id: remoteVideosServer1[0] })) |
539 | tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0])) | 517 | tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] })) |
540 | tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0])) | 518 | tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] })) |
541 | tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0])) | 519 | tasks.push(servers[2].videos.view({ id: remoteVideosServer3[0] })) |
542 | tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1])) | 520 | tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] })) |
543 | tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1])) | 521 | tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] })) |
544 | tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1])) | 522 | tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] })) |
545 | tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) | 523 | tasks.push(servers[2].videos.view({ id: localVideosServer3[1] })) |
546 | tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) | 524 | tasks.push(servers[2].videos.view({ id: localVideosServer3[1] })) |
547 | tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) | 525 | tasks.push(servers[2].videos.view({ id: localVideosServer3[1] })) |
548 | 526 | ||
549 | await Promise.all(tasks) | 527 | await Promise.all(tasks) |
550 | 528 | ||
@@ -558,18 +536,16 @@ describe('Test multiple servers', function () { | |||
558 | let baseVideos = null | 536 | let baseVideos = null |
559 | 537 | ||
560 | for (const server of servers) { | 538 | for (const server of servers) { |
561 | const res = await getVideosList(server.url) | 539 | const { data } = await server.videos.list() |
562 | |||
563 | const videos = res.body.data | ||
564 | 540 | ||
565 | // Initialize base videos for future comparisons | 541 | // Initialize base videos for future comparisons |
566 | if (baseVideos === null) { | 542 | if (baseVideos === null) { |
567 | baseVideos = videos | 543 | baseVideos = data |
568 | continue | 544 | continue |
569 | } | 545 | } |
570 | 546 | ||
571 | for (const baseVideo of baseVideos) { | 547 | for (const baseVideo of baseVideos) { |
572 | const sameVideo = videos.find(video => video.name === baseVideo.name) | 548 | const sameVideo = data.find(video => video.name === baseVideo.name) |
573 | expect(baseVideo.views).to.equal(sameVideo.views) | 549 | expect(baseVideo.views).to.equal(sameVideo.views) |
574 | } | 550 | } |
575 | } | 551 | } |
@@ -578,35 +554,34 @@ describe('Test multiple servers', function () { | |||
578 | it('Should like and dislikes videos on different services', async function () { | 554 | it('Should like and dislikes videos on different services', async function () { |
579 | this.timeout(50000) | 555 | this.timeout(50000) |
580 | 556 | ||
581 | await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like') | 557 | await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' }) |
582 | await wait(500) | 558 | await wait(500) |
583 | await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike') | 559 | await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'dislike' }) |
584 | await wait(500) | 560 | await wait(500) |
585 | await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like') | 561 | await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' }) |
586 | await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like') | 562 | await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'like' }) |
587 | await wait(500) | 563 | await wait(500) |
588 | await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike') | 564 | await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'dislike' }) |
589 | await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike') | 565 | await servers[2].videos.rate({ id: remoteVideosServer3[1], rating: 'dislike' }) |
590 | await wait(500) | 566 | await wait(500) |
591 | await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like') | 567 | await servers[2].videos.rate({ id: remoteVideosServer3[0], rating: 'like' }) |
592 | 568 | ||
593 | await waitJobs(servers) | 569 | await waitJobs(servers) |
594 | await wait(5000) | 570 | await wait(5000) |
571 | await waitJobs(servers) | ||
595 | 572 | ||
596 | let baseVideos = null | 573 | let baseVideos = null |
597 | for (const server of servers) { | 574 | for (const server of servers) { |
598 | const res = await getVideosList(server.url) | 575 | const { data } = await server.videos.list() |
599 | |||
600 | const videos = res.body.data | ||
601 | 576 | ||
602 | // Initialize base videos for future comparisons | 577 | // Initialize base videos for future comparisons |
603 | if (baseVideos === null) { | 578 | if (baseVideos === null) { |
604 | baseVideos = videos | 579 | baseVideos = data |
605 | continue | 580 | continue |
606 | } | 581 | } |
607 | 582 | ||
608 | for (const baseVideo of baseVideos) { | 583 | for (const baseVideo of baseVideos) { |
609 | const sameVideo = videos.find(video => video.name === baseVideo.name) | 584 | const sameVideo = data.find(video => video.name === baseVideo.name) |
610 | expect(baseVideo.likes).to.equal(sameVideo.likes) | 585 | expect(baseVideo.likes).to.equal(sameVideo.likes) |
611 | expect(baseVideo.dislikes).to.equal(sameVideo.dislikes) | 586 | expect(baseVideo.dislikes).to.equal(sameVideo.dislikes) |
612 | } | 587 | } |
@@ -632,7 +607,7 @@ describe('Test multiple servers', function () { | |||
632 | previewfile: 'preview.jpg' | 607 | previewfile: 'preview.jpg' |
633 | } | 608 | } |
634 | 609 | ||
635 | await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes) | 610 | await servers[2].videos.update({ id: toRemove[0].id, attributes }) |
636 | 611 | ||
637 | await waitJobs(servers) | 612 | await waitJobs(servers) |
638 | }) | 613 | }) |
@@ -641,10 +616,9 @@ describe('Test multiple servers', function () { | |||
641 | this.timeout(10000) | 616 | this.timeout(10000) |
642 | 617 | ||
643 | for (const server of servers) { | 618 | for (const server of servers) { |
644 | const res = await getVideosList(server.url) | 619 | const { data } = await server.videos.list() |
645 | 620 | ||
646 | const videos = res.body.data | 621 | const videoUpdated = data.find(video => video.name === 'my super video updated') |
647 | const videoUpdated = videos.find(video => video.name === 'my super video updated') | ||
648 | expect(!!videoUpdated).to.be.true | 622 | expect(!!videoUpdated).to.be.true |
649 | 623 | ||
650 | const isLocal = server.url === 'http://localhost:' + servers[2].port | 624 | const isLocal = server.url === 'http://localhost:' + servers[2].port |
@@ -683,49 +657,46 @@ describe('Test multiple servers', function () { | |||
683 | thumbnailfile: 'thumbnail', | 657 | thumbnailfile: 'thumbnail', |
684 | previewfile: 'preview' | 658 | previewfile: 'preview' |
685 | } | 659 | } |
686 | await completeVideoCheck(server.url, videoUpdated, checkAttributes) | 660 | await completeVideoCheck(server, videoUpdated, checkAttributes) |
687 | } | 661 | } |
688 | }) | 662 | }) |
689 | 663 | ||
690 | it('Should remove the videos 3 and 3-2 by asking server 3', async function () { | 664 | it('Should remove the videos 3 and 3-2 by asking server 3', async function () { |
691 | this.timeout(10000) | 665 | this.timeout(10000) |
692 | 666 | ||
693 | await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id) | 667 | await servers[2].videos.remove({ id: toRemove[0].id }) |
694 | await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id) | 668 | await servers[2].videos.remove({ id: toRemove[1].id }) |
695 | 669 | ||
696 | await waitJobs(servers) | 670 | await waitJobs(servers) |
697 | }) | 671 | }) |
698 | 672 | ||
699 | it('Should not have files of videos 3 and 3-2 on each server', async function () { | 673 | it('Should not have files of videos 3 and 3-2 on each server', async function () { |
700 | for (const server of servers) { | 674 | for (const server of servers) { |
701 | await checkVideoFilesWereRemoved(toRemove[0].uuid, server.internalServerNumber) | 675 | await checkVideoFilesWereRemoved(toRemove[0].uuid, server) |
702 | await checkVideoFilesWereRemoved(toRemove[1].uuid, server.internalServerNumber) | 676 | await checkVideoFilesWereRemoved(toRemove[1].uuid, server) |
703 | } | 677 | } |
704 | }) | 678 | }) |
705 | 679 | ||
706 | it('Should have videos 1 and 3 on each server', async function () { | 680 | it('Should have videos 1 and 3 on each server', async function () { |
707 | for (const server of servers) { | 681 | for (const server of servers) { |
708 | const res = await getVideosList(server.url) | 682 | const { data } = await server.videos.list() |
709 | 683 | ||
710 | const videos = res.body.data | 684 | expect(data).to.be.an('array') |
711 | expect(videos).to.be.an('array') | 685 | expect(data.length).to.equal(2) |
712 | expect(videos.length).to.equal(2) | 686 | expect(data[0].name).not.to.equal(data[1].name) |
713 | expect(videos[0].name).not.to.equal(videos[1].name) | 687 | expect(data[0].name).not.to.equal(toRemove[0].name) |
714 | expect(videos[0].name).not.to.equal(toRemove[0].name) | 688 | expect(data[1].name).not.to.equal(toRemove[0].name) |
715 | expect(videos[1].name).not.to.equal(toRemove[0].name) | 689 | expect(data[0].name).not.to.equal(toRemove[1].name) |
716 | expect(videos[0].name).not.to.equal(toRemove[1].name) | 690 | expect(data[1].name).not.to.equal(toRemove[1].name) |
717 | expect(videos[1].name).not.to.equal(toRemove[1].name) | 691 | |
718 | 692 | videoUUID = data.find(video => video.name === 'my super name for server 1').uuid | |
719 | videoUUID = videos.find(video => video.name === 'my super name for server 1').uuid | ||
720 | } | 693 | } |
721 | }) | 694 | }) |
722 | 695 | ||
723 | it('Should get the same video by UUID on each server', async function () { | 696 | it('Should get the same video by UUID on each server', async function () { |
724 | let baseVideo = null | 697 | let baseVideo = null |
725 | for (const server of servers) { | 698 | for (const server of servers) { |
726 | const res = await getVideo(server.url, videoUUID) | 699 | const video = await server.videos.get({ id: videoUUID }) |
727 | |||
728 | const video = res.body | ||
729 | 700 | ||
730 | if (baseVideo === null) { | 701 | if (baseVideo === null) { |
731 | baseVideo = video | 702 | baseVideo = video |
@@ -748,8 +719,7 @@ describe('Test multiple servers', function () { | |||
748 | 719 | ||
749 | it('Should get the preview from each server', async function () { | 720 | it('Should get the preview from each server', async function () { |
750 | for (const server of servers) { | 721 | for (const server of servers) { |
751 | const res = await getVideo(server.url, videoUUID) | 722 | const video = await server.videos.get({ id: videoUUID }) |
752 | const video = res.body | ||
753 | 723 | ||
754 | await testImage(server.url, 'video_short1-preview.webm', video.previewPath) | 724 | await testImage(server.url, 'video_short1-preview.webm', video.previewPath) |
755 | } | 725 | } |
@@ -764,36 +734,36 @@ describe('Test multiple servers', function () { | |||
764 | 734 | ||
765 | { | 735 | { |
766 | const text = 'my super first comment' | 736 | const text = 'my super first comment' |
767 | await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, text) | 737 | await servers[0].comments.createThread({ videoId: videoUUID, text }) |
768 | } | 738 | } |
769 | 739 | ||
770 | { | 740 | { |
771 | const text = 'my super second comment' | 741 | const text = 'my super second comment' |
772 | await addVideoCommentThread(servers[2].url, servers[2].accessToken, videoUUID, text) | 742 | await servers[2].comments.createThread({ videoId: videoUUID, text }) |
773 | } | 743 | } |
774 | 744 | ||
775 | await waitJobs(servers) | 745 | await waitJobs(servers) |
776 | 746 | ||
777 | { | 747 | { |
778 | const threadId = await findCommentId(servers[1].url, videoUUID, 'my super first comment') | 748 | const threadId = await servers[1].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' }) |
779 | 749 | ||
780 | const text = 'my super answer to thread 1' | 750 | const text = 'my super answer to thread 1' |
781 | await addVideoCommentReply(servers[1].url, servers[1].accessToken, videoUUID, threadId, text) | 751 | await servers[1].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text }) |
782 | } | 752 | } |
783 | 753 | ||
784 | await waitJobs(servers) | 754 | await waitJobs(servers) |
785 | 755 | ||
786 | { | 756 | { |
787 | const threadId = await findCommentId(servers[2].url, videoUUID, 'my super first comment') | 757 | const threadId = await servers[2].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' }) |
788 | 758 | ||
789 | const res2 = await getVideoThreadComments(servers[2].url, videoUUID, threadId) | 759 | const body = await servers[2].comments.getThread({ videoId: videoUUID, threadId }) |
790 | const childCommentId = res2.body.children[0].comment.id | 760 | const childCommentId = body.children[0].comment.id |
791 | 761 | ||
792 | const text3 = 'my second answer to thread 1' | 762 | const text3 = 'my second answer to thread 1' |
793 | await addVideoCommentReply(servers[2].url, servers[2].accessToken, videoUUID, threadId, text3) | 763 | await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 }) |
794 | 764 | ||
795 | const text2 = 'my super answer to answer of thread 1' | 765 | const text2 = 'my super answer to answer of thread 1' |
796 | await addVideoCommentReply(servers[2].url, servers[2].accessToken, videoUUID, childCommentId, text2) | 766 | await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 }) |
797 | } | 767 | } |
798 | 768 | ||
799 | await waitJobs(servers) | 769 | await waitJobs(servers) |
@@ -801,14 +771,14 @@ describe('Test multiple servers', function () { | |||
801 | 771 | ||
802 | it('Should have these threads', async function () { | 772 | it('Should have these threads', async function () { |
803 | for (const server of servers) { | 773 | for (const server of servers) { |
804 | const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5) | 774 | const body = await server.comments.listThreads({ videoId: videoUUID }) |
805 | 775 | ||
806 | expect(res.body.total).to.equal(2) | 776 | expect(body.total).to.equal(2) |
807 | expect(res.body.data).to.be.an('array') | 777 | expect(body.data).to.be.an('array') |
808 | expect(res.body.data).to.have.lengthOf(2) | 778 | expect(body.data).to.have.lengthOf(2) |
809 | 779 | ||
810 | { | 780 | { |
811 | const comment: VideoComment = res.body.data.find(c => c.text === 'my super first comment') | 781 | const comment = body.data.find(c => c.text === 'my super first comment') |
812 | expect(comment).to.not.be.undefined | 782 | expect(comment).to.not.be.undefined |
813 | expect(comment.inReplyToCommentId).to.be.null | 783 | expect(comment.inReplyToCommentId).to.be.null |
814 | expect(comment.account.name).to.equal('root') | 784 | expect(comment.account.name).to.equal('root') |
@@ -819,7 +789,7 @@ describe('Test multiple servers', function () { | |||
819 | } | 789 | } |
820 | 790 | ||
821 | { | 791 | { |
822 | const comment: VideoComment = res.body.data.find(c => c.text === 'my super second comment') | 792 | const comment = body.data.find(c => c.text === 'my super second comment') |
823 | expect(comment).to.not.be.undefined | 793 | expect(comment).to.not.be.undefined |
824 | expect(comment.inReplyToCommentId).to.be.null | 794 | expect(comment.inReplyToCommentId).to.be.null |
825 | expect(comment.account.name).to.equal('root') | 795 | expect(comment.account.name).to.equal('root') |
@@ -833,12 +803,11 @@ describe('Test multiple servers', function () { | |||
833 | 803 | ||
834 | it('Should have these comments', async function () { | 804 | it('Should have these comments', async function () { |
835 | for (const server of servers) { | 805 | for (const server of servers) { |
836 | const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5) | 806 | const body = await server.comments.listThreads({ videoId: videoUUID }) |
837 | const threadId = res1.body.data.find(c => c.text === 'my super first comment').id | 807 | const threadId = body.data.find(c => c.text === 'my super first comment').id |
838 | 808 | ||
839 | const res2 = await getVideoThreadComments(server.url, videoUUID, threadId) | 809 | const tree = await server.comments.getThread({ videoId: videoUUID, threadId }) |
840 | 810 | ||
841 | const tree: VideoCommentThreadTree = res2.body | ||
842 | expect(tree.comment.text).equal('my super first comment') | 811 | expect(tree.comment.text).equal('my super first comment') |
843 | expect(tree.comment.account.name).equal('root') | 812 | expect(tree.comment.account.name).equal('root') |
844 | expect(tree.comment.account.host).equal('localhost:' + servers[0].port) | 813 | expect(tree.comment.account.host).equal('localhost:' + servers[0].port) |
@@ -867,19 +836,17 @@ describe('Test multiple servers', function () { | |||
867 | it('Should delete a reply', async function () { | 836 | it('Should delete a reply', async function () { |
868 | this.timeout(10000) | 837 | this.timeout(10000) |
869 | 838 | ||
870 | await deleteVideoComment(servers[2].url, servers[2].accessToken, videoUUID, childOfFirstChild.comment.id) | 839 | await servers[2].comments.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id }) |
871 | 840 | ||
872 | await waitJobs(servers) | 841 | await waitJobs(servers) |
873 | }) | 842 | }) |
874 | 843 | ||
875 | it('Should have this comment marked as deleted', async function () { | 844 | it('Should have this comment marked as deleted', async function () { |
876 | for (const server of servers) { | 845 | for (const server of servers) { |
877 | const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5) | 846 | const { data } = await server.comments.listThreads({ videoId: videoUUID }) |
878 | const threadId = res1.body.data.find(c => c.text === 'my super first comment').id | 847 | const threadId = data.find(c => c.text === 'my super first comment').id |
879 | |||
880 | const res2 = await getVideoThreadComments(server.url, videoUUID, threadId) | ||
881 | 848 | ||
882 | const tree: VideoCommentThreadTree = res2.body | 849 | const tree = await server.comments.getThread({ videoId: videoUUID, threadId }) |
883 | expect(tree.comment.text).equal('my super first comment') | 850 | expect(tree.comment.text).equal('my super first comment') |
884 | 851 | ||
885 | const firstChild = tree.children[0] | 852 | const firstChild = tree.children[0] |
@@ -900,23 +867,23 @@ describe('Test multiple servers', function () { | |||
900 | it('Should delete the thread comments', async function () { | 867 | it('Should delete the thread comments', async function () { |
901 | this.timeout(10000) | 868 | this.timeout(10000) |
902 | 869 | ||
903 | const res = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5) | 870 | const { data } = await servers[0].comments.listThreads({ videoId: videoUUID }) |
904 | const threadId = res.body.data.find(c => c.text === 'my super first comment').id | 871 | const commentId = data.find(c => c.text === 'my super first comment').id |
905 | await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId) | 872 | await servers[0].comments.delete({ videoId: videoUUID, commentId }) |
906 | 873 | ||
907 | await waitJobs(servers) | 874 | await waitJobs(servers) |
908 | }) | 875 | }) |
909 | 876 | ||
910 | it('Should have the threads marked as deleted on other servers too', async function () { | 877 | it('Should have the threads marked as deleted on other servers too', async function () { |
911 | for (const server of servers) { | 878 | for (const server of servers) { |
912 | const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5) | 879 | const body = await server.comments.listThreads({ videoId: videoUUID }) |
913 | 880 | ||
914 | expect(res.body.total).to.equal(2) | 881 | expect(body.total).to.equal(2) |
915 | expect(res.body.data).to.be.an('array') | 882 | expect(body.data).to.be.an('array') |
916 | expect(res.body.data).to.have.lengthOf(2) | 883 | expect(body.data).to.have.lengthOf(2) |
917 | 884 | ||
918 | { | 885 | { |
919 | const comment: VideoComment = res.body.data[0] | 886 | const comment = body.data[0] |
920 | expect(comment).to.not.be.undefined | 887 | expect(comment).to.not.be.undefined |
921 | expect(comment.inReplyToCommentId).to.be.null | 888 | expect(comment.inReplyToCommentId).to.be.null |
922 | expect(comment.account.name).to.equal('root') | 889 | expect(comment.account.name).to.equal('root') |
@@ -927,7 +894,7 @@ describe('Test multiple servers', function () { | |||
927 | } | 894 | } |
928 | 895 | ||
929 | { | 896 | { |
930 | const deletedComment: VideoComment = res.body.data[1] | 897 | const deletedComment = body.data[1] |
931 | expect(deletedComment).to.not.be.undefined | 898 | expect(deletedComment).to.not.be.undefined |
932 | expect(deletedComment.isDeleted).to.be.true | 899 | expect(deletedComment.isDeleted).to.be.true |
933 | expect(deletedComment.deletedAt).to.not.be.null | 900 | expect(deletedComment.deletedAt).to.not.be.null |
@@ -945,22 +912,22 @@ describe('Test multiple servers', function () { | |||
945 | it('Should delete a remote thread by the origin server', async function () { | 912 | it('Should delete a remote thread by the origin server', async function () { |
946 | this.timeout(5000) | 913 | this.timeout(5000) |
947 | 914 | ||
948 | const res = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5) | 915 | const { data } = await servers[0].comments.listThreads({ videoId: videoUUID }) |
949 | const threadId = res.body.data.find(c => c.text === 'my super second comment').id | 916 | const commentId = data.find(c => c.text === 'my super second comment').id |
950 | await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId) | 917 | await servers[0].comments.delete({ videoId: videoUUID, commentId }) |
951 | 918 | ||
952 | await waitJobs(servers) | 919 | await waitJobs(servers) |
953 | }) | 920 | }) |
954 | 921 | ||
955 | it('Should have the threads marked as deleted on other servers too', async function () { | 922 | it('Should have the threads marked as deleted on other servers too', async function () { |
956 | for (const server of servers) { | 923 | for (const server of servers) { |
957 | const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5) | 924 | const body = await server.comments.listThreads({ videoId: videoUUID }) |
958 | 925 | ||
959 | expect(res.body.total).to.equal(2) | 926 | expect(body.total).to.equal(2) |
960 | expect(res.body.data).to.have.lengthOf(2) | 927 | expect(body.data).to.have.lengthOf(2) |
961 | 928 | ||
962 | { | 929 | { |
963 | const comment: VideoComment = res.body.data[0] | 930 | const comment = body.data[0] |
964 | expect(comment.text).to.equal('') | 931 | expect(comment.text).to.equal('') |
965 | expect(comment.isDeleted).to.be.true | 932 | expect(comment.isDeleted).to.be.true |
966 | expect(comment.createdAt).to.not.be.null | 933 | expect(comment.createdAt).to.not.be.null |
@@ -970,7 +937,7 @@ describe('Test multiple servers', function () { | |||
970 | } | 937 | } |
971 | 938 | ||
972 | { | 939 | { |
973 | const comment: VideoComment = res.body.data[1] | 940 | const comment = body.data[1] |
974 | expect(comment.text).to.equal('') | 941 | expect(comment.text).to.equal('') |
975 | expect(comment.isDeleted).to.be.true | 942 | expect(comment.isDeleted).to.be.true |
976 | expect(comment.createdAt).to.not.be.null | 943 | expect(comment.createdAt).to.not.be.null |
@@ -989,17 +956,17 @@ describe('Test multiple servers', function () { | |||
989 | downloadEnabled: false | 956 | downloadEnabled: false |
990 | } | 957 | } |
991 | 958 | ||
992 | await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes) | 959 | await servers[0].videos.update({ id: videoUUID, attributes }) |
993 | 960 | ||
994 | await waitJobs(servers) | 961 | await waitJobs(servers) |
995 | 962 | ||
996 | for (const server of servers) { | 963 | for (const server of servers) { |
997 | const res = await getVideo(server.url, videoUUID) | 964 | const video = await server.videos.get({ id: videoUUID }) |
998 | expect(res.body.commentsEnabled).to.be.false | 965 | expect(video.commentsEnabled).to.be.false |
999 | expect(res.body.downloadEnabled).to.be.false | 966 | expect(video.downloadEnabled).to.be.false |
1000 | 967 | ||
1001 | const text = 'my super forbidden comment' | 968 | const text = 'my super forbidden comment' |
1002 | await addVideoCommentThread(server.url, server.accessToken, videoUUID, text, HttpStatusCode.CONFLICT_409) | 969 | await server.comments.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 }) |
1003 | } | 970 | } |
1004 | }) | 971 | }) |
1005 | }) | 972 | }) |
@@ -1024,8 +991,8 @@ describe('Test multiple servers', function () { | |||
1024 | await waitJobs(servers) | 991 | await waitJobs(servers) |
1025 | 992 | ||
1026 | for (const server of servers) { | 993 | for (const server of servers) { |
1027 | const res = await getVideosList(server.url) | 994 | const { data } = await server.videos.list() |
1028 | const video = res.body.data.find(v => v.name === 'minimum parameters') | 995 | const video = data.find(v => v.name === 'minimum parameters') |
1029 | 996 | ||
1030 | const isLocal = server.url === 'http://localhost:' + servers[1].port | 997 | const isLocal = server.url === 'http://localhost:' + servers[1].port |
1031 | const checkAttributes = { | 998 | const checkAttributes = { |
@@ -1072,7 +1039,7 @@ describe('Test multiple servers', function () { | |||
1072 | } | 1039 | } |
1073 | ] | 1040 | ] |
1074 | } | 1041 | } |
1075 | await completeVideoCheck(server.url, video, checkAttributes) | 1042 | await completeVideoCheck(server, video, checkAttributes) |
1076 | } | 1043 | } |
1077 | }) | 1044 | }) |
1078 | }) | 1045 | }) |