]>
Commit | Line | Data |
---|---|---|
5f04dd2f C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
5f04dd2f | 3 | import * as chai from 'chai' |
2422c46b | 4 | import 'mocha' |
0f320037 | 5 | import { User, Video } from '../../../../shared/index' |
4bbfc6c6 | 6 | import { |
8a19bee1 | 7 | createUser, |
4bbfc6c6 C |
8 | doubleFollow, |
9 | flushAndRunMultipleServers, | |
d175a6f7 C |
10 | getVideoChannelVideos, |
11 | testImage, | |
4bbfc6c6 C |
12 | updateVideo, |
13 | updateVideoChannelAvatar, | |
d175a6f7 C |
14 | uploadVideo, |
15 | userLogin | |
94565d52 | 16 | } from '../../../../shared/extra-utils' |
5f04dd2f | 17 | import { |
2422c46b C |
18 | addVideoChannel, |
19 | deleteVideoChannel, | |
5f04dd2f | 20 | flushTests, |
2422c46b | 21 | getAccountVideoChannelsList, |
5f04dd2f | 22 | getMyUserInformation, |
2422c46b | 23 | getVideoChannel, |
5f04dd2f | 24 | getVideoChannelsList, |
2422c46b C |
25 | killallServers, |
26 | ServerInfo, | |
27 | setAccessTokensToServers, | |
28 | updateVideoChannel | |
94565d52 C |
29 | } from '../../../../shared/extra-utils/index' |
30 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | |
5f04dd2f | 31 | |
2422c46b C |
32 | const expect = chai.expect |
33 | ||
34 | describe('Test video channels', function () { | |
35 | let servers: ServerInfo[] | |
5f04dd2f | 36 | let userInfo: User |
6b738c7a | 37 | let accountUUID: string |
0f320037 | 38 | let firstVideoChannelId: number |
0f320037 | 39 | let secondVideoChannelId: number |
0f320037 | 40 | let videoUUID: string |
5f04dd2f C |
41 | |
42 | before(async function () { | |
e212f887 | 43 | this.timeout(30000) |
5f04dd2f | 44 | |
2422c46b C |
45 | servers = await flushAndRunMultipleServers(2) |
46 | ||
47 | await setAccessTokensToServers(servers) | |
48 | await doubleFollow(servers[0], servers[1]) | |
5f04dd2f | 49 | |
48dce1c9 | 50 | { |
6b738c7a C |
51 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) |
52 | const user: User = res.body | |
53 | accountUUID = user.account.uuid | |
0f320037 C |
54 | |
55 | firstVideoChannelId = user.videoChannels[0].id | |
48dce1c9 C |
56 | } |
57 | ||
3cd0734f | 58 | await waitJobs(servers) |
5f04dd2f C |
59 | }) |
60 | ||
61 | it('Should have one video channel (created with root)', async () => { | |
2422c46b | 62 | const res = await getVideoChannelsList(servers[0].url, 0, 2) |
5f04dd2f C |
63 | |
64 | expect(res.body.total).to.equal(1) | |
65 | expect(res.body.data).to.be.an('array') | |
66 | expect(res.body.data).to.have.lengthOf(1) | |
67 | }) | |
68 | ||
2422c46b C |
69 | it('Should create another video channel', async function () { |
70 | this.timeout(10000) | |
71 | ||
0f320037 C |
72 | { |
73 | const videoChannel = { | |
8a19bee1 | 74 | name: 'second_video_channel', |
0f320037 C |
75 | displayName: 'second video channel', |
76 | description: 'super video channel description', | |
77 | support: 'super video channel support text' | |
78 | } | |
79 | const res = await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel) | |
80 | secondVideoChannelId = res.body.videoChannel.id | |
5f04dd2f | 81 | } |
2422c46b C |
82 | |
83 | // The channel is 1 is propagated to servers 2 | |
0f320037 C |
84 | { |
85 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'my video name', channelId: secondVideoChannelId }) | |
86 | videoUUID = res.body.video.uuid | |
87 | } | |
2422c46b | 88 | |
3cd0734f | 89 | await waitJobs(servers) |
5f04dd2f C |
90 | }) |
91 | ||
92 | it('Should have two video channels when getting my information', async () => { | |
2422c46b | 93 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) |
5f04dd2f C |
94 | userInfo = res.body |
95 | ||
96 | expect(userInfo.videoChannels).to.be.an('array') | |
97 | expect(userInfo.videoChannels).to.have.lengthOf(2) | |
98 | ||
99 | const videoChannels = userInfo.videoChannels | |
8a19bee1 C |
100 | expect(videoChannels[0].name).to.equal('root_channel') |
101 | expect(videoChannels[0].displayName).to.equal('Main root channel') | |
102 | ||
103 | expect(videoChannels[1].name).to.equal('second_video_channel') | |
7bc29171 | 104 | expect(videoChannels[1].displayName).to.equal('second video channel') |
5f04dd2f | 105 | expect(videoChannels[1].description).to.equal('super video channel description') |
2422c46b | 106 | expect(videoChannels[1].support).to.equal('super video channel support text') |
5f04dd2f C |
107 | }) |
108 | ||
2422c46b | 109 | it('Should have two video channels when getting account channels on server 1', async function () { |
ad9e39fb | 110 | const res = await getAccountVideoChannelsList(servers[0].url, userInfo.account.name + '@' + userInfo.account.host) |
5f04dd2f C |
111 | expect(res.body.total).to.equal(2) |
112 | expect(res.body.data).to.be.an('array') | |
113 | expect(res.body.data).to.have.lengthOf(2) | |
114 | ||
115 | const videoChannels = res.body.data | |
8a19bee1 C |
116 | expect(videoChannels[0].name).to.equal('root_channel') |
117 | expect(videoChannels[0].displayName).to.equal('Main root channel') | |
118 | ||
119 | expect(videoChannels[1].name).to.equal('second_video_channel') | |
7bc29171 | 120 | expect(videoChannels[1].displayName).to.equal('second video channel') |
5f04dd2f | 121 | expect(videoChannels[1].description).to.equal('super video channel description') |
2422c46b C |
122 | expect(videoChannels[1].support).to.equal('super video channel support text') |
123 | }) | |
124 | ||
125 | it('Should have one video channel when getting account channels on server 2', async function () { | |
ad9e39fb | 126 | const res = await getAccountVideoChannelsList(servers[1].url, userInfo.account.name + '@' + userInfo.account.host) |
2422c46b C |
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) | |
5f04dd2f | 130 | |
2422c46b | 131 | const videoChannels = res.body.data |
8a19bee1 | 132 | expect(videoChannels[0].name).to.equal('second_video_channel') |
2422c46b C |
133 | expect(videoChannels[0].displayName).to.equal('second video channel') |
134 | expect(videoChannels[0].description).to.equal('super video channel description') | |
135 | expect(videoChannels[0].support).to.equal('super video channel support text') | |
5f04dd2f C |
136 | }) |
137 | ||
2422c46b C |
138 | it('Should list video channels', async function () { |
139 | const res = await getVideoChannelsList(servers[0].url, 1, 1, '-name') | |
5f04dd2f C |
140 | |
141 | expect(res.body.total).to.equal(2) | |
142 | expect(res.body.data).to.be.an('array') | |
143 | expect(res.body.data).to.have.lengthOf(1) | |
8a19bee1 C |
144 | expect(res.body.data[0].name).to.equal('root_channel') |
145 | expect(res.body.data[0].displayName).to.equal('Main root channel') | |
5f04dd2f C |
146 | }) |
147 | ||
2422c46b C |
148 | it('Should update video channel', async function () { |
149 | this.timeout(5000) | |
150 | ||
5f04dd2f | 151 | const videoChannelAttributes = { |
08c1efbe | 152 | displayName: 'video channel updated', |
2422c46b C |
153 | description: 'video channel description updated', |
154 | support: 'video channel support text updated' | |
5f04dd2f C |
155 | } |
156 | ||
8a19bee1 | 157 | await updateVideoChannel(servers[0].url, servers[0].accessToken, 'second_video_channel', videoChannelAttributes) |
2422c46b | 158 | |
3cd0734f | 159 | await waitJobs(servers) |
5f04dd2f C |
160 | }) |
161 | ||
2422c46b C |
162 | it('Should have video channel updated', async function () { |
163 | for (const server of servers) { | |
164 | const res = await getVideoChannelsList(server.url, 0, 1, '-name') | |
5f04dd2f | 165 | |
2422c46b C |
166 | expect(res.body.total).to.equal(2) |
167 | expect(res.body.data).to.be.an('array') | |
168 | expect(res.body.data).to.have.lengthOf(1) | |
8a19bee1 | 169 | expect(res.body.data[0].name).to.equal('second_video_channel') |
2422c46b C |
170 | expect(res.body.data[0].displayName).to.equal('video channel updated') |
171 | expect(res.body.data[0].description).to.equal('video channel description updated') | |
172 | expect(res.body.data[0].support).to.equal('video channel support text updated') | |
173 | } | |
5f04dd2f C |
174 | }) |
175 | ||
4bbfc6c6 C |
176 | it('Should update video channel avatar', async function () { |
177 | this.timeout(5000) | |
178 | ||
179 | const fixture = 'avatar.png' | |
180 | ||
181 | await updateVideoChannelAvatar({ | |
182 | url: servers[0].url, | |
183 | accessToken: servers[0].accessToken, | |
8a19bee1 | 184 | videoChannelName: 'second_video_channel', |
4bbfc6c6 C |
185 | fixture |
186 | }) | |
187 | ||
188 | await waitJobs(servers) | |
189 | }) | |
190 | ||
191 | it('Should have video channel avatar updated', async function () { | |
192 | for (const server of servers) { | |
193 | const res = await getVideoChannelsList(server.url, 0, 1, '-name') | |
194 | ||
195 | const videoChannel = res.body.data.find(c => c.id === secondVideoChannelId) | |
196 | ||
197 | await testImage(server.url, 'avatar-resized', videoChannel.avatar.path, '.png') | |
198 | } | |
199 | }) | |
200 | ||
2422c46b | 201 | it('Should get video channel', async function () { |
8a19bee1 | 202 | const res = await getVideoChannel(servers[0].url, 'second_video_channel') |
5f04dd2f C |
203 | |
204 | const videoChannel = res.body | |
8a19bee1 | 205 | expect(videoChannel.name).to.equal('second_video_channel') |
7bc29171 | 206 | expect(videoChannel.displayName).to.equal('video channel updated') |
5f04dd2f | 207 | expect(videoChannel.description).to.equal('video channel description updated') |
2422c46b | 208 | expect(videoChannel.support).to.equal('video channel support text updated') |
5f04dd2f C |
209 | }) |
210 | ||
0f320037 | 211 | it('Should list the second video channel videos', async function () { |
6b738c7a C |
212 | this.timeout(10000) |
213 | ||
214 | for (const server of servers) { | |
8a19bee1 C |
215 | const channelURI = 'second_video_channel@localhost:9001' |
216 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) | |
0f320037 C |
217 | expect(res1.body.total).to.equal(1) |
218 | expect(res1.body.data).to.be.an('array') | |
219 | expect(res1.body.data).to.have.lengthOf(1) | |
220 | expect(res1.body.data[0].name).to.equal('my video name') | |
221 | } | |
222 | }) | |
223 | ||
224 | it('Should change the video channel of a video', async function () { | |
225 | this.timeout(10000) | |
226 | ||
227 | await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { channelId: firstVideoChannelId }) | |
228 | ||
3cd0734f | 229 | await waitJobs(servers) |
0f320037 C |
230 | }) |
231 | ||
232 | it('Should list the first video channel videos', async function () { | |
233 | this.timeout(10000) | |
234 | ||
235 | for (const server of servers) { | |
8a19bee1 C |
236 | const secondChannelURI = 'second_video_channel@localhost:9001' |
237 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5) | |
0f320037 C |
238 | expect(res1.body.total).to.equal(0) |
239 | ||
8a19bee1 C |
240 | const channelURI = 'root_channel@localhost:9001' |
241 | const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) | |
0f320037 C |
242 | expect(res2.body.total).to.equal(1) |
243 | ||
244 | const videos: Video[] = res2.body.data | |
245 | expect(videos).to.be.an('array') | |
246 | expect(videos).to.have.lengthOf(1) | |
247 | expect(videos[0].name).to.equal('my video name') | |
6b738c7a C |
248 | } |
249 | }) | |
250 | ||
2422c46b | 251 | it('Should delete video channel', async function () { |
8a19bee1 | 252 | await deleteVideoChannel(servers[0].url, servers[0].accessToken, 'second_video_channel') |
5f04dd2f C |
253 | }) |
254 | ||
2422c46b C |
255 | it('Should have video channel deleted', async function () { |
256 | const res = await getVideoChannelsList(servers[0].url, 0, 10) | |
5f04dd2f C |
257 | |
258 | expect(res.body.total).to.equal(1) | |
259 | expect(res.body.data).to.be.an('array') | |
260 | expect(res.body.data).to.have.lengthOf(1) | |
8a19bee1 C |
261 | expect(res.body.data[0].displayName).to.equal('Main root channel') |
262 | }) | |
263 | ||
264 | it('Should create the main channel with an uuid if there is a conflict', async function () { | |
265 | { | |
266 | const videoChannel = { name: 'toto_channel', displayName: 'My toto channel' } | |
267 | await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel) | |
268 | } | |
269 | ||
270 | { | |
1eddc9a7 | 271 | await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: 'toto', password: 'password' }) |
8a19bee1 C |
272 | const accessToken = await userLogin(servers[ 0 ], { username: 'toto', password: 'password' }) |
273 | ||
274 | const res = await getMyUserInformation(servers[ 0 ].url, accessToken) | |
275 | const videoChannel = res.body.videoChannels[ 0 ] | |
276 | expect(videoChannel.name).to.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/) | |
277 | } | |
5f04dd2f C |
278 | }) |
279 | ||
210feb6c | 280 | after(function () { |
2422c46b | 281 | killallServers(servers) |
5f04dd2f C |
282 | }) |
283 | }) |