1 /* tslint:disable:no-unused-expression */
4 import * as chai from 'chai'
5 const expect = chai.expect
11 setAccessTokensToServers,
16 getAccountVideoChannelsList,
21 import { User } from '../../../shared'
23 describe('Test a video channels', function () {
24 let server: ServerInfo
26 let videoChannelId: number
28 before(async function () {
33 server = await runServer(1)
35 await setAccessTokensToServers([ server ])
38 it('Should have one video channel (created with root)', async () => {
39 const res = await getVideoChannelsList(server.url, 0, 2)
41 expect(res.body.total).to.equal(1)
42 expect(res.body.data).to.be.an('array')
43 expect(res.body.data).to.have.lengthOf(1)
46 it('Should create another video channel', async () => {
47 const videoChannel = {
48 name: 'second video channel',
49 description: 'super video channel description'
51 await addVideoChannel(server.url, server.accessToken, videoChannel)
54 it('Should have two video channels when getting my information', async () => {
55 const res = await getMyUserInformation(server.url, server.accessToken)
58 expect(userInfo.videoChannels).to.be.an('array')
59 expect(userInfo.videoChannels).to.have.lengthOf(2)
61 const videoChannels = userInfo.videoChannels
62 expect(videoChannels[0].name).to.equal('Default root channel')
63 expect(videoChannels[1].name).to.equal('second video channel')
64 expect(videoChannels[1].description).to.equal('super video channel description')
67 it('Should have two video channels when getting account channels', async () => {
68 const res = await getAccountVideoChannelsList(server.url, userInfo.account.uuid)
70 expect(res.body.total).to.equal(2)
71 expect(res.body.data).to.be.an('array')
72 expect(res.body.data).to.have.lengthOf(2)
74 const videoChannels = res.body.data
75 expect(videoChannels[0].name).to.equal('Default root channel')
76 expect(videoChannels[1].name).to.equal('second video channel')
77 expect(videoChannels[1].description).to.equal('super video channel description')
79 videoChannelId = videoChannels[1].id
82 it('Should list video channels', async () => {
83 const res = await getVideoChannelsList(server.url, 1, 1, '-name')
85 expect(res.body.total).to.equal(2)
86 expect(res.body.data).to.be.an('array')
87 expect(res.body.data).to.have.lengthOf(1)
88 expect(res.body.data[0].name).to.equal('Default root channel')
91 it('Should update video channel', async () => {
92 const videoChannelAttributes = {
93 name: 'video channel updated',
94 description: 'video channel description updated'
97 await updateVideoChannel(server.url, server.accessToken, videoChannelId, videoChannelAttributes)
100 it('Should have video channel updated', async () => {
101 const res = await getVideoChannelsList(server.url, 0, 1, '-name')
103 expect(res.body.total).to.equal(2)
104 expect(res.body.data).to.be.an('array')
105 expect(res.body.data).to.have.lengthOf(1)
106 expect(res.body.data[0].name).to.equal('video channel updated')
107 expect(res.body.data[0].description).to.equal('video channel description updated')
110 it('Should get video channel', async () => {
111 const res = await getVideoChannel(server.url, videoChannelId)
113 const videoChannel = res.body
114 expect(videoChannel.name).to.equal('video channel updated')
115 expect(videoChannel.description).to.equal('video channel description updated')
118 it('Should delete video channel', async () => {
119 await deleteVideoChannel(server.url, server.accessToken, videoChannelId)
122 it('Should have video channel deleted', async () => {
123 const res = await getVideoChannelsList(server.url, 0, 10)
125 expect(res.body.total).to.equal(1)
126 expect(res.body.data).to.be.an('array')
127 expect(res.body.data).to.have.lengthOf(1)
128 expect(res.body.data[0].name).to.equal('Default root channel')
131 after(async function () {
132 killallServers([ server ])
134 // Keep the logs if the test failed