aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/video-channels.ts70
-rw-r--r--server/tests/api/videos/video-channels.ts86
2 files changed, 110 insertions, 46 deletions
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 0dd436426..bc2e6192e 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -234,7 +234,8 @@ describe('Test video channels API validator', function () {
234 }) 234 })
235 }) 235 })
236 236
237 describe('When updating video channel avatar', function () { 237 describe('When updating video channel avatar/banner', function () {
238 const types = [ 'avatar', 'banner' ]
238 let path: string 239 let path: string
239 240
240 before(async function () { 241 before(async function () {
@@ -242,48 +243,57 @@ describe('Test video channels API validator', function () {
242 }) 243 })
243 244
244 it('Should fail with an incorrect input file', async function () { 245 it('Should fail with an incorrect input file', async function () {
245 const fields = {} 246 for (const type of types) {
246 const attaches = { 247 const fields = {}
247 avatarfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') 248 const attaches = {
249 [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
250 }
251
252 await makeUploadRequest({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, fields, attaches })
248 } 253 }
249 await makeUploadRequest({ url: server.url, path: path + '/avatar/pick', token: server.accessToken, fields, attaches })
250 }) 254 })
251 255
252 it('Should fail with a big file', async function () { 256 it('Should fail with a big file', async function () {
253 const fields = {} 257 for (const type of types) {
254 const attaches = { 258 const fields = {}
255 avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') 259 const attaches = {
260 [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
261 }
262 await makeUploadRequest({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, fields, attaches })
256 } 263 }
257 await makeUploadRequest({ url: server.url, path: path + '/avatar/pick', token: server.accessToken, fields, attaches })
258 }) 264 })
259 265
260 it('Should fail with an unauthenticated user', async function () { 266 it('Should fail with an unauthenticated user', async function () {
261 const fields = {} 267 for (const type of types) {
262 const attaches = { 268 const fields = {}
263 avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png') 269 const attaches = {
270 [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'avatar.png')
271 }
272 await makeUploadRequest({
273 url: server.url,
274 path: `${path}/${type}/pick`,
275 fields,
276 attaches,
277 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
278 })
264 } 279 }
265 await makeUploadRequest({
266 url: server.url,
267 path: path + '/avatar/pick',
268 fields,
269 attaches,
270 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
271 })
272 }) 280 })
273 281
274 it('Should succeed with the correct params', async function () { 282 it('Should succeed with the correct params', async function () {
275 const fields = {} 283 for (const type of types) {
276 const attaches = { 284 const fields = {}
277 avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png') 285 const attaches = {
286 [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'avatar.png')
287 }
288 await makeUploadRequest({
289 url: server.url,
290 path: `${path}/${type}/pick`,
291 token: server.accessToken,
292 fields,
293 attaches,
294 statusCodeExpected: HttpStatusCode.OK_200
295 })
278 } 296 }
279 await makeUploadRequest({
280 url: server.url,
281 path: path + '/avatar/pick',
282 token: server.accessToken,
283 fields,
284 attaches,
285 statusCodeExpected: HttpStatusCode.OK_200
286 })
287 }) 297 })
288 }) 298 })
289 299
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 367f99fdd..8033b9ba5 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -5,13 +5,14 @@ import * as chai from 'chai'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 createUser, 7 createUser,
8 deleteVideoChannelImage,
8 doubleFollow, 9 doubleFollow,
9 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
10 getVideo, 11 getVideo,
11 getVideoChannelVideos, 12 getVideoChannelVideos,
12 testImage, 13 testImage,
13 updateVideo, 14 updateVideo,
14 updateVideoChannelAvatar, 15 updateVideoChannelImage,
15 uploadVideo, 16 uploadVideo,
16 userLogin, 17 userLogin,
17 wait 18 wait
@@ -21,7 +22,6 @@ import {
21 deleteVideoChannel, 22 deleteVideoChannel,
22 getAccountVideoChannelsList, 23 getAccountVideoChannelsList,
23 getMyUserInformation, 24 getMyUserInformation,
24 getVideoChannel,
25 getVideoChannelsList, 25 getVideoChannelsList,
26 ServerInfo, 26 ServerInfo,
27 setAccessTokensToServers, 27 setAccessTokensToServers,
@@ -33,6 +33,13 @@ import { User, Video, VideoChannel, VideoDetails } from '../../../../shared/inde
33 33
34const expect = chai.expect 34const expect = chai.expect
35 35
36async function findChannel (server: ServerInfo, channelId: number) {
37 const res = await getVideoChannelsList(server.url, 0, 5, '-name')
38 const videoChannel = res.body.data.find(c => c.id === channelId)
39
40 return videoChannel as VideoChannel
41}
42
36describe('Test video channels', function () { 43describe('Test video channels', function () {
37 let servers: ServerInfo[] 44 let servers: ServerInfo[]
38 let userInfo: User 45 let userInfo: User
@@ -262,38 +269,85 @@ describe('Test video channels', function () {
262 }) 269 })
263 270
264 it('Should update video channel avatar', async function () { 271 it('Should update video channel avatar', async function () {
265 this.timeout(5000) 272 this.timeout(15000)
266 273
267 const fixture = 'avatar.png' 274 const fixture = 'avatar.png'
268 275
269 await updateVideoChannelAvatar({ 276 await updateVideoChannelImage({
270 url: servers[0].url, 277 url: servers[0].url,
271 accessToken: servers[0].accessToken, 278 accessToken: servers[0].accessToken,
272 videoChannelName: 'second_video_channel', 279 videoChannelName: 'second_video_channel',
273 fixture 280 fixture,
281 type: 'avatar'
274 }) 282 })
275 283
276 await waitJobs(servers) 284 await waitJobs(servers)
285
286 for (const server of servers) {
287 const videoChannel = await findChannel(server, secondVideoChannelId)
288
289 await testImage(server.url, 'avatar-resized', videoChannel.avatar.path, '.png')
290 }
277 }) 291 })
278 292
279 it('Should have video channel avatar updated', async function () { 293 it('Should update video channel banner', async function () {
294 this.timeout(15000)
295
296 const fixture = 'banner.jpg'
297
298 await updateVideoChannelImage({
299 url: servers[0].url,
300 accessToken: servers[0].accessToken,
301 videoChannelName: 'second_video_channel',
302 fixture,
303 type: 'banner'
304 })
305
306 await waitJobs(servers)
307
280 for (const server of servers) { 308 for (const server of servers) {
281 const res = await getVideoChannelsList(server.url, 0, 1, '-name') 309 const videoChannel = await findChannel(server, secondVideoChannelId)
282 310
283 const videoChannel = res.body.data.find(c => c.id === secondVideoChannelId) 311 await testImage(server.url, 'banner-resized', videoChannel.banner.path)
312 }
313 })
284 314
285 await testImage(server.url, 'avatar-resized', videoChannel.avatar.path, '.png') 315 it('Should delete the video channel avatar', async function () {
316 this.timeout(15000)
317
318 await deleteVideoChannelImage({
319 url: servers[0].url,
320 accessToken: servers[0].accessToken,
321 videoChannelName: 'second_video_channel',
322 type: 'avatar'
323 })
324
325 await waitJobs(servers)
326
327 for (const server of servers) {
328 const videoChannel = await findChannel(server, secondVideoChannelId)
329
330 expect(videoChannel.avatar).to.be.null
286 } 331 }
287 }) 332 })
288 333
289 it('Should get video channel', async function () { 334 it('Should delete the video channel banner', async function () {
290 const res = await getVideoChannel(servers[0].url, 'second_video_channel') 335 this.timeout(15000)
336
337 await deleteVideoChannelImage({
338 url: servers[0].url,
339 accessToken: servers[0].accessToken,
340 videoChannelName: 'second_video_channel',
341 type: 'banner'
342 })
291 343
292 const videoChannel = res.body 344 await waitJobs(servers)
293 expect(videoChannel.name).to.equal('second_video_channel') 345
294 expect(videoChannel.displayName).to.equal('video channel updated') 346 for (const server of servers) {
295 expect(videoChannel.description).to.equal('video channel description updated') 347 const videoChannel = await findChannel(server, secondVideoChannelId)
296 expect(videoChannel.support).to.equal('video channel support text updated') 348
349 expect(videoChannel.banner).to.be.null
350 }
297 }) 351 })
298 352
299 it('Should list the second video channel videos', async function () { 353 it('Should list the second video channel videos', async function () {