aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-channels.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/video-channels.ts')
-rw-r--r--server/tests/api/videos/video-channels.ts69
1 files changed, 32 insertions, 37 deletions
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) {