1 /* tslint:disable:no-unused-expression */
3 import * as chai from 'chai'
5 import { User } from '../../../../shared/index'
6 import { doubleFollow, flushAndRunMultipleServers, uploadVideo, wait } from '../../utils'
11 getAccountVideoChannelsList,
17 setAccessTokensToServers,
19 } from '../../utils/index'
20 import { getAccountsList } from '../../utils/users/accounts'
22 const expect = chai.expect
24 describe('Test video channels', function () {
25 let servers: ServerInfo[]
28 let videoChannelId: number
30 before(async function () {
35 servers = await flushAndRunMultipleServers(2)
37 await setAccessTokensToServers(servers)
38 await doubleFollow(servers[0], servers[1])
41 const res = await getAccountsList(servers[0].url)
42 accountId = res.body.data[0].id
48 it('Should have one video channel (created with root)', async () => {
49 const res = await getVideoChannelsList(servers[0].url, 0, 2)
51 expect(res.body.total).to.equal(1)
52 expect(res.body.data).to.be.an('array')
53 expect(res.body.data).to.have.lengthOf(1)
56 it('Should create another video channel', async function () {
59 const videoChannel = {
60 name: 'second video channel',
61 description: 'super video channel description',
62 support: 'super video channel support text'
64 const res = await addVideoChannel(servers[0].url, servers[0].accessToken, accountId, videoChannel)
65 videoChannelId = res.body.videoChannel.id
67 // The channel is 1 is propagated to servers 2
68 await uploadVideo(servers[0].url, servers[0].accessToken, { channelId: videoChannelId })
73 it('Should have two video channels when getting my information', async () => {
74 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
77 expect(userInfo.videoChannels).to.be.an('array')
78 expect(userInfo.videoChannels).to.have.lengthOf(2)
80 const videoChannels = userInfo.videoChannels
81 expect(videoChannels[0].displayName).to.equal('Default root channel')
82 expect(videoChannels[1].displayName).to.equal('second video channel')
83 expect(videoChannels[1].description).to.equal('super video channel description')
84 expect(videoChannels[1].support).to.equal('super video channel support text')
87 it('Should have two video channels when getting account channels on server 1', async function () {
88 const res = await getAccountVideoChannelsList(servers[0].url, userInfo.account.uuid)
89 expect(res.body.total).to.equal(2)
90 expect(res.body.data).to.be.an('array')
91 expect(res.body.data).to.have.lengthOf(2)
93 const videoChannels = res.body.data
94 expect(videoChannels[0].displayName).to.equal('Default root channel')
95 expect(videoChannels[1].displayName).to.equal('second video channel')
96 expect(videoChannels[1].description).to.equal('super video channel description')
97 expect(videoChannels[1].support).to.equal('super video channel support text')
100 it('Should have one video channel when getting account channels on server 2', async function () {
101 const res = await getAccountVideoChannelsList(servers[1].url, userInfo.account.uuid)
102 expect(res.body.total).to.equal(1)
103 expect(res.body.data).to.be.an('array')
104 expect(res.body.data).to.have.lengthOf(1)
106 const videoChannels = res.body.data
107 expect(videoChannels[0].displayName).to.equal('second video channel')
108 expect(videoChannels[0].description).to.equal('super video channel description')
109 expect(videoChannels[0].support).to.equal('super video channel support text')
112 it('Should list video channels', async function () {
113 const res = await getVideoChannelsList(servers[0].url, 1, 1, '-name')
115 expect(res.body.total).to.equal(2)
116 expect(res.body.data).to.be.an('array')
117 expect(res.body.data).to.have.lengthOf(1)
118 expect(res.body.data[0].displayName).to.equal('Default root channel')
121 it('Should update video channel', async function () {
124 const videoChannelAttributes = {
125 name: 'video channel updated',
126 description: 'video channel description updated',
127 support: 'video channel support text updated'
130 await updateVideoChannel(servers[0].url, servers[0].accessToken, accountId, videoChannelId, videoChannelAttributes)
135 it('Should have video channel updated', async function () {
136 for (const server of servers) {
137 const res = await getVideoChannelsList(server.url, 0, 1, '-name')
139 expect(res.body.total).to.equal(2)
140 expect(res.body.data).to.be.an('array')
141 expect(res.body.data).to.have.lengthOf(1)
142 expect(res.body.data[0].displayName).to.equal('video channel updated')
143 expect(res.body.data[0].description).to.equal('video channel description updated')
144 expect(res.body.data[0].support).to.equal('video channel support text updated')
148 it('Should get video channel', async function () {
149 const res = await getVideoChannel(servers[0].url, accountId, videoChannelId)
151 const videoChannel = res.body
152 expect(videoChannel.displayName).to.equal('video channel updated')
153 expect(videoChannel.description).to.equal('video channel description updated')
154 expect(videoChannel.support).to.equal('video channel support text updated')
157 it('Should delete video channel', async function () {
158 await deleteVideoChannel(servers[0].url, servers[0].accessToken, accountId, videoChannelId)
161 it('Should have video channel deleted', async function () {
162 const res = await getVideoChannelsList(servers[0].url, 0, 10)
164 expect(res.body.total).to.equal(1)
165 expect(res.body.data).to.be.an('array')
166 expect(res.body.data).to.have.lengthOf(1)
167 expect(res.body.data[0].displayName).to.equal('Default root channel')
170 after(async function () {
171 killallServers(servers)
173 // Keep the logs if the test failed