aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/videos/video-channels.ts82
1 files changed, 57 insertions, 25 deletions
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index d12d58e75..7e7ad028c 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -3,6 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { basename } from 'path' 5import { basename } from 'path'
6import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants'
6import { 7import {
7 cleanupTests, 8 cleanupTests,
8 createUser, 9 createUser,
@@ -13,6 +14,7 @@ import {
13 getVideo, 14 getVideo,
14 getVideoChannel, 15 getVideoChannel,
15 getVideoChannelVideos, 16 getVideoChannelVideos,
17 setDefaultVideoChannel,
16 testImage, 18 testImage,
17 updateVideo, 19 updateVideo,
18 updateVideoChannelImage, 20 updateVideoChannelImage,
@@ -33,7 +35,6 @@ import {
33} from '../../../../shared/extra-utils/index' 35} from '../../../../shared/extra-utils/index'
34import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 36import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
35import { User, Video, VideoChannel, VideoDetails } from '../../../../shared/index' 37import { User, Video, VideoChannel, VideoDetails } from '../../../../shared/index'
36import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants'
37 38
38const expect = chai.expect 39const expect = chai.expect
39 40
@@ -47,9 +48,10 @@ async function findChannel (server: ServerInfo, channelId: number) {
47describe('Test video channels', function () { 48describe('Test video channels', function () {
48 let servers: ServerInfo[] 49 let servers: ServerInfo[]
49 let userInfo: User 50 let userInfo: User
50 let firstVideoChannelId: number
51 let secondVideoChannelId: number 51 let secondVideoChannelId: number
52 let totoChannel: number
52 let videoUUID: string 53 let videoUUID: string
54 let accountName: string
53 55
54 before(async function () { 56 before(async function () {
55 this.timeout(60000) 57 this.timeout(60000)
@@ -57,16 +59,9 @@ describe('Test video channels', function () {
57 servers = await flushAndRunMultipleServers(2) 59 servers = await flushAndRunMultipleServers(2)
58 60
59 await setAccessTokensToServers(servers) 61 await setAccessTokensToServers(servers)
60 await doubleFollow(servers[0], servers[1]) 62 await setDefaultVideoChannel(servers)
61
62 {
63 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
64 const user: User = res.body
65
66 firstVideoChannelId = user.videoChannels[0].id
67 }
68 63
69 await waitJobs(servers) 64 await doubleFollow(servers[0], servers[1])
70 }) 65 })
71 66
72 it('Should have one video channel (created with root)', async () => { 67 it('Should have one video channel (created with root)', async () => {
@@ -116,12 +111,14 @@ describe('Test video channels', function () {
116 expect(videoChannels[1].displayName).to.equal('second video channel') 111 expect(videoChannels[1].displayName).to.equal('second video channel')
117 expect(videoChannels[1].description).to.equal('super video channel description') 112 expect(videoChannels[1].description).to.equal('super video channel description')
118 expect(videoChannels[1].support).to.equal('super video channel support text') 113 expect(videoChannels[1].support).to.equal('super video channel support text')
114
115 accountName = userInfo.account.name + '@' + userInfo.account.host
119 }) 116 })
120 117
121 it('Should have two video channels when getting account channels on server 1', async function () { 118 it('Should have two video channels when getting account channels on server 1', async function () {
122 const res = await getAccountVideoChannelsList({ 119 const res = await getAccountVideoChannelsList({
123 url: servers[0].url, 120 url: servers[0].url,
124 accountName: userInfo.account.name + '@' + userInfo.account.host 121 accountName
125 }) 122 })
126 123
127 expect(res.body.total).to.equal(2) 124 expect(res.body.total).to.equal(2)
@@ -142,7 +139,7 @@ describe('Test video channels', function () {
142 { 139 {
143 const res = await getAccountVideoChannelsList({ 140 const res = await getAccountVideoChannelsList({
144 url: servers[0].url, 141 url: servers[0].url,
145 accountName: userInfo.account.name + '@' + userInfo.account.host, 142 accountName,
146 start: 0, 143 start: 0,
147 count: 1, 144 count: 1,
148 sort: 'createdAt' 145 sort: 'createdAt'
@@ -158,7 +155,7 @@ describe('Test video channels', function () {
158 { 155 {
159 const res = await getAccountVideoChannelsList({ 156 const res = await getAccountVideoChannelsList({
160 url: servers[0].url, 157 url: servers[0].url,
161 accountName: userInfo.account.name + '@' + userInfo.account.host, 158 accountName,
162 start: 0, 159 start: 0,
163 count: 1, 160 count: 1,
164 sort: '-createdAt' 161 sort: '-createdAt'
@@ -174,7 +171,7 @@ describe('Test video channels', function () {
174 { 171 {
175 const res = await getAccountVideoChannelsList({ 172 const res = await getAccountVideoChannelsList({
176 url: servers[0].url, 173 url: servers[0].url,
177 accountName: userInfo.account.name + '@' + userInfo.account.host, 174 accountName,
178 start: 1, 175 start: 1,
179 count: 1, 176 count: 1,
180 sort: '-createdAt' 177 sort: '-createdAt'
@@ -191,7 +188,7 @@ describe('Test video channels', function () {
191 it('Should have one video channel when getting account channels on server 2', async function () { 188 it('Should have one video channel when getting account channels on server 2', async function () {
192 const res = await getAccountVideoChannelsList({ 189 const res = await getAccountVideoChannelsList({
193 url: servers[1].url, 190 url: servers[1].url,
194 accountName: userInfo.account.name + '@' + userInfo.account.host 191 accountName
195 }) 192 })
196 193
197 expect(res.body.total).to.equal(1) 194 expect(res.body.total).to.equal(1)
@@ -379,7 +376,7 @@ describe('Test video channels', function () {
379 it('Should change the video channel of a video', async function () { 376 it('Should change the video channel of a video', async function () {
380 this.timeout(10000) 377 this.timeout(10000)
381 378
382 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { channelId: firstVideoChannelId }) 379 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { channelId: servers[0].videoChannel.id })
383 380
384 await waitJobs(servers) 381 await waitJobs(servers)
385 }) 382 })
@@ -419,7 +416,8 @@ describe('Test video channels', function () {
419 it('Should create the main channel with an uuid if there is a conflict', async function () { 416 it('Should create the main channel with an uuid if there is a conflict', async function () {
420 { 417 {
421 const videoChannel = { name: 'toto_channel', displayName: 'My toto channel' } 418 const videoChannel = { name: 'toto_channel', displayName: 'My toto channel' }
422 await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel) 419 const res = await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel)
420 totoChannel = res.body.videoChannel.id
423 } 421 }
424 422
425 { 423 {
@@ -438,7 +436,7 @@ describe('Test video channels', function () {
438 { 436 {
439 const res = await getAccountVideoChannelsList({ 437 const res = await getAccountVideoChannelsList({
440 url: servers[0].url, 438 url: servers[0].url,
441 accountName: userInfo.account.name + '@' + userInfo.account.host, 439 accountName,
442 withStats: true 440 withStats: true
443 }) 441 })
444 442
@@ -456,7 +454,7 @@ describe('Test video channels', function () {
456 } 454 }
457 455
458 { 456 {
459 // video has been posted on channel firstVideoChannelId since last update 457 // video has been posted on channel servers[0].videoChannel.id since last update
460 await viewVideo(servers[0].url, videoUUID, 204, '0.0.0.1,127.0.0.1') 458 await viewVideo(servers[0].url, videoUUID, 204, '0.0.0.1,127.0.0.1')
461 await viewVideo(servers[0].url, videoUUID, 204, '0.0.0.2,127.0.0.1') 459 await viewVideo(servers[0].url, videoUUID, 204, '0.0.0.2,127.0.0.1')
462 460
@@ -465,10 +463,10 @@ describe('Test video channels', function () {
465 463
466 const res = await getAccountVideoChannelsList({ 464 const res = await getAccountVideoChannelsList({
467 url: servers[0].url, 465 url: servers[0].url,
468 accountName: userInfo.account.name + '@' + userInfo.account.host, 466 accountName,
469 withStats: true 467 withStats: true
470 }) 468 })
471 const channelWithView = res.body.data.find((channel: VideoChannel) => channel.id === firstVideoChannelId) 469 const channelWithView = res.body.data.find((channel: VideoChannel) => channel.id === servers[0].videoChannel.id)
472 expect(channelWithView.viewsPerDay.slice(-1)[0].views).to.equal(2) 470 expect(channelWithView.viewsPerDay.slice(-1)[0].views).to.equal(2)
473 } 471 }
474 }) 472 })
@@ -476,7 +474,7 @@ describe('Test video channels', function () {
476 it('Should report correct videos count', async function () { 474 it('Should report correct videos count', async function () {
477 const res = await getAccountVideoChannelsList({ 475 const res = await getAccountVideoChannelsList({
478 url: servers[0].url, 476 url: servers[0].url,
479 accountName: userInfo.account.name + '@' + userInfo.account.host, 477 accountName,
480 withStats: true 478 withStats: true
481 }) 479 })
482 const channels: VideoChannel[] = res.body.data 480 const channels: VideoChannel[] = res.body.data
@@ -492,7 +490,7 @@ describe('Test video channels', function () {
492 { 490 {
493 const res = await getAccountVideoChannelsList({ 491 const res = await getAccountVideoChannelsList({
494 url: servers[0].url, 492 url: servers[0].url,
495 accountName: userInfo.account.name + '@' + userInfo.account.host, 493 accountName,
496 search: 'root' 494 search: 'root'
497 }) 495 })
498 expect(res.body.total).to.equal(1) 496 expect(res.body.total).to.equal(1)
@@ -504,7 +502,7 @@ describe('Test video channels', function () {
504 { 502 {
505 const res = await getAccountVideoChannelsList({ 503 const res = await getAccountVideoChannelsList({
506 url: servers[0].url, 504 url: servers[0].url,
507 accountName: userInfo.account.name + '@' + userInfo.account.host, 505 accountName,
508 search: 'does not exist' 506 search: 'does not exist'
509 }) 507 })
510 expect(res.body.total).to.equal(0) 508 expect(res.body.total).to.equal(0)
@@ -514,6 +512,40 @@ describe('Test video channels', function () {
514 } 512 }
515 }) 513 })
516 514
515 it('Should list channels by updatedAt desc if a video has been uploaded', async function () {
516 this.timeout(30000)
517
518 await uploadVideo(servers[0].url, servers[0].accessToken, { channelId: totoChannel })
519 await waitJobs(servers)
520
521 for (const server of servers) {
522 const res = await getAccountVideoChannelsList({
523 url: server.url,
524 accountName,
525 sort: '-updatedAt'
526 })
527
528 const channels: VideoChannel[] = res.body.data
529 expect(channels[0].name).to.equal('toto_channel')
530 expect(channels[1].name).to.equal('root_channel')
531 }
532
533 await uploadVideo(servers[0].url, servers[0].accessToken, { channelId: servers[0].videoChannel.id })
534 await waitJobs(servers)
535
536 for (const server of servers) {
537 const res = await getAccountVideoChannelsList({
538 url: server.url,
539 accountName,
540 sort: '-updatedAt'
541 })
542
543 const channels: VideoChannel[] = res.body.data
544 expect(channels[0].name).to.equal('root_channel')
545 expect(channels[1].name).to.equal('toto_channel')
546 }
547 })
548
517 after(async function () { 549 after(async function () {
518 await cleanupTests(servers) 550 await cleanupTests(servers)
519 }) 551 })