From 213e30ef90806369529684ac9c247d73b8dc7928 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Apr 2021 10:36:13 +0200 Subject: Add banner tests --- shared/extra-utils/videos/video-channels.ts | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'shared/extra-utils/videos/video-channels.ts') diff --git a/shared/extra-utils/videos/video-channels.ts b/shared/extra-utils/videos/video-channels.ts index 3ff445c2a..d0dfb5856 100644 --- a/shared/extra-utils/videos/video-channels.ts +++ b/shared/extra-utils/videos/video-channels.ts @@ -3,7 +3,7 @@ import * as request from 'supertest' import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model' import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model' -import { makeGetRequest, updateAvatarRequest } from '../requests/requests' +import { makeDeleteRequest, makeGetRequest, updateImageRequest } from '../requests/requests' import { ServerInfo } from '../server/servers' import { User } from '../../models/users/user.model' import { getMyUserInformation } from '../users/users' @@ -129,16 +129,32 @@ function getVideoChannel (url: string, channelName: string) { .expect('Content-Type', /json/) } -function updateVideoChannelAvatar (options: { +function updateVideoChannelImage (options: { url: string accessToken: string fixture: string videoChannelName: string | number + type: 'avatar' | 'banner' }) { + const path = `/api/v1/video-channels/${options.videoChannelName}/${options.type}/pick` - const path = '/api/v1/video-channels/' + options.videoChannelName + '/avatar/pick' + return updateImageRequest({ ...options, path, fieldname: options.type + 'file' }) +} + +function deleteVideoChannelImage (options: { + url: string + accessToken: string + videoChannelName: string | number + type: 'avatar' | 'banner' +}) { + const path = `/api/v1/video-channels/${options.videoChannelName}/${options.type}` - return updateAvatarRequest(Object.assign(options, { path })) + return makeDeleteRequest({ + url: options.url, + token: options.accessToken, + path, + statusCodeExpected: 204 + }) } function setDefaultVideoChannel (servers: ServerInfo[]) { @@ -157,12 +173,13 @@ function setDefaultVideoChannel (servers: ServerInfo[]) { // --------------------------------------------------------------------------- export { - updateVideoChannelAvatar, + updateVideoChannelImage, getVideoChannelsList, getAccountVideoChannelsList, addVideoChannel, updateVideoChannel, deleteVideoChannel, getVideoChannel, - setDefaultVideoChannel + setDefaultVideoChannel, + deleteVideoChannelImage } -- cgit v1.2.3