1 /* tslint:disable:no-unused-expression */
3 import { keyBy } from 'lodash'
4 import { join } from 'path'
6 import * as chai from 'chai'
7 const expect = chai.expect
13 setAccessTokensToServers,
18 getAuthorVideoChannelsList,
23 import { User } from '../../../shared'
25 describe('Test a video channels', function () {
26 let server: ServerInfo
28 let videoChannelId: number
30 before(async function () {
35 server = await runServer(1)
37 await setAccessTokensToServers([ server ])
40 it('Should have one video channel (created with root)', async () => {
41 const res = await getVideoChannelsList(server.url, 0, 2)
43 expect(res.body.total).to.equal(1)
44 expect(res.body.data).to.be.an('array')
45 expect(res.body.data).to.have.lengthOf(1)
48 it('Should create another video channel', async () => {
49 const videoChannel = {
50 name: 'second video channel',
51 description: 'super video channel description'
53 await addVideoChannel(server.url, server.accessToken, videoChannel)
56 it('Should have two video channels when getting my information', async () => {
57 const res = await getMyUserInformation(server.url, server.accessToken)
60 expect(userInfo.videoChannels).to.be.an('array')
61 expect(userInfo.videoChannels).to.have.lengthOf(2)
63 const videoChannels = userInfo.videoChannels
64 expect(videoChannels[0].name).to.equal('Default root channel')
65 expect(videoChannels[1].name).to.equal('second video channel')
66 expect(videoChannels[1].description).to.equal('super video channel description')
69 it('Should have two video channels when getting author channels', async () => {
70 const res = await getAuthorVideoChannelsList(server.url, userInfo.author.uuid)
72 expect(res.body.total).to.equal(2)
73 expect(res.body.data).to.be.an('array')
74 expect(res.body.data).to.have.lengthOf(2)
76 const videoChannels = res.body.data
77 expect(videoChannels[0].name).to.equal('Default root channel')
78 expect(videoChannels[1].name).to.equal('second video channel')
79 expect(videoChannels[1].description).to.equal('super video channel description')
81 videoChannelId = videoChannels[1].id
84 it('Should list video channels', async () => {
85 const res = await getVideoChannelsList(server.url, 1, 1, '-name')
87 expect(res.body.total).to.equal(2)
88 expect(res.body.data).to.be.an('array')
89 expect(res.body.data).to.have.lengthOf(1)
90 expect(res.body.data[0].name).to.equal('Default root channel')
93 it('Should update video channel', async () => {
94 const videoChannelAttributes = {
95 name: 'video channel updated',
96 description: 'video channel description updated'
99 await updateVideoChannel(server.url, server.accessToken, videoChannelId, videoChannelAttributes)
102 it('Should have video channel updated', async () => {
103 const res = await getVideoChannelsList(server.url, 0, 1, '-name')
105 expect(res.body.total).to.equal(2)
106 expect(res.body.data).to.be.an('array')
107 expect(res.body.data).to.have.lengthOf(1)
108 expect(res.body.data[0].name).to.equal('video channel updated')
109 expect(res.body.data[0].description).to.equal('video channel description updated')
112 it('Should get video channel', async () => {
113 const res = await getVideoChannel(server.url, videoChannelId)
115 const videoChannel = res.body
116 expect(videoChannel.name).to.equal('video channel updated')
117 expect(videoChannel.description).to.equal('video channel description updated')
120 it('Should delete video channel', async () => {
121 await deleteVideoChannel(server.url, server.accessToken, videoChannelId)
124 it('Should have video channel deleted', async () => {
125 const res = await getVideoChannelsList(server.url, 0, 10)
127 expect(res.body.total).to.equal(1)
128 expect(res.body.data).to.be.an('array')
129 expect(res.body.data).to.have.lengthOf(1)
130 expect(res.body.data[0].name).to.equal('Default root channel')
133 after(async function () {
134 killallServers([ server ])
136 // Keep the logs if the test failed