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