]>
Commit | Line | Data |
---|---|---|
1 | /* tslint:disable:no-unused-expression */ | |
2 | ||
3 | import * as chai from 'chai' | |
4 | import 'mocha' | |
5 | import { User } from '../../../../shared/index' | |
6 | import { doubleFollow, flushAndRunMultipleServers, uploadVideo, wait } from '../../utils' | |
7 | import { | |
8 | addVideoChannel, | |
9 | deleteVideoChannel, | |
10 | flushTests, | |
11 | getAccountVideoChannelsList, | |
12 | getMyUserInformation, | |
13 | getVideoChannel, | |
14 | getVideoChannelsList, | |
15 | killallServers, | |
16 | ServerInfo, | |
17 | setAccessTokensToServers, | |
18 | updateVideoChannel | |
19 | } from '../../utils/index' | |
20 | ||
21 | const expect = chai.expect | |
22 | ||
23 | describe('Test video channels', function () { | |
24 | let servers: ServerInfo[] | |
25 | let userInfo: User | |
26 | let videoChannelId: number | |
27 | ||
28 | before(async function () { | |
29 | this.timeout(30000) | |
30 | ||
31 | await flushTests() | |
32 | ||
33 | servers = await flushAndRunMultipleServers(2) | |
34 | ||
35 | await setAccessTokensToServers(servers) | |
36 | await doubleFollow(servers[0], servers[1]) | |
37 | ||
38 | await wait(5000) | |
39 | }) | |
40 | ||
41 | it('Should have one video channel (created with root)', async () => { | |
42 | const res = await getVideoChannelsList(servers[0].url, 0, 2) | |
43 | ||
44 | expect(res.body.total).to.equal(1) | |
45 | expect(res.body.data).to.be.an('array') | |
46 | expect(res.body.data).to.have.lengthOf(1) | |
47 | }) | |
48 | ||
49 | it('Should create another video channel', async function () { | |
50 | this.timeout(10000) | |
51 | ||
52 | const videoChannel = { | |
53 | name: 'second video channel', | |
54 | description: 'super video channel description', | |
55 | support: 'super video channel support text' | |
56 | } | |
57 | const res = await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel) | |
58 | videoChannelId = res.body.videoChannel.id | |
59 | ||
60 | // The channel is 1 is propagated to servers 2 | |
61 | await uploadVideo(servers[0].url, servers[0].accessToken, { channelId: videoChannelId }) | |
62 | ||
63 | await wait(3000) | |
64 | }) | |
65 | ||
66 | it('Should have two video channels when getting my information', async () => { | |
67 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) | |
68 | userInfo = res.body | |
69 | ||
70 | expect(userInfo.videoChannels).to.be.an('array') | |
71 | expect(userInfo.videoChannels).to.have.lengthOf(2) | |
72 | ||
73 | const videoChannels = userInfo.videoChannels | |
74 | expect(videoChannels[0].displayName).to.equal('Default root channel') | |
75 | expect(videoChannels[1].displayName).to.equal('second video channel') | |
76 | expect(videoChannels[1].description).to.equal('super video channel description') | |
77 | expect(videoChannels[1].support).to.equal('super video channel support text') | |
78 | }) | |
79 | ||
80 | it('Should have two video channels when getting account channels on server 1', async function () { | |
81 | const res = await getAccountVideoChannelsList(servers[0].url, userInfo.account.uuid) | |
82 | expect(res.body.total).to.equal(2) | |
83 | expect(res.body.data).to.be.an('array') | |
84 | expect(res.body.data).to.have.lengthOf(2) | |
85 | ||
86 | const videoChannels = res.body.data | |
87 | expect(videoChannels[0].displayName).to.equal('Default root channel') | |
88 | expect(videoChannels[1].displayName).to.equal('second video channel') | |
89 | expect(videoChannels[1].description).to.equal('super video channel description') | |
90 | expect(videoChannels[1].support).to.equal('super video channel support text') | |
91 | }) | |
92 | ||
93 | it('Should have one video channel when getting account channels on server 2', async function () { | |
94 | const res = await getAccountVideoChannelsList(servers[1].url, userInfo.account.uuid) | |
95 | expect(res.body.total).to.equal(1) | |
96 | expect(res.body.data).to.be.an('array') | |
97 | expect(res.body.data).to.have.lengthOf(1) | |
98 | ||
99 | const videoChannels = res.body.data | |
100 | expect(videoChannels[0].displayName).to.equal('second video channel') | |
101 | expect(videoChannels[0].description).to.equal('super video channel description') | |
102 | expect(videoChannels[0].support).to.equal('super video channel support text') | |
103 | }) | |
104 | ||
105 | it('Should list video channels', async function () { | |
106 | const res = await getVideoChannelsList(servers[0].url, 1, 1, '-name') | |
107 | ||
108 | expect(res.body.total).to.equal(2) | |
109 | expect(res.body.data).to.be.an('array') | |
110 | expect(res.body.data).to.have.lengthOf(1) | |
111 | expect(res.body.data[0].displayName).to.equal('Default root channel') | |
112 | }) | |
113 | ||
114 | it('Should update video channel', async function () { | |
115 | this.timeout(5000) | |
116 | ||
117 | const videoChannelAttributes = { | |
118 | name: 'video channel updated', | |
119 | description: 'video channel description updated', | |
120 | support: 'video channel support text updated' | |
121 | } | |
122 | ||
123 | await updateVideoChannel(servers[0].url, servers[0].accessToken, videoChannelId, videoChannelAttributes) | |
124 | ||
125 | await wait(3000) | |
126 | }) | |
127 | ||
128 | it('Should have video channel updated', async function () { | |
129 | for (const server of servers) { | |
130 | const res = await getVideoChannelsList(server.url, 0, 1, '-name') | |
131 | ||
132 | expect(res.body.total).to.equal(2) | |
133 | expect(res.body.data).to.be.an('array') | |
134 | expect(res.body.data).to.have.lengthOf(1) | |
135 | expect(res.body.data[0].displayName).to.equal('video channel updated') | |
136 | expect(res.body.data[0].description).to.equal('video channel description updated') | |
137 | expect(res.body.data[0].support).to.equal('video channel support text updated') | |
138 | } | |
139 | }) | |
140 | ||
141 | it('Should get video channel', async function () { | |
142 | const res = await getVideoChannel(servers[0].url, videoChannelId) | |
143 | ||
144 | const videoChannel = res.body | |
145 | expect(videoChannel.displayName).to.equal('video channel updated') | |
146 | expect(videoChannel.description).to.equal('video channel description updated') | |
147 | expect(videoChannel.support).to.equal('video channel support text updated') | |
148 | }) | |
149 | ||
150 | it('Should delete video channel', async function () { | |
151 | await deleteVideoChannel(servers[0].url, servers[0].accessToken, videoChannelId) | |
152 | }) | |
153 | ||
154 | it('Should have video channel deleted', async function () { | |
155 | const res = await getVideoChannelsList(servers[0].url, 0, 10) | |
156 | ||
157 | expect(res.body.total).to.equal(1) | |
158 | expect(res.body.data).to.be.an('array') | |
159 | expect(res.body.data).to.have.lengthOf(1) | |
160 | expect(res.body.data[0].displayName).to.equal('Default root channel') | |
161 | }) | |
162 | ||
163 | after(async function () { | |
164 | killallServers(servers) | |
165 | ||
166 | // Keep the logs if the test failed | |
167 | if (this['ok']) { | |
168 | await flushTests() | |
169 | } | |
170 | }) | |
171 | }) |