1 /* tslint:disable:no-unused-expression */
3 import * as chai from 'chai'
5 import { User } from '../../../../shared/index'
6 import { doubleFollow, flushAndRunMultipleServers, getVideoChannelVideos, 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[]
27 let accountUUID: string
28 let videoChannelId: number
29 let videoChannelUUID: string
31 before(async function () {
36 servers = await flushAndRunMultipleServers(2)
38 await setAccessTokensToServers(servers)
39 await doubleFollow(servers[0], servers[1])
42 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
43 const user: User = res.body
44 accountUUID = user.account.uuid
50 it('Should have one video channel (created with root)', async () => {
51 const res = await getVideoChannelsList(servers[0].url, 0, 2)
53 expect(res.body.total).to.equal(1)
54 expect(res.body.data).to.be.an('array')
55 expect(res.body.data).to.have.lengthOf(1)
58 it('Should create another video channel', async function () {
61 const videoChannel = {
62 name: 'second video channel',
63 description: 'super video channel description',
64 support: 'super video channel support text'
66 const res = await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel)
67 videoChannelId = res.body.videoChannel.id
68 videoChannelUUID = res.body.videoChannel.uuid
70 // The channel is 1 is propagated to servers 2
71 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'my video name', channelId: videoChannelId })
76 it('Should have two video channels when getting my information', async () => {
77 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
80 expect(userInfo.videoChannels).to.be.an('array')
81 expect(userInfo.videoChannels).to.have.lengthOf(2)
83 const videoChannels = userInfo.videoChannels
84 expect(videoChannels[0].displayName).to.equal('Default root channel')
85 expect(videoChannels[1].displayName).to.equal('second video channel')
86 expect(videoChannels[1].description).to.equal('super video channel description')
87 expect(videoChannels[1].support).to.equal('super video channel support text')
90 it('Should have two video channels when getting account channels on server 1', async function () {
91 const res = await getAccountVideoChannelsList(servers[0].url, userInfo.account.uuid)
92 expect(res.body.total).to.equal(2)
93 expect(res.body.data).to.be.an('array')
94 expect(res.body.data).to.have.lengthOf(2)
96 const videoChannels = res.body.data
97 expect(videoChannels[0].displayName).to.equal('Default root channel')
98 expect(videoChannels[1].displayName).to.equal('second video channel')
99 expect(videoChannels[1].description).to.equal('super video channel description')
100 expect(videoChannels[1].support).to.equal('super video channel support text')
103 it('Should have one video channel when getting account channels on server 2', async function () {
104 const res = await getAccountVideoChannelsList(servers[1].url, userInfo.account.uuid)
105 expect(res.body.total).to.equal(1)
106 expect(res.body.data).to.be.an('array')
107 expect(res.body.data).to.have.lengthOf(1)
109 const videoChannels = res.body.data
110 expect(videoChannels[0].displayName).to.equal('second video channel')
111 expect(videoChannels[0].description).to.equal('super video channel description')
112 expect(videoChannels[0].support).to.equal('super video channel support text')
115 it('Should list video channels', async function () {
116 const res = await getVideoChannelsList(servers[0].url, 1, 1, '-name')
118 expect(res.body.total).to.equal(2)
119 expect(res.body.data).to.be.an('array')
120 expect(res.body.data).to.have.lengthOf(1)
121 expect(res.body.data[0].displayName).to.equal('Default root channel')
124 it('Should update video channel', async function () {
127 const videoChannelAttributes = {
128 name: 'video channel updated',
129 description: 'video channel description updated',
130 support: 'video channel support text updated'
133 await updateVideoChannel(servers[0].url, servers[0].accessToken, videoChannelId, videoChannelAttributes)
138 it('Should have video channel updated', async function () {
139 for (const server of servers) {
140 const res = await getVideoChannelsList(server.url, 0, 1, '-name')
142 expect(res.body.total).to.equal(2)
143 expect(res.body.data).to.be.an('array')
144 expect(res.body.data).to.have.lengthOf(1)
145 expect(res.body.data[0].displayName).to.equal('video channel updated')
146 expect(res.body.data[0].description).to.equal('video channel description updated')
147 expect(res.body.data[0].support).to.equal('video channel support text updated')
151 it('Should get video channel', async function () {
152 const res = await getVideoChannel(servers[0].url, videoChannelId)
154 const videoChannel = res.body
155 expect(videoChannel.displayName).to.equal('video channel updated')
156 expect(videoChannel.description).to.equal('video channel description updated')
157 expect(videoChannel.support).to.equal('video channel support text updated')
160 it('Should list the video channel videos', async function () {
163 for (const server of servers) {
164 const res = await getVideoChannelVideos(server.url, server.accessToken, videoChannelUUID, 0, 5)
165 expect(res.body.total).to.equal(1)
166 expect(res.body.data).to.be.an('array')
167 expect(res.body.data).to.have.lengthOf(1)
168 expect(res.body.data[0].name).to.equal('my video name')
172 it('Should delete video channel', async function () {
173 await deleteVideoChannel(servers[0].url, servers[0].accessToken, videoChannelId)
176 it('Should have video channel deleted', async function () {
177 const res = await getVideoChannelsList(servers[0].url, 0, 10)
179 expect(res.body.total).to.equal(1)
180 expect(res.body.data).to.be.an('array')
181 expect(res.body.data).to.have.lengthOf(1)
182 expect(res.body.data[0].displayName).to.equal('Default root channel')
185 after(async function () {
186 killallServers(servers)
188 // Keep the logs if the test failed