aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-15 10:02:54 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commitd23dd9fbfc4d26026352c10f81d2795ceaf2908a (patch)
treeda82286d423c5e834a1ee2dcd5970076b8263cf1 /server/tests/api/videos
parent7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (diff)
downloadPeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.gz
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.zst
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.zip
Introduce videos command
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/audio-only.ts20
-rw-r--r--server/tests/api/videos/multiple-servers.ts334
-rw-r--r--server/tests/api/videos/resumable-upload.ts10
-rw-r--r--server/tests/api/videos/single-server.ts276
-rw-r--r--server/tests/api/videos/video-captions.ts8
-rw-r--r--server/tests/api/videos/video-change-ownership.ts38
-rw-r--r--server/tests/api/videos/video-channels.ts69
-rw-r--r--server/tests/api/videos/video-comments.ts9
-rw-r--r--server/tests/api/videos/video-description.ts41
-rw-r--r--server/tests/api/videos/video-hls.ts32
-rw-r--r--server/tests/api/videos/video-imports.ts54
-rw-r--r--server/tests/api/videos/video-nsfw.ts40
-rw-r--r--server/tests/api/videos/video-playlist-thumbnails.ts5
-rw-r--r--server/tests/api/videos/video-playlists.ts19
-rw-r--r--server/tests/api/videos/video-privacy.ts146
-rw-r--r--server/tests/api/videos/video-schedule-update.ts69
-rw-r--r--server/tests/api/videos/video-transcoder.ts208
-rw-r--r--server/tests/api/videos/videos-filter.ts20
-rw-r--r--server/tests/api/videos/videos-history.ts38
-rw-r--r--server/tests/api/videos/videos-overview.ts22
-rw-r--r--server/tests/api/videos/videos-views-cleaner.ts14
21 files changed, 642 insertions, 830 deletions
diff --git a/server/tests/api/videos/audio-only.ts b/server/tests/api/videos/audio-only.ts
index 9b516af81..e31905b36 100644
--- a/server/tests/api/videos/audio-only.ts
+++ b/server/tests/api/videos/audio-only.ts
@@ -4,17 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { join } from 'path' 5import { join } from 'path'
6import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils' 6import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils'
7import { 7import { cleanupTests, doubleFollow, flushAndRunMultipleServers, ServerInfo, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
8 cleanupTests,
9 doubleFollow,
10 flushAndRunMultipleServers,
11 getVideo,
12 ServerInfo,
13 setAccessTokensToServers,
14 uploadVideo,
15 waitJobs
16} from '../../../../shared/extra-utils'
17import { VideoDetails } from '../../../../shared/models/videos'
18 8
19const expect = chai.expect 9const expect = chai.expect
20 10
@@ -58,15 +48,13 @@ describe('Test audio only video transcoding', function () {
58 it('Should upload a video and transcode it', async function () { 48 it('Should upload a video and transcode it', async function () {
59 this.timeout(120000) 49 this.timeout(120000)
60 50
61 const resUpload = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'audio only' }) 51 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'audio only' } })
62 videoUUID = resUpload.body.video.uuid 52 videoUUID = uuid
63 53
64 await waitJobs(servers) 54 await waitJobs(servers)
65 55
66 for (const server of servers) { 56 for (const server of servers) {
67 const res = await getVideo(server.url, videoUUID) 57 const video = await server.videosCommand.get({ id: videoUUID })
68 const video: VideoDetails = res.body
69
70 expect(video.streamingPlaylists).to.have.lengthOf(1) 58 expect(video.streamingPlaylists).to.have.lengthOf(1)
71 59
72 for (const files of [ video.files, video.streamingPlaylists[0].files ]) { 60 for (const files of [ video.files, video.streamingPlaylists[0].files ]) {
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 169bb2e23..5c13ac629 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -13,17 +13,9 @@ import {
13 dateIsValid, 13 dateIsValid,
14 doubleFollow, 14 doubleFollow,
15 flushAndRunMultipleServers, 15 flushAndRunMultipleServers,
16 getLocalVideos,
17 getVideo,
18 getVideosList,
19 rateVideo,
20 removeVideo,
21 ServerInfo, 16 ServerInfo,
22 setAccessTokensToServers, 17 setAccessTokensToServers,
23 testImage, 18 testImage,
24 updateVideo,
25 uploadVideo,
26 viewVideo,
27 wait, 19 wait,
28 waitJobs, 20 waitJobs,
29 webtorrentAdd 21 webtorrentAdd
@@ -67,10 +59,9 @@ describe('Test multiple servers', function () {
67 59
68 it('Should not have videos for all servers', async function () { 60 it('Should not have videos for all servers', async function () {
69 for (const server of servers) { 61 for (const server of servers) {
70 const res = await getVideosList(server.url) 62 const { data } = await server.videosCommand.list()
71 const videos = res.body.data 63 expect(data).to.be.an('array')
72 expect(videos).to.be.an('array') 64 expect(data.length).to.equal(0)
73 expect(videos.length).to.equal(0)
74 } 65 }
75 }) 66 })
76 67
@@ -78,7 +69,7 @@ describe('Test multiple servers', function () {
78 it('Should upload the video on server 1 and propagate on each server', async function () { 69 it('Should upload the video on server 1 and propagate on each server', async function () {
79 this.timeout(25000) 70 this.timeout(25000)
80 71
81 const videoAttributes = { 72 const attributes = {
82 name: 'my super name for server 1', 73 name: 'my super name for server 1',
83 category: 5, 74 category: 5,
84 licence: 4, 75 licence: 4,
@@ -91,7 +82,7 @@ describe('Test multiple servers', function () {
91 channelId: videoChannelId, 82 channelId: videoChannelId,
92 fixture: 'video_short1.webm' 83 fixture: 'video_short1.webm'
93 } 84 }
94 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) 85 await servers[0].videosCommand.upload({ attributes })
95 86
96 await waitJobs(servers) 87 await waitJobs(servers)
97 88
@@ -134,14 +125,13 @@ describe('Test multiple servers', function () {
134 ] 125 ]
135 } 126 }
136 127
137 const res = await getVideosList(server.url) 128 const { data } = await server.videosCommand.list()
138 const videos = res.body.data 129 expect(data).to.be.an('array')
139 expect(videos).to.be.an('array') 130 expect(data.length).to.equal(1)
140 expect(videos.length).to.equal(1) 131 const video = data[0]
141 const video = videos[0]
142 132
143 await completeVideoCheck(server.url, video, checkAttributes) 133 await completeVideoCheck(server, video, checkAttributes)
144 publishedAt = video.publishedAt 134 publishedAt = video.publishedAt as string
145 } 135 }
146 }) 136 })
147 137
@@ -155,7 +145,7 @@ describe('Test multiple servers', function () {
155 await servers[1].usersCommand.create({ username: user.username, password: user.password }) 145 await servers[1].usersCommand.create({ username: user.username, password: user.password })
156 const userAccessToken = await servers[1].loginCommand.getAccessToken(user) 146 const userAccessToken = await servers[1].loginCommand.getAccessToken(user)
157 147
158 const videoAttributes = { 148 const attributes = {
159 name: 'my super name for server 2', 149 name: 'my super name for server 2',
160 category: 4, 150 category: 4,
161 licence: 3, 151 licence: 3,
@@ -168,7 +158,7 @@ describe('Test multiple servers', function () {
168 thumbnailfile: 'thumbnail.jpg', 158 thumbnailfile: 'thumbnail.jpg',
169 previewfile: 'preview.jpg' 159 previewfile: 'preview.jpg'
170 } 160 }
171 await uploadVideo(servers[1].url, userAccessToken, videoAttributes, HttpStatusCode.OK_200, 'resumable') 161 await servers[1].videosCommand.upload({ token: userAccessToken, attributes, mode: 'resumable' })
172 162
173 // Transcoding 163 // Transcoding
174 await waitJobs(servers) 164 await waitJobs(servers)
@@ -223,65 +213,67 @@ describe('Test multiple servers', function () {
223 previewfile: 'preview' 213 previewfile: 'preview'
224 } 214 }
225 215
226 const res = await getVideosList(server.url) 216 const { data } = await server.videosCommand.list()
227 const videos = res.body.data 217 expect(data).to.be.an('array')
228 expect(videos).to.be.an('array') 218 expect(data.length).to.equal(2)
229 expect(videos.length).to.equal(2) 219 const video = data[1]
230 const video = videos[1]
231 220
232 await completeVideoCheck(server.url, video, checkAttributes) 221 await completeVideoCheck(server, video, checkAttributes)
233 } 222 }
234 }) 223 })
235 224
236 it('Should upload two videos on server 3 and propagate on each server', async function () { 225 it('Should upload two videos on server 3 and propagate on each server', async function () {
237 this.timeout(45000) 226 this.timeout(45000)
238 227
239 const videoAttributes1 = { 228 {
240 name: 'my super name for server 3', 229 const attributes = {
241 category: 6, 230 name: 'my super name for server 3',
242 licence: 5, 231 category: 6,
243 language: 'de', 232 licence: 5,
244 nsfw: true, 233 language: 'de',
245 description: 'my super description for server 3', 234 nsfw: true,
246 support: 'my super support text for server 3', 235 description: 'my super description for server 3',
247 tags: [ 'tag1p3' ], 236 support: 'my super support text for server 3',
248 fixture: 'video_short3.webm' 237 tags: [ 'tag1p3' ],
238 fixture: 'video_short3.webm'
239 }
240 await servers[2].videosCommand.upload({ attributes })
249 } 241 }
250 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1) 242
251 243 {
252 const videoAttributes2 = { 244 const attributes = {
253 name: 'my super name for server 3-2', 245 name: 'my super name for server 3-2',
254 category: 7, 246 category: 7,
255 licence: 6, 247 licence: 6,
256 language: 'ko', 248 language: 'ko',
257 nsfw: false, 249 nsfw: false,
258 description: 'my super description for server 3-2', 250 description: 'my super description for server 3-2',
259 support: 'my super support text for server 3-2', 251 support: 'my super support text for server 3-2',
260 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], 252 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
261 fixture: 'video_short.webm' 253 fixture: 'video_short.webm'
254 }
255 await servers[2].videosCommand.upload({ attributes })
262 } 256 }
263 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2)
264 257
265 await waitJobs(servers) 258 await waitJobs(servers)
266 259
267 // All servers should have this video 260 // All servers should have this video
268 for (const server of servers) { 261 for (const server of servers) {
269 const isLocal = server.url === 'http://localhost:' + servers[2].port 262 const isLocal = server.url === 'http://localhost:' + servers[2].port
270 const res = await getVideosList(server.url) 263 const { data } = await server.videosCommand.list()
271 264
272 const videos = res.body.data 265 expect(data).to.be.an('array')
273 expect(videos).to.be.an('array') 266 expect(data.length).to.equal(4)
274 expect(videos.length).to.equal(4)
275 267
276 // We not sure about the order of the two last uploads 268 // We not sure about the order of the two last uploads
277 let video1 = null 269 let video1 = null
278 let video2 = null 270 let video2 = null
279 if (videos[2].name === 'my super name for server 3') { 271 if (data[2].name === 'my super name for server 3') {
280 video1 = videos[2] 272 video1 = data[2]
281 video2 = videos[3] 273 video2 = data[3]
282 } else { 274 } else {
283 video1 = videos[3] 275 video1 = data[3]
284 video2 = videos[2] 276 video2 = data[2]
285 } 277 }
286 278
287 const checkAttributesVideo1 = { 279 const checkAttributesVideo1 = {
@@ -316,7 +308,7 @@ describe('Test multiple servers', function () {
316 } 308 }
317 ] 309 ]
318 } 310 }
319 await completeVideoCheck(server.url, video1, checkAttributesVideo1) 311 await completeVideoCheck(server, video1, checkAttributesVideo1)
320 312
321 const checkAttributesVideo2 = { 313 const checkAttributesVideo2 = {
322 name: 'my super name for server 3-2', 314 name: 'my super name for server 3-2',
@@ -350,38 +342,38 @@ describe('Test multiple servers', function () {
350 } 342 }
351 ] 343 ]
352 } 344 }
353 await completeVideoCheck(server.url, video2, checkAttributesVideo2) 345 await completeVideoCheck(server, video2, checkAttributesVideo2)
354 } 346 }
355 }) 347 })
356 }) 348 })
357 349
358 describe('It should list local videos', function () { 350 describe('It should list local videos', function () {
359 it('Should list only local videos on server 1', async function () { 351 it('Should list only local videos on server 1', async function () {
360 const { body } = await getLocalVideos(servers[0].url) 352 const { data, total } = await servers[0].videosCommand.list({ filter: 'local' })
361 353
362 expect(body.total).to.equal(1) 354 expect(total).to.equal(1)
363 expect(body.data).to.be.an('array') 355 expect(data).to.be.an('array')
364 expect(body.data.length).to.equal(1) 356 expect(data.length).to.equal(1)
365 expect(body.data[0].name).to.equal('my super name for server 1') 357 expect(data[0].name).to.equal('my super name for server 1')
366 }) 358 })
367 359
368 it('Should list only local videos on server 2', async function () { 360 it('Should list only local videos on server 2', async function () {
369 const { body } = await getLocalVideos(servers[1].url) 361 const { data, total } = await servers[1].videosCommand.list({ filter: 'local' })
370 362
371 expect(body.total).to.equal(1) 363 expect(total).to.equal(1)
372 expect(body.data).to.be.an('array') 364 expect(data).to.be.an('array')
373 expect(body.data.length).to.equal(1) 365 expect(data.length).to.equal(1)
374 expect(body.data[0].name).to.equal('my super name for server 2') 366 expect(data[0].name).to.equal('my super name for server 2')
375 }) 367 })
376 368
377 it('Should list only local videos on server 3', async function () { 369 it('Should list only local videos on server 3', async function () {
378 const { body } = await getLocalVideos(servers[2].url) 370 const { data, total } = await servers[2].videosCommand.list({ filter: 'local' })
379 371
380 expect(body.total).to.equal(2) 372 expect(total).to.equal(2)
381 expect(body.data).to.be.an('array') 373 expect(data).to.be.an('array')
382 expect(body.data.length).to.equal(2) 374 expect(data.length).to.equal(2)
383 expect(body.data[0].name).to.equal('my super name for server 3') 375 expect(data[0].name).to.equal('my super name for server 3')
384 expect(body.data[1].name).to.equal('my super name for server 3-2') 376 expect(data[1].name).to.equal('my super name for server 3-2')
385 }) 377 })
386 }) 378 })
387 379
@@ -389,15 +381,13 @@ describe('Test multiple servers', function () {
389 it('Should add the file 1 by asking server 3', async function () { 381 it('Should add the file 1 by asking server 3', async function () {
390 this.timeout(10000) 382 this.timeout(10000)
391 383
392 const res = await getVideosList(servers[2].url) 384 const { data } = await servers[2].videosCommand.list()
393
394 const video = res.body.data[0]
395 toRemove.push(res.body.data[2])
396 toRemove.push(res.body.data[3])
397 385
398 const res2 = await getVideo(servers[2].url, video.id) 386 const video = data[0]
399 const videoDetails = res2.body 387 toRemove.push(data[2])
388 toRemove.push(data[3])
400 389
390 const videoDetails = await servers[2].videosCommand.get({ id: video.id })
401 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) 391 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
402 expect(torrent.files).to.be.an('array') 392 expect(torrent.files).to.be.an('array')
403 expect(torrent.files.length).to.equal(1) 393 expect(torrent.files.length).to.equal(1)
@@ -407,11 +397,10 @@ describe('Test multiple servers', function () {
407 it('Should add the file 2 by asking server 1', async function () { 397 it('Should add the file 2 by asking server 1', async function () {
408 this.timeout(10000) 398 this.timeout(10000)
409 399
410 const res = await getVideosList(servers[0].url) 400 const { data } = await servers[0].videosCommand.list()
411 401
412 const video = res.body.data[1] 402 const video = data[1]
413 const res2 = await getVideo(servers[0].url, video.id) 403 const videoDetails = await servers[0].videosCommand.get({ id: video.id })
414 const videoDetails = res2.body
415 404
416 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) 405 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
417 expect(torrent.files).to.be.an('array') 406 expect(torrent.files).to.be.an('array')
@@ -422,11 +411,10 @@ describe('Test multiple servers', function () {
422 it('Should add the file 3 by asking server 2', async function () { 411 it('Should add the file 3 by asking server 2', async function () {
423 this.timeout(10000) 412 this.timeout(10000)
424 413
425 const res = await getVideosList(servers[1].url) 414 const { data } = await servers[1].videosCommand.list()
426 415
427 const video = res.body.data[2] 416 const video = data[2]
428 const res2 = await getVideo(servers[1].url, video.id) 417 const videoDetails = await servers[1].videosCommand.get({ id: video.id })
429 const videoDetails = res2.body
430 418
431 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) 419 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
432 expect(torrent.files).to.be.an('array') 420 expect(torrent.files).to.be.an('array')
@@ -437,11 +425,10 @@ describe('Test multiple servers', function () {
437 it('Should add the file 3-2 by asking server 1', async function () { 425 it('Should add the file 3-2 by asking server 1', async function () {
438 this.timeout(10000) 426 this.timeout(10000)
439 427
440 const res = await getVideosList(servers[0].url) 428 const { data } = await servers[0].videosCommand.list()
441 429
442 const video = res.body.data[3] 430 const video = data[3]
443 const res2 = await getVideo(servers[0].url, video.id) 431 const videoDetails = await servers[0].videosCommand.get({ id: video.id })
444 const videoDetails = res2.body
445 432
446 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri) 433 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
447 expect(torrent.files).to.be.an('array') 434 expect(torrent.files).to.be.an('array')
@@ -452,11 +439,10 @@ describe('Test multiple servers', function () {
452 it('Should add the file 2 in 360p by asking server 1', async function () { 439 it('Should add the file 2 in 360p by asking server 1', async function () {
453 this.timeout(10000) 440 this.timeout(10000)
454 441
455 const res = await getVideosList(servers[0].url) 442 const { data } = await servers[0].videosCommand.list()
456 443
457 const video = res.body.data.find(v => v.name === 'my super name for server 2') 444 const video = data.find(v => v.name === 'my super name for server 2')
458 const res2 = await getVideo(servers[0].url, video.id) 445 const videoDetails = await servers[0].videosCommand.get({ id: video.id })
459 const videoDetails = res2.body
460 446
461 const file = videoDetails.files.find(f => f.resolution.id === 360) 447 const file = videoDetails.files.find(f => f.resolution.id === 360)
462 expect(file).not.to.be.undefined 448 expect(file).not.to.be.undefined
@@ -475,30 +461,36 @@ describe('Test multiple servers', function () {
475 let remoteVideosServer3 = [] 461 let remoteVideosServer3 = []
476 462
477 before(async function () { 463 before(async function () {
478 const res1 = await getVideosList(servers[0].url) 464 {
479 remoteVideosServer1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.uuid) 465 const { data } = await servers[0].videosCommand.list()
466 remoteVideosServer1 = data.filter(video => video.isLocal === false).map(video => video.uuid)
467 }
480 468
481 const res2 = await getVideosList(servers[1].url) 469 {
482 remoteVideosServer2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.uuid) 470 const { data } = await servers[1].videosCommand.list()
471 remoteVideosServer2 = data.filter(video => video.isLocal === false).map(video => video.uuid)
472 }
483 473
484 const res3 = await getVideosList(servers[2].url) 474 {
485 localVideosServer3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.uuid) 475 const { data } = await servers[2].videosCommand.list()
486 remoteVideosServer3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.uuid) 476 localVideosServer3 = data.filter(video => video.isLocal === true).map(video => video.uuid)
477 remoteVideosServer3 = data.filter(video => video.isLocal === false).map(video => video.uuid)
478 }
487 }) 479 })
488 480
489 it('Should view multiple videos on owned servers', async function () { 481 it('Should view multiple videos on owned servers', async function () {
490 this.timeout(30000) 482 this.timeout(30000)
491 483
492 await viewVideo(servers[2].url, localVideosServer3[0]) 484 await servers[2].videosCommand.view({ id: localVideosServer3[0] })
493 await wait(1000) 485 await wait(1000)
494 486
495 await viewVideo(servers[2].url, localVideosServer3[0]) 487 await servers[2].videosCommand.view({ id: localVideosServer3[0] })
496 await viewVideo(servers[2].url, localVideosServer3[1]) 488 await servers[2].videosCommand.view({ id: localVideosServer3[1] })
497 489
498 await wait(1000) 490 await wait(1000)
499 491
500 await viewVideo(servers[2].url, localVideosServer3[0]) 492 await servers[2].videosCommand.view({ id: localVideosServer3[0] })
501 await viewVideo(servers[2].url, localVideosServer3[0]) 493 await servers[2].videosCommand.view({ id: localVideosServer3[0] })
502 494
503 await waitJobs(servers) 495 await waitJobs(servers)
504 496
@@ -508,11 +500,10 @@ describe('Test multiple servers', function () {
508 await waitJobs(servers) 500 await waitJobs(servers)
509 501
510 for (const server of servers) { 502 for (const server of servers) {
511 const res = await getVideosList(server.url) 503 const { data } = await server.videosCommand.list()
512 504
513 const videos = res.body.data 505 const video0 = data.find(v => v.uuid === localVideosServer3[0])
514 const video0 = videos.find(v => v.uuid === localVideosServer3[0]) 506 const video1 = data.find(v => v.uuid === localVideosServer3[1])
515 const video1 = videos.find(v => v.uuid === localVideosServer3[1])
516 507
517 expect(video0.views).to.equal(3) 508 expect(video0.views).to.equal(3)
518 expect(video1.views).to.equal(1) 509 expect(video1.views).to.equal(1)
@@ -523,16 +514,16 @@ describe('Test multiple servers', function () {
523 this.timeout(45000) 514 this.timeout(45000)
524 515
525 const tasks: Promise<any>[] = [] 516 const tasks: Promise<any>[] = []
526 tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0])) 517 tasks.push(servers[0].videosCommand.view({ id: remoteVideosServer1[0] }))
527 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0])) 518 tasks.push(servers[1].videosCommand.view({ id: remoteVideosServer2[0] }))
528 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0])) 519 tasks.push(servers[1].videosCommand.view({ id: remoteVideosServer2[0] }))
529 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0])) 520 tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[0] }))
530 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1])) 521 tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[1] }))
531 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1])) 522 tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[1] }))
532 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1])) 523 tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[1] }))
533 tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) 524 tasks.push(servers[2].videosCommand.view({ id: localVideosServer3[1] }))
534 tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) 525 tasks.push(servers[2].videosCommand.view({ id: localVideosServer3[1] }))
535 tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) 526 tasks.push(servers[2].videosCommand.view({ id: localVideosServer3[1] }))
536 527
537 await Promise.all(tasks) 528 await Promise.all(tasks)
538 529
@@ -546,18 +537,16 @@ describe('Test multiple servers', function () {
546 let baseVideos = null 537 let baseVideos = null
547 538
548 for (const server of servers) { 539 for (const server of servers) {
549 const res = await getVideosList(server.url) 540 const { data } = await server.videosCommand.list()
550
551 const videos = res.body.data
552 541
553 // Initialize base videos for future comparisons 542 // Initialize base videos for future comparisons
554 if (baseVideos === null) { 543 if (baseVideos === null) {
555 baseVideos = videos 544 baseVideos = data
556 continue 545 continue
557 } 546 }
558 547
559 for (const baseVideo of baseVideos) { 548 for (const baseVideo of baseVideos) {
560 const sameVideo = videos.find(video => video.name === baseVideo.name) 549 const sameVideo = data.find(video => video.name === baseVideo.name)
561 expect(baseVideo.views).to.equal(sameVideo.views) 550 expect(baseVideo.views).to.equal(sameVideo.views)
562 } 551 }
563 } 552 }
@@ -566,17 +555,17 @@ describe('Test multiple servers', function () {
566 it('Should like and dislikes videos on different services', async function () { 555 it('Should like and dislikes videos on different services', async function () {
567 this.timeout(50000) 556 this.timeout(50000)
568 557
569 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like') 558 await servers[0].videosCommand.rate({ id: remoteVideosServer1[0], rating: 'like' })
570 await wait(500) 559 await wait(500)
571 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike') 560 await servers[0].videosCommand.rate({ id: remoteVideosServer1[0], rating: 'dislike' })
572 await wait(500) 561 await wait(500)
573 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like') 562 await servers[0].videosCommand.rate({ id: remoteVideosServer1[0], rating: 'like' })
574 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like') 563 await servers[2].videosCommand.rate({ id: localVideosServer3[1], rating: 'like' })
575 await wait(500) 564 await wait(500)
576 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike') 565 await servers[2].videosCommand.rate({ id: localVideosServer3[1], rating: 'dislike' })
577 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike') 566 await servers[2].videosCommand.rate({ id: remoteVideosServer3[1], rating: 'dislike' })
578 await wait(500) 567 await wait(500)
579 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like') 568 await servers[2].videosCommand.rate({ id: remoteVideosServer3[0], rating: 'like' })
580 569
581 await waitJobs(servers) 570 await waitJobs(servers)
582 await wait(5000) 571 await wait(5000)
@@ -584,18 +573,16 @@ describe('Test multiple servers', function () {
584 573
585 let baseVideos = null 574 let baseVideos = null
586 for (const server of servers) { 575 for (const server of servers) {
587 const res = await getVideosList(server.url) 576 const { data } = await server.videosCommand.list()
588
589 const videos = res.body.data
590 577
591 // Initialize base videos for future comparisons 578 // Initialize base videos for future comparisons
592 if (baseVideos === null) { 579 if (baseVideos === null) {
593 baseVideos = videos 580 baseVideos = data
594 continue 581 continue
595 } 582 }
596 583
597 for (const baseVideo of baseVideos) { 584 for (const baseVideo of baseVideos) {
598 const sameVideo = videos.find(video => video.name === baseVideo.name) 585 const sameVideo = data.find(video => video.name === baseVideo.name)
599 expect(baseVideo.likes).to.equal(sameVideo.likes) 586 expect(baseVideo.likes).to.equal(sameVideo.likes)
600 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes) 587 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
601 } 588 }
@@ -621,7 +608,7 @@ describe('Test multiple servers', function () {
621 previewfile: 'preview.jpg' 608 previewfile: 'preview.jpg'
622 } 609 }
623 610
624 await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes) 611 await servers[2].videosCommand.update({ id: toRemove[0].id, attributes })
625 612
626 await waitJobs(servers) 613 await waitJobs(servers)
627 }) 614 })
@@ -630,10 +617,9 @@ describe('Test multiple servers', function () {
630 this.timeout(10000) 617 this.timeout(10000)
631 618
632 for (const server of servers) { 619 for (const server of servers) {
633 const res = await getVideosList(server.url) 620 const { data } = await server.videosCommand.list()
634 621
635 const videos = res.body.data 622 const videoUpdated = data.find(video => video.name === 'my super video updated')
636 const videoUpdated = videos.find(video => video.name === 'my super video updated')
637 expect(!!videoUpdated).to.be.true 623 expect(!!videoUpdated).to.be.true
638 624
639 const isLocal = server.url === 'http://localhost:' + servers[2].port 625 const isLocal = server.url === 'http://localhost:' + servers[2].port
@@ -672,15 +658,15 @@ describe('Test multiple servers', function () {
672 thumbnailfile: 'thumbnail', 658 thumbnailfile: 'thumbnail',
673 previewfile: 'preview' 659 previewfile: 'preview'
674 } 660 }
675 await completeVideoCheck(server.url, videoUpdated, checkAttributes) 661 await completeVideoCheck(server, videoUpdated, checkAttributes)
676 } 662 }
677 }) 663 })
678 664
679 it('Should remove the videos 3 and 3-2 by asking server 3', async function () { 665 it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
680 this.timeout(10000) 666 this.timeout(10000)
681 667
682 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id) 668 await servers[2].videosCommand.remove({ id: toRemove[0].id })
683 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id) 669 await servers[2].videosCommand.remove({ id: toRemove[1].id })
684 670
685 await waitJobs(servers) 671 await waitJobs(servers)
686 }) 672 })
@@ -694,27 +680,24 @@ describe('Test multiple servers', function () {
694 680
695 it('Should have videos 1 and 3 on each server', async function () { 681 it('Should have videos 1 and 3 on each server', async function () {
696 for (const server of servers) { 682 for (const server of servers) {
697 const res = await getVideosList(server.url) 683 const { data } = await server.videosCommand.list()
698 684
699 const videos = res.body.data 685 expect(data).to.be.an('array')
700 expect(videos).to.be.an('array') 686 expect(data.length).to.equal(2)
701 expect(videos.length).to.equal(2) 687 expect(data[0].name).not.to.equal(data[1].name)
702 expect(videos[0].name).not.to.equal(videos[1].name) 688 expect(data[0].name).not.to.equal(toRemove[0].name)
703 expect(videos[0].name).not.to.equal(toRemove[0].name) 689 expect(data[1].name).not.to.equal(toRemove[0].name)
704 expect(videos[1].name).not.to.equal(toRemove[0].name) 690 expect(data[0].name).not.to.equal(toRemove[1].name)
705 expect(videos[0].name).not.to.equal(toRemove[1].name) 691 expect(data[1].name).not.to.equal(toRemove[1].name)
706 expect(videos[1].name).not.to.equal(toRemove[1].name) 692
707 693 videoUUID = data.find(video => video.name === 'my super name for server 1').uuid
708 videoUUID = videos.find(video => video.name === 'my super name for server 1').uuid
709 } 694 }
710 }) 695 })
711 696
712 it('Should get the same video by UUID on each server', async function () { 697 it('Should get the same video by UUID on each server', async function () {
713 let baseVideo = null 698 let baseVideo = null
714 for (const server of servers) { 699 for (const server of servers) {
715 const res = await getVideo(server.url, videoUUID) 700 const video = await server.videosCommand.get({ id: videoUUID })
716
717 const video = res.body
718 701
719 if (baseVideo === null) { 702 if (baseVideo === null) {
720 baseVideo = video 703 baseVideo = video
@@ -737,8 +720,7 @@ describe('Test multiple servers', function () {
737 720
738 it('Should get the preview from each server', async function () { 721 it('Should get the preview from each server', async function () {
739 for (const server of servers) { 722 for (const server of servers) {
740 const res = await getVideo(server.url, videoUUID) 723 const video = await server.videosCommand.get({ id: videoUUID })
741 const video = res.body
742 724
743 await testImage(server.url, 'video_short1-preview.webm', video.previewPath) 725 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
744 } 726 }
@@ -975,14 +957,14 @@ describe('Test multiple servers', function () {
975 downloadEnabled: false 957 downloadEnabled: false
976 } 958 }
977 959
978 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes) 960 await servers[0].videosCommand.update({ id: videoUUID, attributes })
979 961
980 await waitJobs(servers) 962 await waitJobs(servers)
981 963
982 for (const server of servers) { 964 for (const server of servers) {
983 const res = await getVideo(server.url, videoUUID) 965 const video = await server.videosCommand.get({ id: videoUUID })
984 expect(res.body.commentsEnabled).to.be.false 966 expect(video.commentsEnabled).to.be.false
985 expect(res.body.downloadEnabled).to.be.false 967 expect(video.downloadEnabled).to.be.false
986 968
987 const text = 'my super forbidden comment' 969 const text = 'my super forbidden comment'
988 await server.commentsCommand.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 }) 970 await server.commentsCommand.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 })
@@ -1010,8 +992,8 @@ describe('Test multiple servers', function () {
1010 await waitJobs(servers) 992 await waitJobs(servers)
1011 993
1012 for (const server of servers) { 994 for (const server of servers) {
1013 const res = await getVideosList(server.url) 995 const { data } = await server.videosCommand.list()
1014 const video = res.body.data.find(v => v.name === 'minimum parameters') 996 const video = data.find(v => v.name === 'minimum parameters')
1015 997
1016 const isLocal = server.url === 'http://localhost:' + servers[1].port 998 const isLocal = server.url === 'http://localhost:' + servers[1].port
1017 const checkAttributes = { 999 const checkAttributes = {
@@ -1058,7 +1040,7 @@ describe('Test multiple servers', function () {
1058 } 1040 }
1059 ] 1041 ]
1060 } 1042 }
1061 await completeVideoCheck(server.url, video, checkAttributes) 1043 await completeVideoCheck(server, video, checkAttributes)
1062 } 1044 }
1063 }) 1045 })
1064 }) 1046 })
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts
index 642c115d0..b7756a4a8 100644
--- a/server/tests/api/videos/resumable-upload.ts
+++ b/server/tests/api/videos/resumable-upload.ts
@@ -9,8 +9,6 @@ import {
9 buildAbsoluteFixturePath, 9 buildAbsoluteFixturePath,
10 cleanupTests, 10 cleanupTests,
11 flushAndRunServer, 11 flushAndRunServer,
12 prepareResumableUpload,
13 sendResumableChunks,
14 ServerInfo, 12 ServerInfo,
15 setAccessTokensToServers, 13 setAccessTokensToServers,
16 setDefaultVideoChannel 14 setDefaultVideoChannel
@@ -45,7 +43,7 @@ describe('Test resumable upload', function () {
45 43
46 const mimetype = 'video/mp4' 44 const mimetype = 'video/mp4'
47 45
48 const res = await prepareResumableUpload({ url: server.url, token: server.accessToken, attributes, size, mimetype }) 46 const res = await server.videosCommand.prepareResumableUpload({ attributes, size, mimetype })
49 47
50 return res.header['location'].split('?')[1] 48 return res.header['location'].split('?')[1]
51 } 49 }
@@ -63,15 +61,13 @@ describe('Test resumable upload', function () {
63 const size = await buildSize(defaultFixture, options.size) 61 const size = await buildSize(defaultFixture, options.size)
64 const absoluteFilePath = buildAbsoluteFixturePath(defaultFixture) 62 const absoluteFilePath = buildAbsoluteFixturePath(defaultFixture)
65 63
66 return sendResumableChunks({ 64 return server.videosCommand.sendResumableChunks({
67 url: server.url,
68 token: server.accessToken,
69 pathUploadId, 65 pathUploadId,
70 videoFilePath: absoluteFilePath, 66 videoFilePath: absoluteFilePath,
71 size, 67 size,
72 contentLength, 68 contentLength,
73 contentRangeBuilder, 69 contentRangeBuilder,
74 specialStatus: expectedStatus 70 expectedStatus
75 }) 71 })
76 } 72 }
77 73
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts
index af1703e02..da0b2011e 100644
--- a/server/tests/api/videos/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -2,34 +2,17 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { keyBy } from 'lodash'
6
7import { 5import {
8 checkVideoFilesWereRemoved, 6 checkVideoFilesWereRemoved,
9 cleanupTests, 7 cleanupTests,
10 completeVideoCheck, 8 completeVideoCheck,
11 flushAndRunServer, 9 flushAndRunServer,
12 getVideo,
13 getVideoCategories,
14 getVideoLanguages,
15 getVideoLicences,
16 getVideoPrivacies,
17 getVideosList,
18 getVideosListPagination,
19 getVideosListSort,
20 getVideosWithFilters,
21 rateVideo,
22 removeVideo,
23 ServerInfo, 10 ServerInfo,
24 setAccessTokensToServers, 11 setAccessTokensToServers,
25 testImage, 12 testImage,
26 updateVideo,
27 uploadVideo,
28 viewVideo,
29 wait 13 wait
30} from '../../../../shared/extra-utils' 14} from '@shared/extra-utils'
31import { VideoPrivacy } from '../../../../shared/models/videos' 15import { Video, VideoPrivacy } from '@shared/models'
32import { HttpStatusCode } from '@shared/core-utils'
33 16
34const expect = chai.expect 17const expect = chai.expect
35 18
@@ -37,8 +20,8 @@ describe('Test a single server', function () {
37 20
38 function runSuite (mode: 'legacy' | 'resumable') { 21 function runSuite (mode: 'legacy' | 'resumable') {
39 let server: ServerInfo = null 22 let server: ServerInfo = null
40 let videoId = -1 23 let videoId: number | string
41 let videoId2 = -1 24 let videoId2: string
42 let videoUUID = '' 25 let videoUUID = ''
43 let videosListBase: any[] = null 26 let videosListBase: any[] = null
44 27
@@ -117,128 +100,116 @@ describe('Test a single server', function () {
117 }) 100 })
118 101
119 it('Should list video categories', async function () { 102 it('Should list video categories', async function () {
120 const res = await getVideoCategories(server.url) 103 const categories = await server.videosCommand.getCategories()
121
122 const categories = res.body
123 expect(Object.keys(categories)).to.have.length.above(10) 104 expect(Object.keys(categories)).to.have.length.above(10)
124 105
125 expect(categories[11]).to.equal('News & Politics') 106 expect(categories[11]).to.equal('News & Politics')
126 }) 107 })
127 108
128 it('Should list video licences', async function () { 109 it('Should list video licences', async function () {
129 const res = await getVideoLicences(server.url) 110 const licences = await server.videosCommand.getLicences()
130
131 const licences = res.body
132 expect(Object.keys(licences)).to.have.length.above(5) 111 expect(Object.keys(licences)).to.have.length.above(5)
133 112
134 expect(licences[3]).to.equal('Attribution - No Derivatives') 113 expect(licences[3]).to.equal('Attribution - No Derivatives')
135 }) 114 })
136 115
137 it('Should list video languages', async function () { 116 it('Should list video languages', async function () {
138 const res = await getVideoLanguages(server.url) 117 const languages = await server.videosCommand.getLanguages()
139
140 const languages = res.body
141 expect(Object.keys(languages)).to.have.length.above(5) 118 expect(Object.keys(languages)).to.have.length.above(5)
142 119
143 expect(languages['ru']).to.equal('Russian') 120 expect(languages['ru']).to.equal('Russian')
144 }) 121 })
145 122
146 it('Should list video privacies', async function () { 123 it('Should list video privacies', async function () {
147 const res = await getVideoPrivacies(server.url) 124 const privacies = await server.videosCommand.getPrivacies()
148
149 const privacies = res.body
150 expect(Object.keys(privacies)).to.have.length.at.least(3) 125 expect(Object.keys(privacies)).to.have.length.at.least(3)
151 126
152 expect(privacies[3]).to.equal('Private') 127 expect(privacies[3]).to.equal('Private')
153 }) 128 })
154 129
155 it('Should not have videos', async function () { 130 it('Should not have videos', async function () {
156 const res = await getVideosList(server.url) 131 const { data, total } = await server.videosCommand.list()
157 132
158 expect(res.body.total).to.equal(0) 133 expect(total).to.equal(0)
159 expect(res.body.data).to.be.an('array') 134 expect(data).to.be.an('array')
160 expect(res.body.data.length).to.equal(0) 135 expect(data.length).to.equal(0)
161 }) 136 })
162 137
163 it('Should upload the video', async function () { 138 it('Should upload the video', async function () {
164 this.timeout(10000) 139 this.timeout(10000)
165 140
166 const videoAttributes = { 141 const attributes = {
167 name: 'my super name', 142 name: 'my super name',
168 category: 2, 143 category: 2,
169 nsfw: true, 144 nsfw: true,
170 licence: 6, 145 licence: 6,
171 tags: [ 'tag1', 'tag2', 'tag3' ] 146 tags: [ 'tag1', 'tag2', 'tag3' ]
172 } 147 }
173 const res = await uploadVideo(server.url, server.accessToken, videoAttributes, HttpStatusCode.OK_200, mode) 148 const video = await server.videosCommand.upload({ attributes, mode })
174 expect(res.body.video).to.not.be.undefined 149 expect(video).to.not.be.undefined
175 expect(res.body.video.id).to.equal(1) 150 expect(video.id).to.equal(1)
176 expect(res.body.video.uuid).to.have.length.above(5) 151 expect(video.uuid).to.have.length.above(5)
177 152
178 videoId = res.body.video.id 153 videoId = video.id
179 videoUUID = res.body.video.uuid 154 videoUUID = video.uuid
180 }) 155 })
181 156
182 it('Should get and seed the uploaded video', async function () { 157 it('Should get and seed the uploaded video', async function () {
183 this.timeout(5000) 158 this.timeout(5000)
184 159
185 const res = await getVideosList(server.url) 160 const { data, total } = await server.videosCommand.list()
186 161
187 expect(res.body.total).to.equal(1) 162 expect(total).to.equal(1)
188 expect(res.body.data).to.be.an('array') 163 expect(data).to.be.an('array')
189 expect(res.body.data.length).to.equal(1) 164 expect(data.length).to.equal(1)
190 165
191 const video = res.body.data[0] 166 const video = data[0]
192 await completeVideoCheck(server.url, video, getCheckAttributes()) 167 await completeVideoCheck(server, video, getCheckAttributes())
193 }) 168 })
194 169
195 it('Should get the video by UUID', async function () { 170 it('Should get the video by UUID', async function () {
196 this.timeout(5000) 171 this.timeout(5000)
197 172
198 const res = await getVideo(server.url, videoUUID) 173 const video = await server.videosCommand.get({ id: videoUUID })
199 174 await completeVideoCheck(server, video, getCheckAttributes())
200 const video = res.body
201 await completeVideoCheck(server.url, video, getCheckAttributes())
202 }) 175 })
203 176
204 it('Should have the views updated', async function () { 177 it('Should have the views updated', async function () {
205 this.timeout(20000) 178 this.timeout(20000)
206 179
207 await viewVideo(server.url, videoId) 180 await server.videosCommand.view({ id: videoId })
208 await viewVideo(server.url, videoId) 181 await server.videosCommand.view({ id: videoId })
209 await viewVideo(server.url, videoId) 182 await server.videosCommand.view({ id: videoId })
210 183
211 await wait(1500) 184 await wait(1500)
212 185
213 await viewVideo(server.url, videoId) 186 await server.videosCommand.view({ id: videoId })
214 await viewVideo(server.url, videoId) 187 await server.videosCommand.view({ id: videoId })
215 188
216 await wait(1500) 189 await wait(1500)
217 190
218 await viewVideo(server.url, videoId) 191 await server.videosCommand.view({ id: videoId })
219 await viewVideo(server.url, videoId) 192 await server.videosCommand.view({ id: videoId })
220 193
221 // Wait the repeatable job 194 // Wait the repeatable job
222 await wait(8000) 195 await wait(8000)
223 196
224 const res = await getVideo(server.url, videoId) 197 const video = await server.videosCommand.get({ id: videoId })
225
226 const video = res.body
227 expect(video.views).to.equal(3) 198 expect(video.views).to.equal(3)
228 }) 199 })
229 200
230 it('Should remove the video', async function () { 201 it('Should remove the video', async function () {
231 await removeVideo(server.url, server.accessToken, videoId) 202 await server.videosCommand.remove({ id: videoId })
232 203
233 await checkVideoFilesWereRemoved(videoUUID, server) 204 await checkVideoFilesWereRemoved(videoUUID, server)
234 }) 205 })
235 206
236 it('Should not have videos', async function () { 207 it('Should not have videos', async function () {
237 const res = await getVideosList(server.url) 208 const { total, data } = await server.videosCommand.list()
238 209
239 expect(res.body.total).to.equal(0) 210 expect(total).to.equal(0)
240 expect(res.body.data).to.be.an('array') 211 expect(data).to.be.an('array')
241 expect(res.body.data).to.have.lengthOf(0) 212 expect(data).to.have.lengthOf(0)
242 }) 213 })
243 214
244 it('Should upload 6 videos', async function () { 215 it('Should upload 6 videos', async function () {
@@ -250,7 +221,7 @@ describe('Test a single server', function () {
250 ]) 221 ])
251 222
252 for (const video of videos) { 223 for (const video of videos) {
253 const videoAttributes = { 224 const attributes = {
254 name: video + ' name', 225 name: video + ' name',
255 description: video + ' description', 226 description: video + ' description',
256 category: 2, 227 category: 2,
@@ -261,19 +232,20 @@ describe('Test a single server', function () {
261 fixture: video 232 fixture: video
262 } 233 }
263 234
264 await uploadVideo(server.url, server.accessToken, videoAttributes, HttpStatusCode.OK_200, mode) 235 await server.videosCommand.upload({ attributes, mode })
265 } 236 }
266 }) 237 })
267 238
268 it('Should have the correct durations', async function () { 239 it('Should have the correct durations', async function () {
269 const res = await getVideosList(server.url) 240 const { total, data } = await server.videosCommand.list()
241
242 expect(total).to.equal(6)
243 expect(data).to.be.an('array')
244 expect(data).to.have.lengthOf(6)
270 245
271 expect(res.body.total).to.equal(6) 246 const videosByName: { [ name: string ]: Video } = {}
272 const videos = res.body.data 247 data.forEach(v => { videosByName[v.name] = v })
273 expect(videos).to.be.an('array')
274 expect(videos).to.have.lengthOf(6)
275 248
276 const videosByName = keyBy<{ duration: number }>(videos, 'name')
277 expect(videosByName['video_short.mp4 name'].duration).to.equal(5) 249 expect(videosByName['video_short.mp4 name'].duration).to.equal(5)
278 expect(videosByName['video_short.ogv name'].duration).to.equal(5) 250 expect(videosByName['video_short.ogv name'].duration).to.equal(5)
279 expect(videosByName['video_short.webm name'].duration).to.equal(5) 251 expect(videosByName['video_short.webm name'].duration).to.equal(5)
@@ -283,96 +255,87 @@ describe('Test a single server', function () {
283 }) 255 })
284 256
285 it('Should have the correct thumbnails', async function () { 257 it('Should have the correct thumbnails', async function () {
286 const res = await getVideosList(server.url) 258 const { data } = await server.videosCommand.list()
287 259
288 const videos = res.body.data
289 // For the next test 260 // For the next test
290 videosListBase = videos 261 videosListBase = data
291 262
292 for (const video of videos) { 263 for (const video of data) {
293 const videoName = video.name.replace(' name', '') 264 const videoName = video.name.replace(' name', '')
294 await testImage(server.url, videoName, video.thumbnailPath) 265 await testImage(server.url, videoName, video.thumbnailPath)
295 } 266 }
296 }) 267 })
297 268
298 it('Should list only the two first videos', async function () { 269 it('Should list only the two first videos', async function () {
299 const res = await getVideosListPagination(server.url, 0, 2, 'name') 270 const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: 'name' })
300 271
301 const videos = res.body.data 272 expect(total).to.equal(6)
302 expect(res.body.total).to.equal(6) 273 expect(data.length).to.equal(2)
303 expect(videos.length).to.equal(2) 274 expect(data[0].name).to.equal(videosListBase[0].name)
304 expect(videos[0].name).to.equal(videosListBase[0].name) 275 expect(data[1].name).to.equal(videosListBase[1].name)
305 expect(videos[1].name).to.equal(videosListBase[1].name)
306 }) 276 })
307 277
308 it('Should list only the next three videos', async function () { 278 it('Should list only the next three videos', async function () {
309 const res = await getVideosListPagination(server.url, 2, 3, 'name') 279 const { total, data } = await server.videosCommand.list({ start: 2, count: 3, sort: 'name' })
310 280
311 const videos = res.body.data 281 expect(total).to.equal(6)
312 expect(res.body.total).to.equal(6) 282 expect(data.length).to.equal(3)
313 expect(videos.length).to.equal(3) 283 expect(data[0].name).to.equal(videosListBase[2].name)
314 expect(videos[0].name).to.equal(videosListBase[2].name) 284 expect(data[1].name).to.equal(videosListBase[3].name)
315 expect(videos[1].name).to.equal(videosListBase[3].name) 285 expect(data[2].name).to.equal(videosListBase[4].name)
316 expect(videos[2].name).to.equal(videosListBase[4].name)
317 }) 286 })
318 287
319 it('Should list the last video', async function () { 288 it('Should list the last video', async function () {
320 const res = await getVideosListPagination(server.url, 5, 6, 'name') 289 const { total, data } = await server.videosCommand.list({ start: 5, count: 6, sort: 'name' })
321 290
322 const videos = res.body.data 291 expect(total).to.equal(6)
323 expect(res.body.total).to.equal(6) 292 expect(data.length).to.equal(1)
324 expect(videos.length).to.equal(1) 293 expect(data[0].name).to.equal(videosListBase[5].name)
325 expect(videos[0].name).to.equal(videosListBase[5].name)
326 }) 294 })
327 295
328 it('Should not have the total field', async function () { 296 it('Should not have the total field', async function () {
329 const res = await getVideosListPagination(server.url, 5, 6, 'name', true) 297 const { total, data } = await server.videosCommand.list({ start: 5, count: 6, sort: 'name', skipCount: true })
330 298
331 const videos = res.body.data 299 expect(total).to.not.exist
332 expect(res.body.total).to.not.exist 300 expect(data.length).to.equal(1)
333 expect(videos.length).to.equal(1) 301 expect(data[0].name).to.equal(videosListBase[5].name)
334 expect(videos[0].name).to.equal(videosListBase[5].name)
335 }) 302 })
336 303
337 it('Should list and sort by name in descending order', async function () { 304 it('Should list and sort by name in descending order', async function () {
338 const res = await getVideosListSort(server.url, '-name') 305 const { total, data } = await server.videosCommand.list({ sort: '-name' })
339 306
340 const videos = res.body.data 307 expect(total).to.equal(6)
341 expect(res.body.total).to.equal(6) 308 expect(data.length).to.equal(6)
342 expect(videos.length).to.equal(6) 309 expect(data[0].name).to.equal('video_short.webm name')
343 expect(videos[0].name).to.equal('video_short.webm name') 310 expect(data[1].name).to.equal('video_short.ogv name')
344 expect(videos[1].name).to.equal('video_short.ogv name') 311 expect(data[2].name).to.equal('video_short.mp4 name')
345 expect(videos[2].name).to.equal('video_short.mp4 name') 312 expect(data[3].name).to.equal('video_short3.webm name')
346 expect(videos[3].name).to.equal('video_short3.webm name') 313 expect(data[4].name).to.equal('video_short2.webm name')
347 expect(videos[4].name).to.equal('video_short2.webm name') 314 expect(data[5].name).to.equal('video_short1.webm name')
348 expect(videos[5].name).to.equal('video_short1.webm name')
349 315
350 videoId = videos[3].uuid 316 videoId = data[3].uuid
351 videoId2 = videos[5].uuid 317 videoId2 = data[5].uuid
352 }) 318 })
353 319
354 it('Should list and sort by trending in descending order', async function () { 320 it('Should list and sort by trending in descending order', async function () {
355 const res = await getVideosListPagination(server.url, 0, 2, '-trending') 321 const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-trending' })
356 322
357 const videos = res.body.data 323 expect(total).to.equal(6)
358 expect(res.body.total).to.equal(6) 324 expect(data.length).to.equal(2)
359 expect(videos.length).to.equal(2)
360 }) 325 })
361 326
362 it('Should list and sort by hotness in descending order', async function () { 327 it('Should list and sort by hotness in descending order', async function () {
363 const res = await getVideosListPagination(server.url, 0, 2, '-hot') 328 const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-hot' })
364 329
365 const videos = res.body.data 330 expect(total).to.equal(6)
366 expect(res.body.total).to.equal(6) 331 expect(data.length).to.equal(2)
367 expect(videos.length).to.equal(2)
368 }) 332 })
369 333
370 it('Should list and sort by best in descending order', async function () { 334 it('Should list and sort by best in descending order', async function () {
371 const res = await getVideosListPagination(server.url, 0, 2, '-best') 335 const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-best' })
372 336
373 const videos = res.body.data 337 expect(total).to.equal(6)
374 expect(res.body.total).to.equal(6) 338 expect(data.length).to.equal(2)
375 expect(videos.length).to.equal(2)
376 }) 339 })
377 340
378 it('Should update a video', async function () { 341 it('Should update a video', async function () {
@@ -387,67 +350,66 @@ describe('Test a single server', function () {
387 downloadEnabled: false, 350 downloadEnabled: false,
388 tags: [ 'tagup1', 'tagup2' ] 351 tags: [ 'tagup1', 'tagup2' ]
389 } 352 }
390 await updateVideo(server.url, server.accessToken, videoId, attributes) 353 await server.videosCommand.update({ id: videoId, attributes })
391 }) 354 })
392 355
393 it('Should filter by tags and category', async function () { 356 it('Should filter by tags and category', async function () {
394 const res1 = await getVideosWithFilters(server.url, { tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 4 ] }) 357 {
395 expect(res1.body.total).to.equal(1) 358 const { data, total } = await server.videosCommand.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 4 ] })
396 expect(res1.body.data[0].name).to.equal('my super video updated') 359 expect(total).to.equal(1)
360 expect(data[0].name).to.equal('my super video updated')
361 }
397 362
398 const res2 = await getVideosWithFilters(server.url, { tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 3 ] }) 363 {
399 expect(res2.body.total).to.equal(0) 364 const { total } = await server.videosCommand.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 3 ] })
365 expect(total).to.equal(0)
366 }
400 }) 367 })
401 368
402 it('Should have the video updated', async function () { 369 it('Should have the video updated', async function () {
403 this.timeout(60000) 370 this.timeout(60000)
404 371
405 const res = await getVideo(server.url, videoId) 372 const video = await server.videosCommand.get({ id: videoId })
406 const video = res.body
407 373
408 await completeVideoCheck(server.url, video, updateCheckAttributes()) 374 await completeVideoCheck(server, video, updateCheckAttributes())
409 }) 375 })
410 376
411 it('Should update only the tags of a video', async function () { 377 it('Should update only the tags of a video', async function () {
412 const attributes = { 378 const attributes = {
413 tags: [ 'supertag', 'tag1', 'tag2' ] 379 tags: [ 'supertag', 'tag1', 'tag2' ]
414 } 380 }
415 await updateVideo(server.url, server.accessToken, videoId, attributes) 381 await server.videosCommand.update({ id: videoId, attributes })
416 382
417 const res = await getVideo(server.url, videoId) 383 const video = await server.videosCommand.get({ id: videoId })
418 const video = res.body
419 384
420 await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes(), attributes)) 385 await completeVideoCheck(server, video, Object.assign(updateCheckAttributes(), attributes))
421 }) 386 })
422 387
423 it('Should update only the description of a video', async function () { 388 it('Should update only the description of a video', async function () {
424 const attributes = { 389 const attributes = {
425 description: 'hello everybody' 390 description: 'hello everybody'
426 } 391 }
427 await updateVideo(server.url, server.accessToken, videoId, attributes) 392 await server.videosCommand.update({ id: videoId, attributes })
428 393
429 const res = await getVideo(server.url, videoId) 394 const video = await server.videosCommand.get({ id: videoId })
430 const video = res.body
431 395
432 const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: [ 'supertag', 'tag1', 'tag2' ] }, attributes) 396 const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: [ 'supertag', 'tag1', 'tag2' ] }, attributes)
433 await completeVideoCheck(server.url, video, expectedAttributes) 397 await completeVideoCheck(server, video, expectedAttributes)
434 }) 398 })
435 399
436 it('Should like a video', async function () { 400 it('Should like a video', async function () {
437 await rateVideo(server.url, server.accessToken, videoId, 'like') 401 await server.videosCommand.rate({ id: videoId, rating: 'like' })
438 402
439 const res = await getVideo(server.url, videoId) 403 const video = await server.videosCommand.get({ id: videoId })
440 const video = res.body
441 404
442 expect(video.likes).to.equal(1) 405 expect(video.likes).to.equal(1)
443 expect(video.dislikes).to.equal(0) 406 expect(video.dislikes).to.equal(0)
444 }) 407 })
445 408
446 it('Should dislike the same video', async function () { 409 it('Should dislike the same video', async function () {
447 await rateVideo(server.url, server.accessToken, videoId, 'dislike') 410 await server.videosCommand.rate({ id: videoId, rating: 'dislike' })
448 411
449 const res = await getVideo(server.url, videoId) 412 const video = await server.videosCommand.get({ id: videoId })
450 const video = res.body
451 413
452 expect(video.likes).to.equal(0) 414 expect(video.likes).to.equal(0)
453 expect(video.dislikes).to.equal(1) 415 expect(video.dislikes).to.equal(1)
@@ -457,10 +419,10 @@ describe('Test a single server', function () {
457 { 419 {
458 const now = new Date() 420 const now = new Date()
459 const attributes = { originallyPublishedAt: now.toISOString() } 421 const attributes = { originallyPublishedAt: now.toISOString() }
460 await updateVideo(server.url, server.accessToken, videoId, attributes) 422 await server.videosCommand.update({ id: videoId, attributes })
461 423
462 const res = await getVideosListSort(server.url, '-originallyPublishedAt') 424 const { data } = await server.videosCommand.list({ sort: '-originallyPublishedAt' })
463 const names = res.body.data.map(v => v.name) 425 const names = data.map(v => v.name)
464 426
465 expect(names[0]).to.equal('my super video updated') 427 expect(names[0]).to.equal('my super video updated')
466 expect(names[1]).to.equal('video_short2.webm name') 428 expect(names[1]).to.equal('video_short2.webm name')
@@ -473,10 +435,10 @@ describe('Test a single server', function () {
473 { 435 {
474 const now = new Date() 436 const now = new Date()
475 const attributes = { originallyPublishedAt: now.toISOString() } 437 const attributes = { originallyPublishedAt: now.toISOString() }
476 await updateVideo(server.url, server.accessToken, videoId2, attributes) 438 await server.videosCommand.update({ id: videoId2, attributes })
477 439
478 const res = await getVideosListSort(server.url, '-originallyPublishedAt') 440 const { data } = await server.videosCommand.list({ sort: '-originallyPublishedAt' })
479 const names = res.body.data.map(v => v.name) 441 const names = data.map(v => v.name)
480 442
481 expect(names[0]).to.equal('video_short1.webm name') 443 expect(names[0]).to.equal('video_short1.webm name')
482 expect(names[1]).to.equal('my super video updated') 444 expect(names[1]).to.equal('my super video updated')
diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts
index d4a5385ab..4c67e96f7 100644
--- a/server/tests/api/videos/video-captions.ts
+++ b/server/tests/api/videos/video-captions.ts
@@ -7,11 +7,9 @@ import {
7 cleanupTests, 7 cleanupTests,
8 doubleFollow, 8 doubleFollow,
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 removeVideo,
11 ServerInfo, 10 ServerInfo,
12 setAccessTokensToServers, 11 setAccessTokensToServers,
13 testCaptionFile, 12 testCaptionFile,
14 uploadVideo,
15 wait, 13 wait,
16 waitJobs 14 waitJobs
17} from '@shared/extra-utils' 15} from '@shared/extra-utils'
@@ -34,8 +32,8 @@ describe('Test video captions', function () {
34 32
35 await waitJobs(servers) 33 await waitJobs(servers)
36 34
37 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'my video name' }) 35 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'my video name' } })
38 videoUUID = res.body.video.uuid 36 videoUUID = uuid
39 37
40 await waitJobs(servers) 38 await waitJobs(servers)
41 }) 39 })
@@ -180,7 +178,7 @@ describe('Test video captions', function () {
180 }) 178 })
181 179
182 it('Should remove the video, and thus all video captions', async function () { 180 it('Should remove the video, and thus all video captions', async function () {
183 await removeVideo(servers[0].url, servers[0].accessToken, videoUUID) 181 await servers[0].videosCommand.remove({ id: videoUUID })
184 182
185 await checkVideoFilesWereRemoved(videoUUID, servers[0]) 183 await checkVideoFilesWereRemoved(videoUUID, servers[0])
186 }) 184 })
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts
index b0bbd5a0d..b85edd920 100644
--- a/server/tests/api/videos/video-change-ownership.ts
+++ b/server/tests/api/videos/video-change-ownership.ts
@@ -2,22 +2,19 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 ChangeOwnershipCommand, 7 ChangeOwnershipCommand,
8 cleanupTests, 8 cleanupTests,
9 doubleFollow, 9 doubleFollow,
10 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
11 flushAndRunServer, 11 flushAndRunServer,
12 getVideo,
13 getVideosList,
14 ServerInfo, 12 ServerInfo,
15 setAccessTokensToServers, 13 setAccessTokensToServers,
16 setDefaultVideoChannel, 14 setDefaultVideoChannel,
17 uploadVideo 15 waitJobs
18} from '../../../../shared/extra-utils' 16} from '@shared/extra-utils'
19import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 17import { VideoPrivacy } from '@shared/models'
20import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos'
21 18
22const expect = chai.expect 19const expect = chai.expect
23 20
@@ -71,14 +68,13 @@ describe('Test video change ownership - nominal', function () {
71 } 68 }
72 69
73 { 70 {
74 const videoAttributes = { 71 const attributes = {
75 name: 'my super name', 72 name: 'my super name',
76 description: 'my super description' 73 description: 'my super description'
77 } 74 }
78 const res = await uploadVideo(servers[0].url, firstUserToken, videoAttributes) 75 const { id } = await servers[0].videosCommand.upload({ token: firstUserToken, attributes })
79 76
80 const resVideo = await getVideo(servers[0].url, res.body.video.id) 77 servers[0].video = await servers[0].videosCommand.get({ id })
81 servers[0].video = resVideo.body
82 } 78 }
83 79
84 { 80 {
@@ -212,9 +208,7 @@ describe('Test video change ownership - nominal', function () {
212 208
213 it('Should have the channel of the video updated', async function () { 209 it('Should have the channel of the video updated', async function () {
214 for (const server of servers) { 210 for (const server of servers) {
215 const res = await getVideo(server.url, servers[0].video.uuid) 211 const video = await server.videosCommand.get({ id: servers[0].video.uuid })
216
217 const video: VideoDetails = res.body
218 212
219 expect(video.name).to.equal('my super name') 213 expect(video.name).to.equal('my super name')
220 expect(video.channel.displayName).to.equal('Main second channel') 214 expect(video.channel.displayName).to.equal('Main second channel')
@@ -243,9 +237,7 @@ describe('Test video change ownership - nominal', function () {
243 await waitJobs(servers) 237 await waitJobs(servers)
244 238
245 for (const server of servers) { 239 for (const server of servers) {
246 const res = await getVideo(server.url, servers[0].video.uuid) 240 const video = await server.videosCommand.get({ id: servers[0].video.uuid })
247
248 const video: VideoDetails = res.body
249 241
250 expect(video.name).to.equal('my super name') 242 expect(video.name).to.equal('my super name')
251 expect(video.channel.displayName).to.equal('Main second channel') 243 expect(video.channel.displayName).to.equal('Main second channel')
@@ -280,20 +272,18 @@ describe('Test video change ownership - quota too small', function () {
280 secondUserToken = await server.loginCommand.getAccessToken(secondUser) 272 secondUserToken = await server.loginCommand.getAccessToken(secondUser)
281 273
282 // Upload some videos on the server 274 // Upload some videos on the server
283 const video1Attributes = { 275 const attributes = {
284 name: 'my super name', 276 name: 'my super name',
285 description: 'my super description' 277 description: 'my super description'
286 } 278 }
287 await uploadVideo(server.url, firstUserToken, video1Attributes) 279 await server.videosCommand.upload({ token: firstUserToken, attributes })
288 280
289 await waitJobs(server) 281 await waitJobs(server)
290 282
291 const res = await getVideosList(server.url) 283 const { data } = await server.videosCommand.list()
292 const videos = res.body.data 284 expect(data.length).to.equal(1)
293
294 expect(videos.length).to.equal(1)
295 285
296 server.video = videos.find(video => video.name === 'my super name') 286 server.video = data.find(video => video.name === 'my super name')
297 }) 287 })
298 288
299 it('Should send a request to change ownership of a video', async function () { 289 it('Should send a request to change ownership of a video', async function () {
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 2e57cbbff..170cc942e 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -8,20 +8,15 @@ import {
8 cleanupTests, 8 cleanupTests,
9 doubleFollow, 9 doubleFollow,
10 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
11 getVideo,
12 getVideoChannelVideos,
13 ServerInfo, 11 ServerInfo,
14 setAccessTokensToServers, 12 setAccessTokensToServers,
15 setDefaultVideoChannel, 13 setDefaultVideoChannel,
16 testFileExistsOrNot, 14 testFileExistsOrNot,
17 testImage, 15 testImage,
18 updateVideo,
19 uploadVideo,
20 viewVideo,
21 wait, 16 wait,
22 waitJobs 17 waitJobs
23} from '@shared/extra-utils' 18} from '@shared/extra-utils'
24import { User, Video, VideoChannel, VideoDetails } from '@shared/models' 19import { User, VideoChannel } from '@shared/models'
25 20
26const expect = chai.expect 21const expect = chai.expect
27 22
@@ -77,9 +72,9 @@ describe('Test video channels', function () {
77 72
78 // The channel is 1 is propagated to servers 2 73 // The channel is 1 is propagated to servers 2
79 { 74 {
80 const videoAttributesArg = { name: 'my video name', channelId: secondVideoChannelId, support: 'video support field' } 75 const attributes = { name: 'my video name', channelId: secondVideoChannelId, support: 'video support field' }
81 const res = await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributesArg) 76 const { uuid } = await servers[0].videosCommand.upload({ attributes })
82 videoUUID = res.body.video.uuid 77 videoUUID = uuid
83 } 78 }
84 79
85 await waitJobs(servers) 80 await waitJobs(servers)
@@ -219,9 +214,7 @@ describe('Test video channels', function () {
219 214
220 it('Should not have updated the video support field', async function () { 215 it('Should not have updated the video support field', async function () {
221 for (const server of servers) { 216 for (const server of servers) {
222 const res = await getVideo(server.url, videoUUID) 217 const video = await server.videosCommand.get({ id: videoUUID })
223 const video: VideoDetails = res.body
224
225 expect(video.support).to.equal('video support field') 218 expect(video.support).to.equal('video support field')
226 } 219 }
227 }) 220 })
@@ -239,9 +232,7 @@ describe('Test video channels', function () {
239 await waitJobs(servers) 232 await waitJobs(servers)
240 233
241 for (const server of servers) { 234 for (const server of servers) {
242 const res = await getVideo(server.url, videoUUID) 235 const video = await server.videosCommand.get({ id: videoUUID })
243 const video: VideoDetails = res.body
244
245 expect(video.support).to.equal(videoChannelAttributes.support) 236 expect(video.support).to.equal(videoChannelAttributes.support)
246 } 237 }
247 }) 238 })
@@ -333,18 +324,19 @@ describe('Test video channels', function () {
333 324
334 for (const server of servers) { 325 for (const server of servers) {
335 const channelURI = 'second_video_channel@localhost:' + servers[0].port 326 const channelURI = 'second_video_channel@localhost:' + servers[0].port
336 const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) 327 const { total, data } = await server.videosCommand.listByChannel({ videoChannelName: channelURI })
337 expect(res1.body.total).to.equal(1) 328
338 expect(res1.body.data).to.be.an('array') 329 expect(total).to.equal(1)
339 expect(res1.body.data).to.have.lengthOf(1) 330 expect(data).to.be.an('array')
340 expect(res1.body.data[0].name).to.equal('my video name') 331 expect(data).to.have.lengthOf(1)
332 expect(data[0].name).to.equal('my video name')
341 } 333 }
342 }) 334 })
343 335
344 it('Should change the video channel of a video', async function () { 336 it('Should change the video channel of a video', async function () {
345 this.timeout(10000) 337 this.timeout(10000)
346 338
347 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { channelId: servers[0].videoChannel.id }) 339 await servers[0].videosCommand.update({ id: videoUUID, attributes: { channelId: servers[0].videoChannel.id } })
348 340
349 await waitJobs(servers) 341 await waitJobs(servers)
350 }) 342 })
@@ -353,18 +345,21 @@ describe('Test video channels', function () {
353 this.timeout(10000) 345 this.timeout(10000)
354 346
355 for (const server of servers) { 347 for (const server of servers) {
356 const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port 348 {
357 const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5) 349 const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port
358 expect(res1.body.total).to.equal(0) 350 const { total } = await server.videosCommand.listByChannel({ videoChannelName: secondChannelURI })
359 351 expect(total).to.equal(0)
360 const channelURI = 'root_channel@localhost:' + servers[0].port 352 }
361 const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) 353
362 expect(res2.body.total).to.equal(1) 354 {
363 355 const channelURI = 'root_channel@localhost:' + servers[0].port
364 const videos: Video[] = res2.body.data 356 const { total, data } = await server.videosCommand.listByChannel({ videoChannelName: channelURI })
365 expect(videos).to.be.an('array') 357 expect(total).to.equal(1)
366 expect(videos).to.have.lengthOf(1) 358
367 expect(videos[0].name).to.equal('my video name') 359 expect(data).to.be.an('array')
360 expect(data).to.have.lengthOf(1)
361 expect(data[0].name).to.equal('my video name')
362 }
368 } 363 }
369 }) 364 })
370 365
@@ -417,8 +412,8 @@ describe('Test video channels', function () {
417 412
418 { 413 {
419 // video has been posted on channel servers[0].videoChannel.id since last update 414 // video has been posted on channel servers[0].videoChannel.id since last update
420 await viewVideo(servers[0].url, videoUUID, 204, '0.0.0.1,127.0.0.1') 415 await servers[0].videosCommand.view({ id: videoUUID, xForwardedFor: '0.0.0.1,127.0.0.1' })
421 await viewVideo(servers[0].url, videoUUID, 204, '0.0.0.2,127.0.0.1') 416 await servers[0].videosCommand.view({ id: videoUUID, xForwardedFor: '0.0.0.2,127.0.0.1' })
422 417
423 // Wait the repeatable job 418 // Wait the repeatable job
424 await wait(8000) 419 await wait(8000)
@@ -460,7 +455,7 @@ describe('Test video channels', function () {
460 it('Should list channels by updatedAt desc if a video has been uploaded', async function () { 455 it('Should list channels by updatedAt desc if a video has been uploaded', async function () {
461 this.timeout(30000) 456 this.timeout(30000)
462 457
463 await uploadVideo(servers[0].url, servers[0].accessToken, { channelId: totoChannel }) 458 await servers[0].videosCommand.upload({ attributes: { channelId: totoChannel } })
464 await waitJobs(servers) 459 await waitJobs(servers)
465 460
466 for (const server of servers) { 461 for (const server of servers) {
@@ -470,7 +465,7 @@ describe('Test video channels', function () {
470 expect(data[1].name).to.equal('root_channel') 465 expect(data[1].name).to.equal('root_channel')
471 } 466 }
472 467
473 await uploadVideo(servers[0].url, servers[0].accessToken, { channelId: servers[0].videoChannel.id }) 468 await servers[0].videosCommand.upload({ attributes: { channelId: servers[0].videoChannel.id } })
474 await waitJobs(servers) 469 await waitJobs(servers)
475 470
476 for (const server of servers) { 471 for (const server of servers) {
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts
index 266824d58..41be54c81 100644
--- a/server/tests/api/videos/video-comments.ts
+++ b/server/tests/api/videos/video-comments.ts
@@ -9,8 +9,7 @@ import {
9 flushAndRunServer, 9 flushAndRunServer,
10 ServerInfo, 10 ServerInfo,
11 setAccessTokensToServers, 11 setAccessTokensToServers,
12 testImage, 12 testImage
13 uploadVideo
14} from '@shared/extra-utils' 13} from '@shared/extra-utils'
15 14
16const expect = chai.expect 15const expect = chai.expect
@@ -33,9 +32,9 @@ describe('Test video comments', function () {
33 32
34 await setAccessTokensToServers([ server ]) 33 await setAccessTokensToServers([ server ])
35 34
36 const res = await uploadVideo(server.url, server.accessToken, {}) 35 const { id, uuid } = await server.videosCommand.upload()
37 videoUUID = res.body.video.uuid 36 videoUUID = uuid
38 videoId = res.body.video.id 37 videoId = id
39 38
40 await server.usersCommand.updateMyAvatar({ fixture: 'avatar.png' }) 39 await server.usersCommand.updateMyAvatar({ fixture: 'avatar.png' })
41 40
diff --git a/server/tests/api/videos/video-description.ts b/server/tests/api/videos/video-description.ts
index e1c9afe79..6ac9206f5 100644
--- a/server/tests/api/videos/video-description.ts
+++ b/server/tests/api/videos/video-description.ts
@@ -2,19 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { 5import { cleanupTests, doubleFollow, flushAndRunMultipleServers, ServerInfo, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
6 cleanupTests,
7 flushAndRunMultipleServers,
8 getVideo,
9 getVideoDescription,
10 getVideosList,
11 ServerInfo,
12 setAccessTokensToServers,
13 updateVideo,
14 uploadVideo
15} from '../../../../shared/extra-utils/index'
16import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
17import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
18 6
19const expect = chai.expect 7const expect = chai.expect
20 8
@@ -43,20 +31,19 @@ describe('Test video description', function () {
43 const attributes = { 31 const attributes = {
44 description: longDescription 32 description: longDescription
45 } 33 }
46 await uploadVideo(servers[0].url, servers[0].accessToken, attributes) 34 await servers[0].videosCommand.upload({ attributes })
47 35
48 await waitJobs(servers) 36 await waitJobs(servers)
49 37
50 const res = await getVideosList(servers[0].url) 38 const { data } = await servers[0].videosCommand.list()
51 39
52 videoId = res.body.data[0].id 40 videoId = data[0].id
53 videoUUID = res.body.data[0].uuid 41 videoUUID = data[0].uuid
54 }) 42 })
55 43
56 it('Should have a truncated description on each server', async function () { 44 it('Should have a truncated description on each server', async function () {
57 for (const server of servers) { 45 for (const server of servers) {
58 const res = await getVideo(server.url, videoUUID) 46 const video = await server.videosCommand.get({ id: videoUUID })
59 const video = res.body
60 47
61 // 30 characters * 6 -> 240 characters 48 // 30 characters * 6 -> 240 characters
62 const truncatedDescription = 'my super description for server 1'.repeat(7) + 49 const truncatedDescription = 'my super description for server 1'.repeat(7) +
@@ -68,11 +55,10 @@ describe('Test video description', function () {
68 55
69 it('Should fetch long description on each server', async function () { 56 it('Should fetch long description on each server', async function () {
70 for (const server of servers) { 57 for (const server of servers) {
71 const res = await getVideo(server.url, videoUUID) 58 const video = await server.videosCommand.get({ id: videoUUID })
72 const video = res.body
73 59
74 const res2 = await getVideoDescription(server.url, video.descriptionPath) 60 const { description } = await server.videosCommand.getDescription({ descriptionPath: video.descriptionPath })
75 expect(res2.body.description).to.equal(longDescription) 61 expect(description).to.equal(longDescription)
76 } 62 }
77 }) 63 })
78 64
@@ -82,20 +68,19 @@ describe('Test video description', function () {
82 const attributes = { 68 const attributes = {
83 description: 'short description' 69 description: 'short description'
84 } 70 }
85 await updateVideo(servers[0].url, servers[0].accessToken, videoId, attributes) 71 await servers[0].videosCommand.update({ id: videoId, attributes })
86 72
87 await waitJobs(servers) 73 await waitJobs(servers)
88 }) 74 })
89 75
90 it('Should have a small description on each server', async function () { 76 it('Should have a small description on each server', async function () {
91 for (const server of servers) { 77 for (const server of servers) {
92 const res = await getVideo(server.url, videoUUID) 78 const video = await server.videosCommand.get({ id: videoUUID })
93 const video = res.body
94 79
95 expect(video.description).to.equal('short description') 80 expect(video.description).to.equal('short description')
96 81
97 const res2 = await getVideoDescription(server.url, video.descriptionPath) 82 const { description } = await server.videosCommand.getDescription({ descriptionPath: video.descriptionPath })
98 expect(res2.body.description).to.equal('short description') 83 expect(description).to.equal('short description')
99 } 84 }
100 }) 85 })
101 86
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts
index 428e1316d..d63b81694 100644
--- a/server/tests/api/videos/video-hls.ts
+++ b/server/tests/api/videos/video-hls.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { join } from 'path' 5import { join } from 'path'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '@shared/core-utils'
7import { 7import {
8 checkDirectoryIsEmpty, 8 checkDirectoryIsEmpty,
9 checkResolutionsInMasterPlaylist, 9 checkResolutionsInMasterPlaylist,
@@ -12,26 +12,20 @@ import {
12 cleanupTests, 12 cleanupTests,
13 doubleFollow, 13 doubleFollow,
14 flushAndRunMultipleServers, 14 flushAndRunMultipleServers,
15 getVideo,
16 makeRawRequest, 15 makeRawRequest,
17 removeVideo,
18 ServerInfo, 16 ServerInfo,
19 setAccessTokensToServers, 17 setAccessTokensToServers,
20 updateVideo,
21 uploadVideo,
22 waitJobs, 18 waitJobs,
23 webtorrentAdd 19 webtorrentAdd
24} from '../../../../shared/extra-utils' 20} from '@shared/extra-utils'
25import { VideoDetails } from '../../../../shared/models/videos' 21import { VideoStreamingPlaylistType } from '@shared/models'
26import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type'
27import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' 22import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants'
28 23
29const expect = chai.expect 24const expect = chai.expect
30 25
31async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOnly: boolean, resolutions = [ 240, 360, 480, 720 ]) { 26async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOnly: boolean, resolutions = [ 240, 360, 480, 720 ]) {
32 for (const server of servers) { 27 for (const server of servers) {
33 const resVideoDetails = await getVideo(server.url, videoUUID) 28 const videoDetails = await server.videosCommand.get({ id: videoUUID })
34 const videoDetails: VideoDetails = resVideoDetails.body
35 const baseUrl = `http://${videoDetails.account.host}` 29 const baseUrl = `http://${videoDetails.account.host}`
36 30
37 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) 31 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
@@ -113,8 +107,8 @@ describe('Test HLS videos', function () {
113 it('Should upload a video and transcode it to HLS', async function () { 107 it('Should upload a video and transcode it to HLS', async function () {
114 this.timeout(120000) 108 this.timeout(120000)
115 109
116 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video 1', fixture: 'video_short.webm' }) 110 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 1', fixture: 'video_short.webm' } })
117 videoUUID = res.body.video.uuid 111 videoUUID = uuid
118 112
119 await waitJobs(servers) 113 await waitJobs(servers)
120 114
@@ -124,8 +118,8 @@ describe('Test HLS videos', function () {
124 it('Should upload an audio file and transcode it to HLS', async function () { 118 it('Should upload an audio file and transcode it to HLS', async function () {
125 this.timeout(120000) 119 this.timeout(120000)
126 120
127 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video audio', fixture: 'sample.ogg' }) 121 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video audio', fixture: 'sample.ogg' } })
128 videoAudioUUID = res.body.video.uuid 122 videoAudioUUID = uuid
129 123
130 await waitJobs(servers) 124 await waitJobs(servers)
131 125
@@ -135,7 +129,7 @@ describe('Test HLS videos', function () {
135 it('Should update the video', async function () { 129 it('Should update the video', async function () {
136 this.timeout(10000) 130 this.timeout(10000)
137 131
138 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { name: 'video 1 updated' }) 132 await servers[0].videosCommand.update({ id: videoUUID, attributes: { name: 'video 1 updated' } })
139 133
140 await waitJobs(servers) 134 await waitJobs(servers)
141 135
@@ -145,14 +139,14 @@ describe('Test HLS videos', function () {
145 it('Should delete videos', async function () { 139 it('Should delete videos', async function () {
146 this.timeout(10000) 140 this.timeout(10000)
147 141
148 await removeVideo(servers[0].url, servers[0].accessToken, videoUUID) 142 await servers[0].videosCommand.remove({ id: videoUUID })
149 await removeVideo(servers[0].url, servers[0].accessToken, videoAudioUUID) 143 await servers[0].videosCommand.remove({ id: videoAudioUUID })
150 144
151 await waitJobs(servers) 145 await waitJobs(servers)
152 146
153 for (const server of servers) { 147 for (const server of servers) {
154 await getVideo(server.url, videoUUID, HttpStatusCode.NOT_FOUND_404) 148 await server.videosCommand.get({ id: videoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
155 await getVideo(server.url, videoAudioUUID, HttpStatusCode.NOT_FOUND_404) 149 await server.videosCommand.get({ id: videoAudioUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
156 } 150 }
157 }) 151 })
158 152
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts
index 052c052b4..31fdfe12e 100644
--- a/server/tests/api/videos/video-imports.ts
+++ b/server/tests/api/videos/video-imports.ts
@@ -7,9 +7,6 @@ import {
7 cleanupTests, 7 cleanupTests,
8 doubleFollow, 8 doubleFollow,
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 getMyVideos,
11 getVideo,
12 getVideosList,
13 ImportsCommand, 10 ImportsCommand,
14 ServerInfo, 11 ServerInfo,
15 setAccessTokensToServers, 12 setAccessTokensToServers,
@@ -17,7 +14,7 @@ import {
17 testImage, 14 testImage,
18 waitJobs 15 waitJobs
19} from '@shared/extra-utils' 16} from '@shared/extra-utils'
20import { VideoDetails, VideoPrivacy, VideoResolution } from '@shared/models' 17import { VideoPrivacy, VideoResolution } from '@shared/models'
21 18
22const expect = chai.expect 19const expect = chai.expect
23 20
@@ -29,8 +26,7 @@ describe('Test video imports', function () {
29 if (areHttpImportTestsDisabled()) return 26 if (areHttpImportTestsDisabled()) return
30 27
31 async function checkVideosServer1 (server: ServerInfo, idHttp: string, idMagnet: string, idTorrent: string) { 28 async function checkVideosServer1 (server: ServerInfo, idHttp: string, idMagnet: string, idTorrent: string) {
32 const resHttp = await getVideo(server.url, idHttp) 29 const videoHttp = await server.videosCommand.get({ id: idHttp })
33 const videoHttp: VideoDetails = resHttp.body
34 30
35 expect(videoHttp.name).to.equal('small video - youtube') 31 expect(videoHttp.name).to.equal('small video - youtube')
36 // FIXME: youtube-dl seems broken 32 // FIXME: youtube-dl seems broken
@@ -47,10 +43,8 @@ describe('Test video imports', function () {
47 expect(originallyPublishedAt.getMonth()).to.equal(0) 43 expect(originallyPublishedAt.getMonth()).to.equal(0)
48 expect(originallyPublishedAt.getFullYear()).to.equal(2019) 44 expect(originallyPublishedAt.getFullYear()).to.equal(2019)
49 45
50 const resMagnet = await getVideo(server.url, idMagnet) 46 const videoMagnet = await server.videosCommand.get({ id: idMagnet })
51 const videoMagnet: VideoDetails = resMagnet.body 47 const videoTorrent = await server.videosCommand.get({ id: idTorrent })
52 const resTorrent = await getVideo(server.url, idTorrent)
53 const videoTorrent: VideoDetails = resTorrent.body
54 48
55 for (const video of [ videoMagnet, videoTorrent ]) { 49 for (const video of [ videoMagnet, videoTorrent ]) {
56 expect(video.category.label).to.equal('Misc') 50 expect(video.category.label).to.equal('Misc')
@@ -70,8 +64,7 @@ describe('Test video imports', function () {
70 } 64 }
71 65
72 async function checkVideoServer2 (server: ServerInfo, id: number | string) { 66 async function checkVideoServer2 (server: ServerInfo, id: number | string) {
73 const res = await getVideo(server.url, id) 67 const video = await server.videosCommand.get({ id })
74 const video: VideoDetails = res.body
75 68
76 expect(video.name).to.equal('my super name') 69 expect(video.name).to.equal('my super name')
77 expect(video.category.label).to.equal('Entertainment') 70 expect(video.category.label).to.equal('Entertainment')
@@ -190,15 +183,14 @@ Ajouter un sous-titre est vraiment facile`)
190 }) 183 })
191 184
192 it('Should list the videos to import in my videos on server 1', async function () { 185 it('Should list the videos to import in my videos on server 1', async function () {
193 const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5, 'createdAt') 186 const { total, data } = await servers[0].videosCommand.listMyVideos({ sort: 'createdAt' })
194 187
195 expect(res.body.total).to.equal(3) 188 expect(total).to.equal(3)
196 189
197 const videos = res.body.data 190 expect(data).to.have.lengthOf(3)
198 expect(videos).to.have.lengthOf(3) 191 expect(data[0].name).to.equal('small video - youtube')
199 expect(videos[0].name).to.equal('small video - youtube') 192 expect(data[1].name).to.equal('super peertube2 video')
200 expect(videos[1].name).to.equal('super peertube2 video') 193 expect(data[2].name).to.equal('你好 世界 720p.mp4')
201 expect(videos[2].name).to.equal('你好 世界 720p.mp4')
202 }) 194 })
203 195
204 it('Should list the videos to import in my imports on server 1', async function () { 196 it('Should list the videos to import in my imports on server 1', async function () {
@@ -229,11 +221,11 @@ Ajouter un sous-titre est vraiment facile`)
229 await waitJobs(servers) 221 await waitJobs(servers)
230 222
231 for (const server of servers) { 223 for (const server of servers) {
232 const res = await getVideosList(server.url) 224 const { total, data } = await server.videosCommand.list()
233 expect(res.body.total).to.equal(3) 225 expect(total).to.equal(3)
234 expect(res.body.data).to.have.lengthOf(3) 226 expect(data).to.have.lengthOf(3)
235 227
236 const [ videoHttp, videoMagnet, videoTorrent ] = res.body.data 228 const [ videoHttp, videoMagnet, videoTorrent ] = data
237 await checkVideosServer1(server, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid) 229 await checkVideosServer1(server, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid)
238 } 230 }
239 }) 231 })
@@ -262,13 +254,13 @@ Ajouter un sous-titre est vraiment facile`)
262 await waitJobs(servers) 254 await waitJobs(servers)
263 255
264 for (const server of servers) { 256 for (const server of servers) {
265 const res = await getVideosList(server.url) 257 const { total, data } = await server.videosCommand.list()
266 expect(res.body.total).to.equal(4) 258 expect(total).to.equal(4)
267 expect(res.body.data).to.have.lengthOf(4) 259 expect(data).to.have.lengthOf(4)
268 260
269 await checkVideoServer2(server, res.body.data[0].uuid) 261 await checkVideoServer2(server, data[0].uuid)
270 262
271 const [ , videoHttp, videoMagnet, videoTorrent ] = res.body.data 263 const [ , videoHttp, videoMagnet, videoTorrent ] = data
272 await checkVideosServer1(server, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid) 264 await checkVideosServer1(server, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid)
273 } 265 }
274 }) 266 })
@@ -288,8 +280,7 @@ Ajouter un sous-titre est vraiment facile`)
288 await waitJobs(servers) 280 await waitJobs(servers)
289 281
290 for (const server of servers) { 282 for (const server of servers) {
291 const res = await getVideo(server.url, videoUUID) 283 const video = await server.videosCommand.get({ id: videoUUID })
292 const video: VideoDetails = res.body
293 284
294 expect(video.name).to.equal('transcoded video') 285 expect(video.name).to.equal('transcoded video')
295 expect(video.files).to.have.lengthOf(4) 286 expect(video.files).to.have.lengthOf(4)
@@ -339,8 +330,7 @@ Ajouter un sous-titre est vraiment facile`)
339 await waitJobs(servers) 330 await waitJobs(servers)
340 331
341 // test resolution 332 // test resolution
342 const res2 = await getVideo(servers[0].url, videoUUID) 333 const video = await servers[0].videosCommand.get({ id: videoUUID })
343 const video: VideoDetails = res2.body
344 expect(video.name).to.equal('hdr video') 334 expect(video.name).to.equal('hdr video')
345 const maxResolution = Math.max.apply(Math, video.files.map(function (o) { return o.resolution.id })) 335 const maxResolution = Math.max.apply(Math, video.files.map(function (o) { return o.resolution.id }))
346 expect(maxResolution, 'expected max resolution not met').to.equals(VideoResolution.H_1080P) 336 expect(maxResolution, 'expected max resolution not met').to.equals(VideoResolution.H_1080P)
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index 9dc26fca6..b8fff096d 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -2,18 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { 5import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils'
6 cleanupTests,
7 flushAndRunServer,
8 getAccountVideos,
9 getMyVideos,
10 getVideoChannelVideos,
11 getVideosList,
12 getVideosListWithToken,
13 ServerInfo,
14 setAccessTokensToServers,
15 uploadVideo
16} from '@shared/extra-utils'
17import { BooleanBothQuery, CustomConfig, ResultList, Video, VideosOverview } from '@shared/models' 6import { BooleanBothQuery, CustomConfig, ResultList, Video, VideosOverview } from '@shared/models'
18 7
19const expect = chai.expect 8const expect = chai.expect
@@ -37,10 +26,10 @@ describe('Test video NSFW policy', function () {
37 26
38 if (token) { 27 if (token) {
39 promises = [ 28 promises = [
40 getVideosListWithToken(server.url, token, query).then(res => res.body),
41 server.searchCommand.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }), 29 server.searchCommand.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }),
42 getAccountVideos(server.url, token, accountName, 0, 5, undefined, query).then(res => res.body), 30 server.videosCommand.listWithToken({ token, ...query }),
43 getVideoChannelVideos(server.url, token, videoChannelName, 0, 5, undefined, query).then(res => res.body) 31 server.videosCommand.listByAccount({ token, accountName, ...query }),
32 server.videosCommand.listByChannel({ token, videoChannelName, ...query })
44 ] 33 ]
45 34
46 // Overviews do not support video filters 35 // Overviews do not support video filters
@@ -54,10 +43,10 @@ describe('Test video NSFW policy', function () {
54 } 43 }
55 44
56 promises = [ 45 promises = [
57 getVideosList(server.url).then(res => res.body),
58 server.searchCommand.searchVideos({ search: 'n', sort: '-publishedAt' }), 46 server.searchCommand.searchVideos({ search: 'n', sort: '-publishedAt' }),
59 getAccountVideos(server.url, undefined, accountName, 0, 5).then(res => res.body), 47 server.videosCommand.list(),
60 getVideoChannelVideos(server.url, undefined, videoChannelName, 0, 5).then(res => res.body) 48 server.videosCommand.listByAccount({ accountName }),
49 server.videosCommand.listByChannel({ videoChannelName })
61 ] 50 ]
62 51
63 // Overviews do not support video filters 52 // Overviews do not support video filters
@@ -79,12 +68,12 @@ describe('Test video NSFW policy', function () {
79 68
80 { 69 {
81 const attributes = { name: 'nsfw', nsfw: true, category: 1 } 70 const attributes = { name: 'nsfw', nsfw: true, category: 1 }
82 await uploadVideo(server.url, server.accessToken, attributes) 71 await server.videosCommand.upload({ attributes })
83 } 72 }
84 73
85 { 74 {
86 const attributes = { name: 'normal', nsfw: false, category: 1 } 75 const attributes = { name: 'normal', nsfw: false, category: 1 }
87 await uploadVideo(server.url, server.accessToken, attributes) 76 await server.videosCommand.upload({ attributes })
88 } 77 }
89 78
90 customConfig = await server.configCommand.getCustomConfig() 79 customConfig = await server.configCommand.getCustomConfig()
@@ -192,13 +181,12 @@ describe('Test video NSFW policy', function () {
192 }) 181 })
193 182
194 it('Should be able to see my NSFW videos even with do_not_list user NSFW policy', async function () { 183 it('Should be able to see my NSFW videos even with do_not_list user NSFW policy', async function () {
195 const res = await getMyVideos(server.url, server.accessToken, 0, 5) 184 const { total, data } = await server.videosCommand.listMyVideos()
196 expect(res.body.total).to.equal(2) 185 expect(total).to.equal(2)
197 186
198 const videos = res.body.data 187 expect(data).to.have.lengthOf(2)
199 expect(videos).to.have.lengthOf(2) 188 expect(data[0].name).to.equal('normal')
200 expect(videos[0].name).to.equal('normal') 189 expect(data[1].name).to.equal('nsfw')
201 expect(videos[1].name).to.equal('nsfw')
202 }) 190 })
203 191
204 it('Should display NSFW videos when the nsfw param === true', async function () { 192 it('Should display NSFW videos when the nsfw param === true', async function () {
diff --git a/server/tests/api/videos/video-playlist-thumbnails.ts b/server/tests/api/videos/video-playlist-thumbnails.ts
index af5df8d90..14739af20 100644
--- a/server/tests/api/videos/video-playlist-thumbnails.ts
+++ b/server/tests/api/videos/video-playlist-thumbnails.ts
@@ -10,7 +10,6 @@ import {
10 setAccessTokensToServers, 10 setAccessTokensToServers,
11 setDefaultVideoChannel, 11 setDefaultVideoChannel,
12 testImage, 12 testImage,
13 uploadVideoAndGetId,
14 waitJobs 13 waitJobs
15} from '../../../../shared/extra-utils' 14} from '../../../../shared/extra-utils'
16import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' 15import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
@@ -55,8 +54,8 @@ describe('Playlist thumbnail', function () {
55 // Server 1 and server 2 follow each other 54 // Server 1 and server 2 follow each other
56 await doubleFollow(servers[0], servers[1]) 55 await doubleFollow(servers[0], servers[1])
57 56
58 video1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 1' })).id 57 video1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).id
59 video2 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 2' })).id 58 video2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).id
60 59
61 await waitJobs(servers) 60 await waitJobs(servers)
62 }) 61 })
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index e57d86c14..40f61ca19 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -13,9 +13,6 @@ import {
13 setAccessTokensToServers, 13 setAccessTokensToServers,
14 setDefaultVideoChannel, 14 setDefaultVideoChannel,
15 testImage, 15 testImage,
16 updateVideo,
17 uploadVideo,
18 uploadVideoAndGetId,
19 wait, 16 wait,
20 waitJobs 17 waitJobs
21} from '@shared/extra-utils' 18} from '@shared/extra-utils'
@@ -99,14 +96,14 @@ describe('Test video playlists', function () {
99 for (const server of servers) { 96 for (const server of servers) {
100 for (let i = 0; i < 7; i++) { 97 for (let i = 0; i < 7; i++) {
101 const name = `video ${i} server ${server.serverNumber}` 98 const name = `video ${i} server ${server.serverNumber}`
102 const resVideo = await uploadVideo(server.url, server.accessToken, { name, nsfw: false }) 99 const video = await server.videosCommand.upload({ attributes: { name, nsfw: false } })
103 100
104 server.videos.push(resVideo.body.video) 101 server.videos.push(video)
105 } 102 }
106 } 103 }
107 } 104 }
108 105
109 nsfwVideoServer1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'NSFW video', nsfw: true })).id 106 nsfwVideoServer1 = (await servers[0].videosCommand.quickUpload({ name: 'NSFW video', nsfw: true })).id
110 107
111 userTokenServer1 = await servers[0].usersCommand.generateUserAndToken('user1') 108 userTokenServer1 = await servers[0].usersCommand.generateUserAndToken('user1')
112 109
@@ -620,9 +617,9 @@ describe('Test video playlists', function () {
620 return commands[0].addElement({ token: userTokenServer1, playlistId: playlistServer1Id2, attributes }) 617 return commands[0].addElement({ token: userTokenServer1, playlistId: playlistServer1Id2, attributes })
621 } 618 }
622 619
623 video1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 89', token: userTokenServer1 })).uuid 620 video1 = (await servers[0].videosCommand.quickUpload({ name: 'video 89', token: userTokenServer1 })).uuid
624 video2 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 90' })).uuid 621 video2 = (await servers[1].videosCommand.quickUpload({ name: 'video 90' })).uuid
625 video3 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 91', nsfw: true })).uuid 622 video3 = (await servers[0].videosCommand.quickUpload({ name: 'video 91', nsfw: true })).uuid
626 623
627 await waitJobs(servers) 624 await waitJobs(servers)
628 625
@@ -640,7 +637,7 @@ describe('Test video playlists', function () {
640 const position = 1 637 const position = 1
641 638
642 { 639 {
643 await updateVideo(servers[0].url, servers[0].accessToken, video1, { privacy: VideoPrivacy.PRIVATE }) 640 await servers[0].videosCommand.update({ id: video1, attributes: { privacy: VideoPrivacy.PRIVATE } })
644 await waitJobs(servers) 641 await waitJobs(servers)
645 642
646 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 643 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -650,7 +647,7 @@ describe('Test video playlists', function () {
650 } 647 }
651 648
652 { 649 {
653 await updateVideo(servers[0].url, servers[0].accessToken, video1, { privacy: VideoPrivacy.PUBLIC }) 650 await servers[0].videosCommand.update({ id: video1, attributes: { privacy: VideoPrivacy.PUBLIC } })
654 await waitJobs(servers) 651 await waitJobs(servers)
655 652
656 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 653 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts
index 4e349e350..bcf431edb 100644
--- a/server/tests/api/videos/video-privacy.ts
+++ b/server/tests/api/videos/video-privacy.ts
@@ -3,22 +3,8 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import { cleanupTests, doubleFollow, flushAndRunServer, ServerInfo, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
7 cleanupTests, 7import { VideoCreateResult, VideoPrivacy } from '@shared/models'
8 doubleFollow,
9 flushAndRunServer,
10 getMyVideos,
11 getVideo,
12 getVideosList,
13 getVideosListWithToken,
14 getVideoWithToken,
15 ServerInfo,
16 setAccessTokensToServers,
17 updateVideo,
18 uploadVideo,
19 waitJobs
20} from '@shared/extra-utils'
21import { Video, VideoCreateResult, VideoPrivacy } from '@shared/models'
22 8
23const expect = chai.expect 9const expect = chai.expect
24 10
@@ -66,55 +52,53 @@ describe('Test video privacy', function () {
66 52
67 for (const privacy of [ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]) { 53 for (const privacy of [ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]) {
68 const attributes = { privacy } 54 const attributes = { privacy }
69 await uploadVideo(servers[0].url, servers[0].accessToken, attributes) 55 await servers[0].videosCommand.upload({ attributes })
70 } 56 }
71 57
72 await waitJobs(servers) 58 await waitJobs(servers)
73 }) 59 })
74 60
75 it('Should not have these private and internal videos on server 2', async function () { 61 it('Should not have these private and internal videos on server 2', async function () {
76 const res = await getVideosList(servers[1].url) 62 const { total, data } = await servers[1].videosCommand.list()
77 63
78 expect(res.body.total).to.equal(0) 64 expect(total).to.equal(0)
79 expect(res.body.data).to.have.lengthOf(0) 65 expect(data).to.have.lengthOf(0)
80 }) 66 })
81 67
82 it('Should not list the private and internal videos for an unauthenticated user on server 1', async function () { 68 it('Should not list the private and internal videos for an unauthenticated user on server 1', async function () {
83 const res = await getVideosList(servers[0].url) 69 const { total, data } = await servers[0].videosCommand.list()
84 70
85 expect(res.body.total).to.equal(0) 71 expect(total).to.equal(0)
86 expect(res.body.data).to.have.lengthOf(0) 72 expect(data).to.have.lengthOf(0)
87 }) 73 })
88 74
89 it('Should not list the private video and list the internal video for an authenticated user on server 1', async function () { 75 it('Should not list the private video and list the internal video for an authenticated user on server 1', async function () {
90 const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken) 76 const { total, data } = await servers[0].videosCommand.listWithToken()
91 77
92 expect(res.body.total).to.equal(1) 78 expect(total).to.equal(1)
93 expect(res.body.data).to.have.lengthOf(1) 79 expect(data).to.have.lengthOf(1)
94 80
95 expect(res.body.data[0].privacy.id).to.equal(VideoPrivacy.INTERNAL) 81 expect(data[0].privacy.id).to.equal(VideoPrivacy.INTERNAL)
96 }) 82 })
97 83
98 it('Should list my (private and internal) videos', async function () { 84 it('Should list my (private and internal) videos', async function () {
99 const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 10) 85 const { total, data } = await servers[0].videosCommand.listMyVideos()
100 86
101 expect(res.body.total).to.equal(2) 87 expect(total).to.equal(2)
102 expect(res.body.data).to.have.lengthOf(2) 88 expect(data).to.have.lengthOf(2)
103 89
104 const videos: Video[] = res.body.data 90 const privateVideo = data.find(v => v.privacy.id === VideoPrivacy.PRIVATE)
105
106 const privateVideo = videos.find(v => v.privacy.id === VideoPrivacy.PRIVATE)
107 privateVideoId = privateVideo.id 91 privateVideoId = privateVideo.id
108 privateVideoUUID = privateVideo.uuid 92 privateVideoUUID = privateVideo.uuid
109 93
110 const internalVideo = videos.find(v => v.privacy.id === VideoPrivacy.INTERNAL) 94 const internalVideo = data.find(v => v.privacy.id === VideoPrivacy.INTERNAL)
111 internalVideoId = internalVideo.id 95 internalVideoId = internalVideo.id
112 internalVideoUUID = internalVideo.uuid 96 internalVideoUUID = internalVideo.uuid
113 }) 97 })
114 98
115 it('Should not be able to watch the private/internal video with non authenticated user', async function () { 99 it('Should not be able to watch the private/internal video with non authenticated user', async function () {
116 await getVideo(servers[0].url, privateVideoUUID, HttpStatusCode.UNAUTHORIZED_401) 100 await servers[0].videosCommand.get({ id: privateVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
117 await getVideo(servers[0].url, internalVideoUUID, HttpStatusCode.UNAUTHORIZED_401) 101 await servers[0].videosCommand.get({ id: internalVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
118 }) 102 })
119 103
120 it('Should not be able to watch the private video with another user', async function () { 104 it('Should not be able to watch the private video with another user', async function () {
@@ -127,15 +111,20 @@ describe('Test video privacy', function () {
127 await servers[0].usersCommand.create({ username: user.username, password: user.password }) 111 await servers[0].usersCommand.create({ username: user.username, password: user.password })
128 112
129 anotherUserToken = await servers[0].loginCommand.getAccessToken(user) 113 anotherUserToken = await servers[0].loginCommand.getAccessToken(user)
130 await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, HttpStatusCode.FORBIDDEN_403) 114
115 await servers[0].videosCommand.getWithToken({
116 token: anotherUserToken,
117 id: privateVideoUUID,
118 expectedStatus: HttpStatusCode.FORBIDDEN_403
119 })
131 }) 120 })
132 121
133 it('Should be able to watch the internal video with another user', async function () { 122 it('Should be able to watch the internal video with another user', async function () {
134 await getVideoWithToken(servers[0].url, anotherUserToken, internalVideoUUID, HttpStatusCode.OK_200) 123 await servers[0].videosCommand.getWithToken({ token: anotherUserToken, id: internalVideoUUID })
135 }) 124 })
136 125
137 it('Should be able to watch the private video with the correct user', async function () { 126 it('Should be able to watch the private video with the correct user', async function () {
138 await getVideoWithToken(servers[0].url, servers[0].accessToken, privateVideoUUID, HttpStatusCode.OK_200) 127 await servers[0].videosCommand.getWithToken({ id: privateVideoUUID })
139 }) 128 })
140 }) 129 })
141 130
@@ -148,7 +137,7 @@ describe('Test video privacy', function () {
148 name: 'unlisted video', 137 name: 'unlisted video',
149 privacy: VideoPrivacy.UNLISTED 138 privacy: VideoPrivacy.UNLISTED
150 } 139 }
151 await uploadVideo(servers[1].url, servers[1].accessToken, attributes) 140 await servers[1].videosCommand.upload({ attributes })
152 141
153 // Server 2 has transcoding enabled 142 // Server 2 has transcoding enabled
154 await waitJobs(servers) 143 await waitJobs(servers)
@@ -156,32 +145,32 @@ describe('Test video privacy', function () {
156 145
157 it('Should not have this unlisted video listed on server 1 and 2', async function () { 146 it('Should not have this unlisted video listed on server 1 and 2', async function () {
158 for (const server of servers) { 147 for (const server of servers) {
159 const res = await getVideosList(server.url) 148 const { total, data } = await server.videosCommand.list()
160 149
161 expect(res.body.total).to.equal(0) 150 expect(total).to.equal(0)
162 expect(res.body.data).to.have.lengthOf(0) 151 expect(data).to.have.lengthOf(0)
163 } 152 }
164 }) 153 })
165 154
166 it('Should list my (unlisted) videos', async function () { 155 it('Should list my (unlisted) videos', async function () {
167 const res = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 1) 156 const { total, data } = await servers[1].videosCommand.listMyVideos()
168 157
169 expect(res.body.total).to.equal(1) 158 expect(total).to.equal(1)
170 expect(res.body.data).to.have.lengthOf(1) 159 expect(data).to.have.lengthOf(1)
171 160
172 unlistedVideo = res.body.data[0] 161 unlistedVideo = data[0]
173 }) 162 })
174 163
175 it('Should not be able to get this unlisted video using its id', async function () { 164 it('Should not be able to get this unlisted video using its id', async function () {
176 await getVideo(servers[1].url, unlistedVideo.id, 404) 165 await servers[1].videosCommand.get({ id: unlistedVideo.id, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
177 }) 166 })
178 167
179 it('Should be able to get this unlisted video using its uuid/shortUUID', async function () { 168 it('Should be able to get this unlisted video using its uuid/shortUUID', async function () {
180 for (const server of servers) { 169 for (const server of servers) {
181 for (const id of [ unlistedVideo.uuid, unlistedVideo.shortUUID ]) { 170 for (const id of [ unlistedVideo.uuid, unlistedVideo.shortUUID ]) {
182 const res = await getVideo(server.url, id) 171 const video = await server.videosCommand.get({ id })
183 172
184 expect(res.body.name).to.equal('unlisted video') 173 expect(video.name).to.equal('unlisted video')
185 } 174 }
186 } 175 }
187 }) 176 })
@@ -193,28 +182,28 @@ describe('Test video privacy', function () {
193 name: 'unlisted video', 182 name: 'unlisted video',
194 privacy: VideoPrivacy.UNLISTED 183 privacy: VideoPrivacy.UNLISTED
195 } 184 }
196 await uploadVideo(servers[0].url, servers[0].accessToken, attributes) 185 await servers[0].videosCommand.upload({ attributes })
197 186
198 await waitJobs(servers) 187 await waitJobs(servers)
199 }) 188 })
200 189
201 it('Should list my new unlisted video', async function () { 190 it('Should list my new unlisted video', async function () {
202 const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 3) 191 const { total, data } = await servers[0].videosCommand.listMyVideos()
203 192
204 expect(res.body.total).to.equal(3) 193 expect(total).to.equal(3)
205 expect(res.body.data).to.have.lengthOf(3) 194 expect(data).to.have.lengthOf(3)
206 195
207 nonFederatedUnlistedVideoUUID = res.body.data[0].uuid 196 nonFederatedUnlistedVideoUUID = data[0].uuid
208 }) 197 })
209 198
210 it('Should be able to get non-federated unlisted video from origin', async function () { 199 it('Should be able to get non-federated unlisted video from origin', async function () {
211 const res = await getVideo(servers[0].url, nonFederatedUnlistedVideoUUID) 200 const video = await servers[0].videosCommand.get({ id: nonFederatedUnlistedVideoUUID })
212 201
213 expect(res.body.name).to.equal('unlisted video') 202 expect(video.name).to.equal('unlisted video')
214 }) 203 })
215 204
216 it('Should not be able to get non-federated unlisted video from federated server', async function () { 205 it('Should not be able to get non-federated unlisted video from federated server', async function () {
217 await getVideo(servers[1].url, nonFederatedUnlistedVideoUUID, HttpStatusCode.NOT_FOUND_404) 206 await servers[1].videosCommand.get({ id: nonFederatedUnlistedVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
218 }) 207 })
219 }) 208 })
220 209
@@ -226,20 +215,20 @@ describe('Test video privacy', function () {
226 now = Date.now() 215 now = Date.now()
227 216
228 { 217 {
229 const attribute = { 218 const attributes = {
230 name: 'private video becomes public', 219 name: 'private video becomes public',
231 privacy: VideoPrivacy.PUBLIC 220 privacy: VideoPrivacy.PUBLIC
232 } 221 }
233 222
234 await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, attribute) 223 await servers[0].videosCommand.update({ id: privateVideoId, attributes })
235 } 224 }
236 225
237 { 226 {
238 const attribute = { 227 const attributes = {
239 name: 'internal video becomes public', 228 name: 'internal video becomes public',
240 privacy: VideoPrivacy.PUBLIC 229 privacy: VideoPrivacy.PUBLIC
241 } 230 }
242 await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, attribute) 231 await servers[0].videosCommand.update({ id: internalVideoId, attributes })
243 } 232 }
244 233
245 await waitJobs(servers) 234 await waitJobs(servers)
@@ -247,13 +236,12 @@ describe('Test video privacy', function () {
247 236
248 it('Should have this new public video listed on server 1 and 2', async function () { 237 it('Should have this new public video listed on server 1 and 2', async function () {
249 for (const server of servers) { 238 for (const server of servers) {
250 const res = await getVideosList(server.url) 239 const { total, data } = await server.videosCommand.list()
251 expect(res.body.total).to.equal(2) 240 expect(total).to.equal(2)
252 expect(res.body.data).to.have.lengthOf(2) 241 expect(data).to.have.lengthOf(2)
253 242
254 const videos: Video[] = res.body.data 243 const privateVideo = data.find(v => v.name === 'private video becomes public')
255 const privateVideo = videos.find(v => v.name === 'private video becomes public') 244 const internalVideo = data.find(v => v.name === 'internal video becomes public')
256 const internalVideo = videos.find(v => v.name === 'internal video becomes public')
257 245
258 expect(privateVideo).to.not.be.undefined 246 expect(privateVideo).to.not.be.undefined
259 expect(internalVideo).to.not.be.undefined 247 expect(internalVideo).to.not.be.undefined
@@ -270,27 +258,25 @@ describe('Test video privacy', function () {
270 it('Should set these videos as private and internal', async function () { 258 it('Should set these videos as private and internal', async function () {
271 this.timeout(10000) 259 this.timeout(10000)
272 260
273 await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, { privacy: VideoPrivacy.PRIVATE }) 261 await servers[0].videosCommand.update({ id: internalVideoId, attributes: { privacy: VideoPrivacy.PRIVATE } })
274 await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, { privacy: VideoPrivacy.INTERNAL }) 262 await servers[0].videosCommand.update({ id: privateVideoId, attributes: { privacy: VideoPrivacy.INTERNAL } })
275 263
276 await waitJobs(servers) 264 await waitJobs(servers)
277 265
278 for (const server of servers) { 266 for (const server of servers) {
279 const res = await getVideosList(server.url) 267 const { total, data } = await server.videosCommand.list()
280 268
281 expect(res.body.total).to.equal(0) 269 expect(total).to.equal(0)
282 expect(res.body.data).to.have.lengthOf(0) 270 expect(data).to.have.lengthOf(0)
283 } 271 }
284 272
285 { 273 {
286 const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5) 274 const { total, data } = await servers[0].videosCommand.listMyVideos()
287 const videos = res.body.data 275 expect(total).to.equal(3)
288 276 expect(data).to.have.lengthOf(3)
289 expect(res.body.total).to.equal(3)
290 expect(videos).to.have.lengthOf(3)
291 277
292 const privateVideo = videos.find(v => v.name === 'private video becomes public') 278 const privateVideo = data.find(v => v.name === 'private video becomes public')
293 const internalVideo = videos.find(v => v.name === 'internal video becomes public') 279 const internalVideo = data.find(v => v.name === 'internal video becomes public')
294 280
295 expect(privateVideo).to.not.be.undefined 281 expect(privateVideo).to.not.be.undefined
296 expect(internalVideo).to.not.be.undefined 282 expect(internalVideo).to.not.be.undefined
diff --git a/server/tests/api/videos/video-schedule-update.ts b/server/tests/api/videos/video-schedule-update.ts
index 204f43611..635ae6ff1 100644
--- a/server/tests/api/videos/video-schedule-update.ts
+++ b/server/tests/api/videos/video-schedule-update.ts
@@ -1,22 +1,17 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
5import { VideoPrivacy } from '../../../../shared/models/videos' 4import * as chai from 'chai'
6import { 5import {
7 cleanupTests, 6 cleanupTests,
8 doubleFollow, 7 doubleFollow,
9 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
10 getMyVideos,
11 getVideosList,
12 getVideoWithToken,
13 ServerInfo, 9 ServerInfo,
14 setAccessTokensToServers, 10 setAccessTokensToServers,
15 updateVideo, 11 wait,
16 uploadVideo, 12 waitJobs
17 wait 13} from '@shared/extra-utils'
18} from '../../../../shared/extra-utils' 14import { VideoPrivacy } from '@shared/models'
19import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
20 15
21const expect = chai.expect 16const expect = chai.expect
22 17
@@ -45,35 +40,34 @@ describe('Test video update scheduler', function () {
45 it('Should upload a video and schedule an update in 10 seconds', async function () { 40 it('Should upload a video and schedule an update in 10 seconds', async function () {
46 this.timeout(10000) 41 this.timeout(10000)
47 42
48 const videoAttributes = { 43 const attributes = {
49 name: 'video 1', 44 name: 'video 1',
50 privacy: VideoPrivacy.PRIVATE, 45 privacy: VideoPrivacy.PRIVATE,
51 scheduleUpdate: { 46 scheduleUpdate: {
52 updateAt: in10Seconds().toISOString(), 47 updateAt: in10Seconds().toISOString(),
53 privacy: VideoPrivacy.PUBLIC 48 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
54 } 49 }
55 } 50 }
56 51
57 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) 52 await servers[0].videosCommand.upload({ attributes })
58 53
59 await waitJobs(servers) 54 await waitJobs(servers)
60 }) 55 })
61 56
62 it('Should not list the video (in privacy mode)', async function () { 57 it('Should not list the video (in privacy mode)', async function () {
63 for (const server of servers) { 58 for (const server of servers) {
64 const res = await getVideosList(server.url) 59 const { total } = await server.videosCommand.list()
65 60
66 expect(res.body.total).to.equal(0) 61 expect(total).to.equal(0)
67 } 62 }
68 }) 63 })
69 64
70 it('Should have my scheduled video in my account videos', async function () { 65 it('Should have my scheduled video in my account videos', async function () {
71 const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5) 66 const { total, data } = await servers[0].videosCommand.listMyVideos()
72 expect(res.body.total).to.equal(1) 67 expect(total).to.equal(1)
73 68
74 const videoFromList = res.body.data[0] 69 const videoFromList = data[0]
75 const res2 = await getVideoWithToken(servers[0].url, servers[0].accessToken, videoFromList.uuid) 70 const videoFromGet = await servers[0].videosCommand.getWithToken({ id: videoFromList.uuid })
76 const videoFromGet = res2.body
77 71
78 for (const video of [ videoFromList, videoFromGet ]) { 72 for (const video of [ videoFromList, videoFromGet ]) {
79 expect(video.name).to.equal('video 1') 73 expect(video.name).to.equal('video 1')
@@ -90,23 +84,23 @@ describe('Test video update scheduler', function () {
90 await waitJobs(servers) 84 await waitJobs(servers)
91 85
92 for (const server of servers) { 86 for (const server of servers) {
93 const res = await getVideosList(server.url) 87 const { total, data } = await server.videosCommand.list()
94 88
95 expect(res.body.total).to.equal(1) 89 expect(total).to.equal(1)
96 expect(res.body.data[0].name).to.equal('video 1') 90 expect(data[0].name).to.equal('video 1')
97 } 91 }
98 }) 92 })
99 93
100 it('Should upload a video without scheduling an update', async function () { 94 it('Should upload a video without scheduling an update', async function () {
101 this.timeout(10000) 95 this.timeout(10000)
102 96
103 const videoAttributes = { 97 const attributes = {
104 name: 'video 2', 98 name: 'video 2',
105 privacy: VideoPrivacy.PRIVATE 99 privacy: VideoPrivacy.PRIVATE
106 } 100 }
107 101
108 const res = await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) 102 const { uuid } = await servers[0].videosCommand.upload({ attributes })
109 video2UUID = res.body.video.uuid 103 video2UUID = uuid
110 104
111 await waitJobs(servers) 105 await waitJobs(servers)
112 }) 106 })
@@ -114,31 +108,31 @@ describe('Test video update scheduler', function () {
114 it('Should update a video by scheduling an update', async function () { 108 it('Should update a video by scheduling an update', async function () {
115 this.timeout(10000) 109 this.timeout(10000)
116 110
117 const videoAttributes = { 111 const attributes = {
118 name: 'video 2 updated', 112 name: 'video 2 updated',
119 scheduleUpdate: { 113 scheduleUpdate: {
120 updateAt: in10Seconds().toISOString(), 114 updateAt: in10Seconds().toISOString(),
121 privacy: VideoPrivacy.PUBLIC 115 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
122 } 116 }
123 } 117 }
124 118
125 await updateVideo(servers[0].url, servers[0].accessToken, video2UUID, videoAttributes) 119 await servers[0].videosCommand.update({ id: video2UUID, attributes })
126 await waitJobs(servers) 120 await waitJobs(servers)
127 }) 121 })
128 122
129 it('Should not display the updated video', async function () { 123 it('Should not display the updated video', async function () {
130 for (const server of servers) { 124 for (const server of servers) {
131 const res = await getVideosList(server.url) 125 const { total } = await server.videosCommand.list()
132 126
133 expect(res.body.total).to.equal(1) 127 expect(total).to.equal(1)
134 } 128 }
135 }) 129 })
136 130
137 it('Should have my scheduled updated video in my account videos', async function () { 131 it('Should have my scheduled updated video in my account videos', async function () {
138 const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5) 132 const { total, data } = await servers[0].videosCommand.listMyVideos()
139 expect(res.body.total).to.equal(2) 133 expect(total).to.equal(2)
140 134
141 const video = res.body.data.find(v => v.uuid === video2UUID) 135 const video = data.find(v => v.uuid === video2UUID)
142 expect(video).not.to.be.undefined 136 expect(video).not.to.be.undefined
143 137
144 expect(video.name).to.equal('video 2 updated') 138 expect(video.name).to.equal('video 2 updated')
@@ -155,11 +149,10 @@ describe('Test video update scheduler', function () {
155 await waitJobs(servers) 149 await waitJobs(servers)
156 150
157 for (const server of servers) { 151 for (const server of servers) {
158 const res = await getVideosList(server.url) 152 const { total, data } = await server.videosCommand.list()
159 153 expect(total).to.equal(2)
160 expect(res.body.total).to.equal(2)
161 154
162 const video = res.body.data.find(v => v.uuid === video2UUID) 155 const video = data.find(v => v.uuid === video2UUID)
163 expect(video).not.to.be.undefined 156 expect(video).not.to.be.undefined
164 expect(video.name).to.equal('video 2 updated') 157 expect(video.name).to.equal('video 2 updated')
165 } 158 }
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index f16b22bae..b41c68283 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -2,11 +2,9 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { FfprobeData } from 'fluent-ffmpeg'
6import { omit } from 'lodash' 5import { omit } from 'lodash'
7import { join } from 'path' 6import { join } from 'path'
8import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' 7import { HttpStatusCode } from '@shared/core-utils'
9import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
10import { 8import {
11 buildAbsoluteFixturePath, 9 buildAbsoluteFixturePath,
12 cleanupTests, 10 cleanupTests,
@@ -14,19 +12,14 @@ import {
14 flushAndRunMultipleServers, 12 flushAndRunMultipleServers,
15 generateHighBitrateVideo, 13 generateHighBitrateVideo,
16 generateVideoWithFramerate, 14 generateVideoWithFramerate,
17 getMyVideos,
18 getVideo,
19 getVideoFileMetadataUrl,
20 getVideosList,
21 makeGetRequest, 15 makeGetRequest,
22 ServerInfo, 16 ServerInfo,
23 setAccessTokensToServers, 17 setAccessTokensToServers,
24 uploadVideo,
25 uploadVideoAndGetId,
26 waitJobs, 18 waitJobs,
27 webtorrentAdd 19 webtorrentAdd
28} from '../../../../shared/extra-utils' 20} from '@shared/extra-utils'
29import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' 21import { getMaxBitrate, VideoResolution, VideoState } from '@shared/models'
22import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants'
30import { 23import {
31 canDoQuickTranscode, 24 canDoQuickTranscode,
32 getAudioStream, 25 getAudioStream,
@@ -84,21 +77,20 @@ describe('Test video transcoding', function () {
84 it('Should not transcode video on server 1', async function () { 77 it('Should not transcode video on server 1', async function () {
85 this.timeout(60_000) 78 this.timeout(60_000)
86 79
87 const videoAttributes = { 80 const attributes = {
88 name: 'my super name for server 1', 81 name: 'my super name for server 1',
89 description: 'my super description for server 1', 82 description: 'my super description for server 1',
90 fixture: 'video_short.webm' 83 fixture: 'video_short.webm'
91 } 84 }
92 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) 85 await servers[0].videosCommand.upload({ attributes })
93 86
94 await waitJobs(servers) 87 await waitJobs(servers)
95 88
96 for (const server of servers) { 89 for (const server of servers) {
97 const res = await getVideosList(server.url) 90 const { data } = await server.videosCommand.list()
98 const video = res.body.data[0] 91 const video = data[0]
99 92
100 const res2 = await getVideo(server.url, video.id) 93 const videoDetails = await server.videosCommand.get({ id: video.id })
101 const videoDetails = res2.body
102 expect(videoDetails.files).to.have.lengthOf(1) 94 expect(videoDetails.files).to.have.lengthOf(1)
103 95
104 const magnetUri = videoDetails.files[0].magnetUri 96 const magnetUri = videoDetails.files[0].magnetUri
@@ -114,21 +106,20 @@ describe('Test video transcoding', function () {
114 it('Should transcode video on server 2', async function () { 106 it('Should transcode video on server 2', async function () {
115 this.timeout(120_000) 107 this.timeout(120_000)
116 108
117 const videoAttributes = { 109 const attributes = {
118 name: 'my super name for server 2', 110 name: 'my super name for server 2',
119 description: 'my super description for server 2', 111 description: 'my super description for server 2',
120 fixture: 'video_short.webm' 112 fixture: 'video_short.webm'
121 } 113 }
122 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 114 await servers[1].videosCommand.upload({ attributes })
123 115
124 await waitJobs(servers) 116 await waitJobs(servers)
125 117
126 for (const server of servers) { 118 for (const server of servers) {
127 const res = await getVideosList(server.url) 119 const { data } = await server.videosCommand.list()
128 120
129 const video = res.body.data.find(v => v.name === videoAttributes.name) 121 const video = data.find(v => v.name === attributes.name)
130 const res2 = await getVideo(server.url, video.id) 122 const videoDetails = await server.videosCommand.get({ id: video.id })
131 const videoDetails = res2.body
132 123
133 expect(videoDetails.files).to.have.lengthOf(4) 124 expect(videoDetails.files).to.have.lengthOf(4)
134 125
@@ -147,47 +138,50 @@ describe('Test video transcoding', function () {
147 138
148 { 139 {
149 // Upload the video, but wait transcoding 140 // Upload the video, but wait transcoding
150 const videoAttributes = { 141 const attributes = {
151 name: 'waiting video', 142 name: 'waiting video',
152 fixture: 'video_short1.webm', 143 fixture: 'video_short1.webm',
153 waitTranscoding: true 144 waitTranscoding: true
154 } 145 }
155 const resVideo = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 146 const { uuid } = await servers[1].videosCommand.upload({ attributes })
156 const videoId = resVideo.body.video.uuid 147 const videoId = uuid
157 148
158 // Should be in transcode state 149 // Should be in transcode state
159 const { body } = await getVideo(servers[1].url, videoId) 150 const body = await servers[1].videosCommand.get({ id: videoId })
160 expect(body.name).to.equal('waiting video') 151 expect(body.name).to.equal('waiting video')
161 expect(body.state.id).to.equal(VideoState.TO_TRANSCODE) 152 expect(body.state.id).to.equal(VideoState.TO_TRANSCODE)
162 expect(body.state.label).to.equal('To transcode') 153 expect(body.state.label).to.equal('To transcode')
163 expect(body.waitTranscoding).to.be.true 154 expect(body.waitTranscoding).to.be.true
164 155
165 // Should have my video 156 {
166 const resMyVideos = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 10) 157 // Should have my video
167 const videoToFindInMine = resMyVideos.body.data.find(v => v.name === videoAttributes.name) 158 const { data } = await servers[1].videosCommand.listMyVideos()
168 expect(videoToFindInMine).not.to.be.undefined 159 const videoToFindInMine = data.find(v => v.name === attributes.name)
169 expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE) 160 expect(videoToFindInMine).not.to.be.undefined
170 expect(videoToFindInMine.state.label).to.equal('To transcode') 161 expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE)
171 expect(videoToFindInMine.waitTranscoding).to.be.true 162 expect(videoToFindInMine.state.label).to.equal('To transcode')
163 expect(videoToFindInMine.waitTranscoding).to.be.true
164 }
172 165
173 // Should not list this video 166 {
174 const resVideos = await getVideosList(servers[1].url) 167 // Should not list this video
175 const videoToFindInList = resVideos.body.data.find(v => v.name === videoAttributes.name) 168 const { data } = await servers[1].videosCommand.list()
176 expect(videoToFindInList).to.be.undefined 169 const videoToFindInList = data.find(v => v.name === attributes.name)
170 expect(videoToFindInList).to.be.undefined
171 }
177 172
178 // Server 1 should not have the video yet 173 // Server 1 should not have the video yet
179 await getVideo(servers[0].url, videoId, HttpStatusCode.NOT_FOUND_404) 174 await servers[0].videosCommand.get({ id: videoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
180 } 175 }
181 176
182 await waitJobs(servers) 177 await waitJobs(servers)
183 178
184 for (const server of servers) { 179 for (const server of servers) {
185 const res = await getVideosList(server.url) 180 const { data } = await server.videosCommand.list()
186 const videoToFind = res.body.data.find(v => v.name === 'waiting video') 181 const videoToFind = data.find(v => v.name === 'waiting video')
187 expect(videoToFind).not.to.be.undefined 182 expect(videoToFind).not.to.be.undefined
188 183
189 const res2 = await getVideo(server.url, videoToFind.id) 184 const videoDetails = await server.videosCommand.get({ id: videoToFind.id })
190 const videoDetails: VideoDetails = res2.body
191 185
192 expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED) 186 expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED)
193 expect(videoDetails.state.label).to.equal('Published') 187 expect(videoDetails.state.label).to.equal('Published')
@@ -208,22 +202,20 @@ describe('Test video transcoding', function () {
208 } 202 }
209 203
210 for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) { 204 for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) {
211 const videoAttributes = { 205 const attributes = {
212 name: fixture, 206 name: fixture,
213 fixture 207 fixture
214 } 208 }
215 209
216 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 210 await servers[1].videosCommand.upload({ attributes })
217 211
218 await waitJobs(servers) 212 await waitJobs(servers)
219 213
220 for (const server of servers) { 214 for (const server of servers) {
221 const res = await getVideosList(server.url) 215 const { data } = await server.videosCommand.list()
222
223 const video = res.body.data.find(v => v.name === videoAttributes.name)
224 const res2 = await getVideo(server.url, video.id)
225 const videoDetails = res2.body
226 216
217 const video = data.find(v => v.name === attributes.name)
218 const videoDetails = await server.videosCommand.get({ id: video.id })
227 expect(videoDetails.files).to.have.lengthOf(4) 219 expect(videoDetails.files).to.have.lengthOf(4)
228 220
229 const magnetUri = videoDetails.files[0].magnetUri 221 const magnetUri = videoDetails.files[0].magnetUri
@@ -235,22 +227,20 @@ describe('Test video transcoding', function () {
235 it('Should transcode a 4k video', async function () { 227 it('Should transcode a 4k video', async function () {
236 this.timeout(200_000) 228 this.timeout(200_000)
237 229
238 const videoAttributes = { 230 const attributes = {
239 name: '4k video', 231 name: '4k video',
240 fixture: 'video_short_4k.mp4' 232 fixture: 'video_short_4k.mp4'
241 } 233 }
242 234
243 const resUpload = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 235 const { uuid } = await servers[1].videosCommand.upload({ attributes })
244 video4k = resUpload.body.video.uuid 236 video4k = uuid
245 237
246 await waitJobs(servers) 238 await waitJobs(servers)
247 239
248 const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ] 240 const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ]
249 241
250 for (const server of servers) { 242 for (const server of servers) {
251 const res = await getVideo(server.url, video4k) 243 const videoDetails = await server.videosCommand.get({ id: video4k })
252 const videoDetails: VideoDetails = res.body
253
254 expect(videoDetails.files).to.have.lengthOf(resolutions.length) 244 expect(videoDetails.files).to.have.lengthOf(resolutions.length)
255 245
256 for (const r of resolutions) { 246 for (const r of resolutions) {
@@ -266,20 +256,19 @@ describe('Test video transcoding', function () {
266 it('Should transcode high bit rate mp3 to proper bit rate', async function () { 256 it('Should transcode high bit rate mp3 to proper bit rate', async function () {
267 this.timeout(60_000) 257 this.timeout(60_000)
268 258
269 const videoAttributes = { 259 const attributes = {
270 name: 'mp3_256k', 260 name: 'mp3_256k',
271 fixture: 'video_short_mp3_256k.mp4' 261 fixture: 'video_short_mp3_256k.mp4'
272 } 262 }
273 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 263 await servers[1].videosCommand.upload({ attributes })
274 264
275 await waitJobs(servers) 265 await waitJobs(servers)
276 266
277 for (const server of servers) { 267 for (const server of servers) {
278 const res = await getVideosList(server.url) 268 const { data } = await server.videosCommand.list()
279 269
280 const video = res.body.data.find(v => v.name === videoAttributes.name) 270 const video = data.find(v => v.name === attributes.name)
281 const res2 = await getVideo(server.url, video.id) 271 const videoDetails = await server.videosCommand.get({ id: video.id })
282 const videoDetails: VideoDetails = res2.body
283 272
284 expect(videoDetails.files).to.have.lengthOf(4) 273 expect(videoDetails.files).to.have.lengthOf(4)
285 274
@@ -298,20 +287,19 @@ describe('Test video transcoding', function () {
298 it('Should transcode video with no audio and have no audio itself', async function () { 287 it('Should transcode video with no audio and have no audio itself', async function () {
299 this.timeout(60_000) 288 this.timeout(60_000)
300 289
301 const videoAttributes = { 290 const attributes = {
302 name: 'no_audio', 291 name: 'no_audio',
303 fixture: 'video_short_no_audio.mp4' 292 fixture: 'video_short_no_audio.mp4'
304 } 293 }
305 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 294 await servers[1].videosCommand.upload({ attributes })
306 295
307 await waitJobs(servers) 296 await waitJobs(servers)
308 297
309 for (const server of servers) { 298 for (const server of servers) {
310 const res = await getVideosList(server.url) 299 const { data } = await server.videosCommand.list()
311 300
312 const video = res.body.data.find(v => v.name === videoAttributes.name) 301 const video = data.find(v => v.name === attributes.name)
313 const res2 = await getVideo(server.url, video.id) 302 const videoDetails = await server.videosCommand.get({ id: video.id })
314 const videoDetails: VideoDetails = res2.body
315 303
316 expect(videoDetails.files).to.have.lengthOf(4) 304 expect(videoDetails.files).to.have.lengthOf(4)
317 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4')) 305 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
@@ -323,24 +311,23 @@ describe('Test video transcoding', function () {
323 it('Should leave the audio untouched, but properly transcode the video', async function () { 311 it('Should leave the audio untouched, but properly transcode the video', async function () {
324 this.timeout(60_000) 312 this.timeout(60_000)
325 313
326 const videoAttributes = { 314 const attributes = {
327 name: 'untouched_audio', 315 name: 'untouched_audio',
328 fixture: 'video_short.mp4' 316 fixture: 'video_short.mp4'
329 } 317 }
330 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 318 await servers[1].videosCommand.upload({ attributes })
331 319
332 await waitJobs(servers) 320 await waitJobs(servers)
333 321
334 for (const server of servers) { 322 for (const server of servers) {
335 const res = await getVideosList(server.url) 323 const { data } = await server.videosCommand.list()
336 324
337 const video = res.body.data.find(v => v.name === videoAttributes.name) 325 const video = data.find(v => v.name === attributes.name)
338 const res2 = await getVideo(server.url, video.id) 326 const videoDetails = await server.videosCommand.get({ id: video.id })
339 const videoDetails: VideoDetails = res2.body
340 327
341 expect(videoDetails.files).to.have.lengthOf(4) 328 expect(videoDetails.files).to.have.lengthOf(4)
342 329
343 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) 330 const fixturePath = buildAbsoluteFixturePath(attributes.fixture)
344 const fixtureVideoProbe = await getAudioStream(fixturePath) 331 const fixtureVideoProbe = await getAudioStream(fixturePath)
345 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4')) 332 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
346 333
@@ -384,17 +371,16 @@ describe('Test video transcoding', function () {
384 it('Should merge an audio file with the preview file', async function () { 371 it('Should merge an audio file with the preview file', async function () {
385 this.timeout(60_000) 372 this.timeout(60_000)
386 373
387 const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' } 374 const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
388 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg, HttpStatusCode.OK_200, mode) 375 await servers[1].videosCommand.upload({ attributes, mode })
389 376
390 await waitJobs(servers) 377 await waitJobs(servers)
391 378
392 for (const server of servers) { 379 for (const server of servers) {
393 const res = await getVideosList(server.url) 380 const { data } = await server.videosCommand.list()
394 381
395 const video = res.body.data.find(v => v.name === 'audio_with_preview') 382 const video = data.find(v => v.name === 'audio_with_preview')
396 const res2 = await getVideo(server.url, video.id) 383 const videoDetails = await server.videosCommand.get({ id: video.id })
397 const videoDetails: VideoDetails = res2.body
398 384
399 expect(videoDetails.files).to.have.lengthOf(1) 385 expect(videoDetails.files).to.have.lengthOf(1)
400 386
@@ -409,17 +395,16 @@ describe('Test video transcoding', function () {
409 it('Should upload an audio file and choose a default background image', async function () { 395 it('Should upload an audio file and choose a default background image', async function () {
410 this.timeout(60_000) 396 this.timeout(60_000)
411 397
412 const videoAttributesArg = { name: 'audio_without_preview', fixture: 'sample.ogg' } 398 const attributes = { name: 'audio_without_preview', fixture: 'sample.ogg' }
413 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg, HttpStatusCode.OK_200, mode) 399 await servers[1].videosCommand.upload({ attributes, mode })
414 400
415 await waitJobs(servers) 401 await waitJobs(servers)
416 402
417 for (const server of servers) { 403 for (const server of servers) {
418 const res = await getVideosList(server.url) 404 const { data } = await server.videosCommand.list()
419 405
420 const video = res.body.data.find(v => v.name === 'audio_without_preview') 406 const video = data.find(v => v.name === 'audio_without_preview')
421 const res2 = await getVideo(server.url, video.id) 407 const videoDetails = await server.videosCommand.get({ id: video.id })
422 const videoDetails = res2.body
423 408
424 expect(videoDetails.files).to.have.lengthOf(1) 409 expect(videoDetails.files).to.have.lengthOf(1)
425 410
@@ -448,14 +433,13 @@ describe('Test video transcoding', function () {
448 } 433 }
449 }) 434 })
450 435
451 const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' } 436 const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
452 const resVideo = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg, HttpStatusCode.OK_200, mode) 437 const { id } = await servers[1].videosCommand.upload({ attributes, mode })
453 438
454 await waitJobs(servers) 439 await waitJobs(servers)
455 440
456 for (const server of servers) { 441 for (const server of servers) {
457 const res2 = await getVideo(server.url, resVideo.body.video.id) 442 const videoDetails = await server.videosCommand.get({ id })
458 const videoDetails: VideoDetails = res2.body
459 443
460 for (const files of [ videoDetails.files, videoDetails.streamingPlaylists[0].files ]) { 444 for (const files of [ videoDetails.files, videoDetails.streamingPlaylists[0].files ]) {
461 expect(files).to.have.lengthOf(2) 445 expect(files).to.have.lengthOf(2)
@@ -481,21 +465,20 @@ describe('Test video transcoding', function () {
481 it('Should transcode a 60 FPS video', async function () { 465 it('Should transcode a 60 FPS video', async function () {
482 this.timeout(60_000) 466 this.timeout(60_000)
483 467
484 const videoAttributes = { 468 const attributes = {
485 name: 'my super 30fps name for server 2', 469 name: 'my super 30fps name for server 2',
486 description: 'my super 30fps description for server 2', 470 description: 'my super 30fps description for server 2',
487 fixture: '60fps_720p_small.mp4' 471 fixture: '60fps_720p_small.mp4'
488 } 472 }
489 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 473 await servers[1].videosCommand.upload({ attributes })
490 474
491 await waitJobs(servers) 475 await waitJobs(servers)
492 476
493 for (const server of servers) { 477 for (const server of servers) {
494 const res = await getVideosList(server.url) 478 const { data } = await server.videosCommand.list()
495 479
496 const video = res.body.data.find(v => v.name === videoAttributes.name) 480 const video = data.find(v => v.name === attributes.name)
497 const res2 = await getVideo(server.url, video.id) 481 const videoDetails = await server.videosCommand.get({ id: video.id })
498 const videoDetails: VideoDetails = res2.body
499 482
500 expect(videoDetails.files).to.have.lengthOf(4) 483 expect(videoDetails.files).to.have.lengthOf(4)
501 expect(videoDetails.files[0].fps).to.be.above(58).and.below(62) 484 expect(videoDetails.files[0].fps).to.be.above(58).and.below(62)
@@ -529,20 +512,20 @@ describe('Test video transcoding', function () {
529 expect(fps).to.be.equal(59) 512 expect(fps).to.be.equal(59)
530 } 513 }
531 514
532 const videoAttributes = { 515 const attributes = {
533 name: '59fps video', 516 name: '59fps video',
534 description: '59fps video', 517 description: '59fps video',
535 fixture: tempFixturePath 518 fixture: tempFixturePath
536 } 519 }
537 520
538 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 521 await servers[1].videosCommand.upload({ attributes })
539 522
540 await waitJobs(servers) 523 await waitJobs(servers)
541 524
542 for (const server of servers) { 525 for (const server of servers) {
543 const res = await getVideosList(server.url) 526 const { data } = await server.videosCommand.list()
544 527
545 const video = res.body.data.find(v => v.name === videoAttributes.name) 528 const video = data.find(v => v.name === attributes.name)
546 529
547 { 530 {
548 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4')) 531 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
@@ -572,20 +555,20 @@ describe('Test video transcoding', function () {
572 expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS)) 555 expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS))
573 } 556 }
574 557
575 const videoAttributes = { 558 const attributes = {
576 name: 'high bitrate video', 559 name: 'high bitrate video',
577 description: 'high bitrate video', 560 description: 'high bitrate video',
578 fixture: tempFixturePath 561 fixture: tempFixturePath
579 } 562 }
580 563
581 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 564 await servers[1].videosCommand.upload({ attributes })
582 565
583 await waitJobs(servers) 566 await waitJobs(servers)
584 567
585 for (const server of servers) { 568 for (const server of servers) {
586 const res = await getVideosList(server.url) 569 const { data } = await server.videosCommand.list()
587 570
588 const video = res.body.data.find(v => v.name === videoAttributes.name) 571 const video = data.find(v => v.name === attributes.name)
589 572
590 for (const resolution of [ '240', '360', '480', '720', '1080' ]) { 573 for (const resolution of [ '240', '360', '480', '720', '1080' ]) {
591 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4')) 574 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
@@ -621,19 +604,18 @@ describe('Test video transcoding', function () {
621 } 604 }
622 await servers[1].configCommand.updateCustomSubConfig({ newConfig }) 605 await servers[1].configCommand.updateCustomSubConfig({ newConfig })
623 606
624 const videoAttributes = { 607 const attributes = {
625 name: 'low bitrate', 608 name: 'low bitrate',
626 fixture: 'low-bitrate.mp4' 609 fixture: 'low-bitrate.mp4'
627 } 610 }
628 611
629 const resUpload = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 612 const { uuid } = await servers[1].videosCommand.upload({ attributes })
630 const videoUUID = resUpload.body.video.uuid
631 613
632 await waitJobs(servers) 614 await waitJobs(servers)
633 615
634 const resolutions = [ 240, 360, 480, 720, 1080 ] 616 const resolutions = [ 240, 360, 480, 720, 1080 ]
635 for (const r of resolutions) { 617 for (const r of resolutions) {
636 const path = `videos/${videoUUID}-${r}.mp4` 618 const path = `videos/${uuid}-${r}.mp4`
637 const size = await servers[1].serversCommand.getServerFileSize(path) 619 const size = await servers[1].serversCommand.getServerFileSize(path)
638 expect(size, `${path} not below ${60_000}`).to.be.below(60_000) 620 expect(size, `${path} not below ${60_000}`).to.be.below(60_000)
639 } 621 }
@@ -645,7 +627,7 @@ describe('Test video transcoding', function () {
645 it('Should provide valid ffprobe data', async function () { 627 it('Should provide valid ffprobe data', async function () {
646 this.timeout(160_000) 628 this.timeout(160_000)
647 629
648 const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'ffprobe data' })).uuid 630 const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'ffprobe data' })).uuid
649 await waitJobs(servers) 631 await waitJobs(servers)
650 632
651 { 633 {
@@ -679,8 +661,7 @@ describe('Test video transcoding', function () {
679 } 661 }
680 662
681 for (const server of servers) { 663 for (const server of servers) {
682 const res2 = await getVideo(server.url, videoUUID) 664 const videoDetails = await server.videosCommand.get({ id: videoUUID })
683 const videoDetails: VideoDetails = res2.body
684 665
685 const videoFiles = videoDetails.files 666 const videoFiles = videoDetails.files
686 .concat(videoDetails.streamingPlaylists[0].files) 667 .concat(videoDetails.streamingPlaylists[0].files)
@@ -692,8 +673,7 @@ describe('Test video transcoding', function () {
692 expect(file.metadataUrl).to.contain(servers[1].url) 673 expect(file.metadataUrl).to.contain(servers[1].url)
693 expect(file.metadataUrl).to.contain(videoUUID) 674 expect(file.metadataUrl).to.contain(videoUUID)
694 675
695 const res3 = await getVideoFileMetadataUrl(file.metadataUrl) 676 const metadata = await server.videosCommand.getFileMetadata({ url: file.metadataUrl })
696 const metadata: FfprobeData = res3.body
697 expect(metadata).to.have.nested.property('format.size') 677 expect(metadata).to.have.nested.property('format.size')
698 } 678 }
699 } 679 }
diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts
index 4aa00cfc4..4a5a83ee6 100644
--- a/server/tests/api/videos/videos-filter.ts
+++ b/server/tests/api/videos/videos-filter.ts
@@ -1,21 +1,17 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 doubleFollow, 8 doubleFollow,
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 makeGetRequest, 10 makeGetRequest,
11 ServerInfo, 11 ServerInfo,
12 setAccessTokensToServers, 12 setAccessTokensToServers
13 uploadVideo 13} from '@shared/extra-utils'
14} from '../../../../shared/extra-utils' 14import { UserRole, Video, VideoPrivacy } from '@shared/models'
15import { UserRole } from '../../../../shared/models/users'
16import { Video, VideoPrivacy } from '../../../../shared/models/videos'
17
18const expect = chai.expect
19 15
20async function getVideosNames (server: ServerInfo, token: string, filter: string, statusCodeExpected = HttpStatusCode.OK_200) { 16async function getVideosNames (server: ServerInfo, token: string, filter: string, statusCodeExpected = HttpStatusCode.OK_200) {
21 const paths = [ 17 const paths = [
@@ -62,16 +58,16 @@ describe('Test videos filter', function () {
62 await server.usersCommand.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR }) 58 await server.usersCommand.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR })
63 server['moderatorAccessToken'] = await server.loginCommand.getAccessToken(moderator) 59 server['moderatorAccessToken'] = await server.loginCommand.getAccessToken(moderator)
64 60
65 await uploadVideo(server.url, server.accessToken, { name: 'public ' + server.serverNumber }) 61 await server.videosCommand.upload({ attributes: { name: 'public ' + server.serverNumber } })
66 62
67 { 63 {
68 const attributes = { name: 'unlisted ' + server.serverNumber, privacy: VideoPrivacy.UNLISTED } 64 const attributes = { name: 'unlisted ' + server.serverNumber, privacy: VideoPrivacy.UNLISTED }
69 await uploadVideo(server.url, server.accessToken, attributes) 65 await server.videosCommand.upload({ attributes })
70 } 66 }
71 67
72 { 68 {
73 const attributes = { name: 'private ' + server.serverNumber, privacy: VideoPrivacy.PRIVATE } 69 const attributes = { name: 'private ' + server.serverNumber, privacy: VideoPrivacy.PRIVATE }
74 await uploadVideo(server.url, server.accessToken, attributes) 70 await server.videosCommand.upload({ attributes })
75 } 71 }
76 } 72 }
77 73
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts
index aa0623f7d..8614078f1 100644
--- a/server/tests/api/videos/videos-history.ts
+++ b/server/tests/api/videos/videos-history.ts
@@ -6,17 +6,14 @@ import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 flushAndRunServer, 8 flushAndRunServer,
9 getVideosListWithToken,
10 getVideoWithToken,
11 HistoryCommand, 9 HistoryCommand,
12 killallServers, 10 killallServers,
13 reRunServer, 11 reRunServer,
14 ServerInfo, 12 ServerInfo,
15 setAccessTokensToServers, 13 setAccessTokensToServers,
16 uploadVideo,
17 wait 14 wait
18} from '@shared/extra-utils' 15} from '@shared/extra-utils'
19import { Video, VideoDetails } from '@shared/models' 16import { Video } from '@shared/models'
20 17
21const expect = chai.expect 18const expect = chai.expect
22 19
@@ -39,18 +36,18 @@ describe('Test videos history', function () {
39 command = server.historyCommand 36 command = server.historyCommand
40 37
41 { 38 {
42 const res = await uploadVideo(server.url, server.accessToken, { name: 'video 1' }) 39 const { uuid } = await server.videosCommand.upload({ attributes: { name: 'video 1' } })
43 video1UUID = res.body.video.uuid 40 video1UUID = uuid
44 } 41 }
45 42
46 { 43 {
47 const res = await uploadVideo(server.url, server.accessToken, { name: 'video 2' }) 44 const { uuid } = await server.videosCommand.upload({ attributes: { name: 'video 2' } })
48 video2UUID = res.body.video.uuid 45 video2UUID = uuid
49 } 46 }
50 47
51 { 48 {
52 const res = await uploadVideo(server.url, server.accessToken, { name: 'video 3' }) 49 const { uuid } = await server.videosCommand.upload({ attributes: { name: 'video 3' } })
53 video3UUID = res.body.video.uuid 50 video3UUID = uuid
54 } 51 }
55 52
56 const user = { 53 const user = {
@@ -62,12 +59,10 @@ describe('Test videos history', function () {
62 }) 59 })
63 60
64 it('Should get videos, without watching history', async function () { 61 it('Should get videos, without watching history', async function () {
65 const res = await getVideosListWithToken(server.url, server.accessToken) 62 const { data } = await server.videosCommand.listWithToken()
66 const videos: Video[] = res.body.data
67 63
68 for (const video of videos) { 64 for (const video of data) {
69 const resDetail = await getVideoWithToken(server.url, server.accessToken, video.id) 65 const videoDetails = await server.videosCommand.getWithToken({ id: video.id })
70 const videoDetails: VideoDetails = resDetail.body
71 66
72 expect(video.userHistory).to.be.undefined 67 expect(video.userHistory).to.be.undefined
73 expect(videoDetails.userHistory).to.be.undefined 68 expect(videoDetails.userHistory).to.be.undefined
@@ -83,8 +78,8 @@ describe('Test videos history', function () {
83 const videosOfVideos: Video[][] = [] 78 const videosOfVideos: Video[][] = []
84 79
85 { 80 {
86 const res = await getVideosListWithToken(server.url, server.accessToken) 81 const { data } = await server.videosCommand.listWithToken()
87 videosOfVideos.push(res.body.data) 82 videosOfVideos.push(data)
88 } 83 }
89 84
90 { 85 {
@@ -107,24 +102,21 @@ describe('Test videos history', function () {
107 } 102 }
108 103
109 { 104 {
110 const resDetail = await getVideoWithToken(server.url, server.accessToken, video1UUID) 105 const videoDetails = await server.videosCommand.getWithToken({ id: video1UUID })
111 const videoDetails: VideoDetails = resDetail.body
112 106
113 expect(videoDetails.userHistory).to.not.be.undefined 107 expect(videoDetails.userHistory).to.not.be.undefined
114 expect(videoDetails.userHistory.currentTime).to.equal(3) 108 expect(videoDetails.userHistory.currentTime).to.equal(3)
115 } 109 }
116 110
117 { 111 {
118 const resDetail = await getVideoWithToken(server.url, server.accessToken, video2UUID) 112 const videoDetails = await server.videosCommand.getWithToken({ id: video2UUID })
119 const videoDetails: VideoDetails = resDetail.body
120 113
121 expect(videoDetails.userHistory).to.not.be.undefined 114 expect(videoDetails.userHistory).to.not.be.undefined
122 expect(videoDetails.userHistory.currentTime).to.equal(8) 115 expect(videoDetails.userHistory.currentTime).to.equal(8)
123 } 116 }
124 117
125 { 118 {
126 const resDetail = await getVideoWithToken(server.url, server.accessToken, video3UUID) 119 const videoDetails = await server.videosCommand.getWithToken({ id: video3UUID })
127 const videoDetails: VideoDetails = resDetail.body
128 120
129 expect(videoDetails.userHistory).to.be.undefined 121 expect(videoDetails.userHistory).to.be.undefined
130 } 122 }
diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts
index a2da2eaef..969393842 100644
--- a/server/tests/api/videos/videos-overview.ts
+++ b/server/tests/api/videos/videos-overview.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo, wait } from '@shared/extra-utils' 5import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers, wait } from '@shared/extra-utils'
6import { VideosOverview } from '@shared/models' 6import { VideosOverview } from '@shared/models'
7 7
8const expect = chai.expect 8const expect = chai.expect
@@ -35,10 +35,12 @@ describe('Test a videos overview', function () {
35 35
36 await wait(3000) 36 await wait(3000)
37 37
38 await uploadVideo(server.url, server.accessToken, { 38 await server.videosCommand.upload({
39 name: 'video 0', 39 attributes: {
40 category: 3, 40 name: 'video 0',
41 tags: [ 'coucou1', 'coucou2' ] 41 category: 3,
42 tags: [ 'coucou1', 'coucou2' ]
43 }
42 }) 44 })
43 45
44 const body = await server.overviewsCommand.getVideos({ page: 1 }) 46 const body = await server.overviewsCommand.getVideos({ page: 1 })
@@ -51,10 +53,12 @@ describe('Test a videos overview', function () {
51 53
52 { 54 {
53 for (let i = 1; i < 6; i++) { 55 for (let i = 1; i < 6; i++) {
54 await uploadVideo(server.url, server.accessToken, { 56 await server.videosCommand.upload({
55 name: 'video ' + i, 57 attributes: {
56 category: 3, 58 name: 'video ' + i,
57 tags: [ 'coucou1', 'coucou2' ] 59 category: 3,
60 tags: [ 'coucou1', 'coucou2' ]
61 }
58 }) 62 })
59 } 63 }
60 64
diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts
index b6cde6b50..7ded1bf38 100644
--- a/server/tests/api/videos/videos-views-cleaner.ts
+++ b/server/tests/api/videos/videos-views-cleaner.ts
@@ -10,8 +10,6 @@ import {
10 reRunServer, 10 reRunServer,
11 ServerInfo, 11 ServerInfo,
12 setAccessTokensToServers, 12 setAccessTokensToServers,
13 uploadVideoAndGetId,
14 viewVideo,
15 wait, 13 wait,
16 waitJobs 14 waitJobs
17} from '../../../../shared/extra-utils' 15} from '../../../../shared/extra-utils'
@@ -32,15 +30,15 @@ describe('Test video views cleaner', function () {
32 30
33 await doubleFollow(servers[0], servers[1]) 31 await doubleFollow(servers[0], servers[1])
34 32
35 videoIdServer1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' })).uuid 33 videoIdServer1 = (await servers[0].videosCommand.quickUpload({ name: 'video server 1' })).uuid
36 videoIdServer2 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video server 2' })).uuid 34 videoIdServer2 = (await servers[1].videosCommand.quickUpload({ name: 'video server 2' })).uuid
37 35
38 await waitJobs(servers) 36 await waitJobs(servers)
39 37
40 await viewVideo(servers[0].url, videoIdServer1) 38 await servers[0].videosCommand.view({ id: videoIdServer1 })
41 await viewVideo(servers[1].url, videoIdServer1) 39 await servers[1].videosCommand.view({ id: videoIdServer1 })
42 await viewVideo(servers[0].url, videoIdServer2) 40 await servers[0].videosCommand.view({ id: videoIdServer2 })
43 await viewVideo(servers[1].url, videoIdServer2) 41 await servers[1].videosCommand.view({ id: videoIdServer2 })
44 42
45 await waitJobs(servers) 43 await waitJobs(servers)
46 }) 44 })