aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/videos/video-channels.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-04-07 10:36:13 +0200
committerChocobozzz <chocobozzz@cpy.re>2021-04-08 10:07:53 +0200
commit213e30ef90806369529684ac9c247d73b8dc7928 (patch)
tree7f834f2485a074b1d3052745fa5236d34c0f26db /shared/extra-utils/videos/video-channels.ts
parent2cb03dc1f4e01ba491c36caff30c33fe9c5bad89 (diff)
downloadPeerTube-213e30ef90806369529684ac9c247d73b8dc7928.tar.gz
PeerTube-213e30ef90806369529684ac9c247d73b8dc7928.tar.zst
PeerTube-213e30ef90806369529684ac9c247d73b8dc7928.zip
Add banner tests
Diffstat (limited to 'shared/extra-utils/videos/video-channels.ts')
-rw-r--r--shared/extra-utils/videos/video-channels.ts29
1 files changed, 23 insertions, 6 deletions
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 @@
3import * as request from 'supertest' 3import * as request from 'supertest'
4import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model' 4import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model'
5import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model' 5import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model'
6import { makeGetRequest, updateAvatarRequest } from '../requests/requests' 6import { makeDeleteRequest, makeGetRequest, updateImageRequest } from '../requests/requests'
7import { ServerInfo } from '../server/servers' 7import { ServerInfo } from '../server/servers'
8import { User } from '../../models/users/user.model' 8import { User } from '../../models/users/user.model'
9import { getMyUserInformation } from '../users/users' 9import { getMyUserInformation } from '../users/users'
@@ -129,16 +129,32 @@ function getVideoChannel (url: string, channelName: string) {
129 .expect('Content-Type', /json/) 129 .expect('Content-Type', /json/)
130} 130}
131 131
132function updateVideoChannelAvatar (options: { 132function updateVideoChannelImage (options: {
133 url: string 133 url: string
134 accessToken: string 134 accessToken: string
135 fixture: string 135 fixture: string
136 videoChannelName: string | number 136 videoChannelName: string | number
137 type: 'avatar' | 'banner'
137}) { 138}) {
139 const path = `/api/v1/video-channels/${options.videoChannelName}/${options.type}/pick`
138 140
139 const path = '/api/v1/video-channels/' + options.videoChannelName + '/avatar/pick' 141 return updateImageRequest({ ...options, path, fieldname: options.type + 'file' })
142}
143
144function deleteVideoChannelImage (options: {
145 url: string
146 accessToken: string
147 videoChannelName: string | number
148 type: 'avatar' | 'banner'
149}) {
150 const path = `/api/v1/video-channels/${options.videoChannelName}/${options.type}`
140 151
141 return updateAvatarRequest(Object.assign(options, { path })) 152 return makeDeleteRequest({
153 url: options.url,
154 token: options.accessToken,
155 path,
156 statusCodeExpected: 204
157 })
142} 158}
143 159
144function setDefaultVideoChannel (servers: ServerInfo[]) { 160function setDefaultVideoChannel (servers: ServerInfo[]) {
@@ -157,12 +173,13 @@ function setDefaultVideoChannel (servers: ServerInfo[]) {
157// --------------------------------------------------------------------------- 173// ---------------------------------------------------------------------------
158 174
159export { 175export {
160 updateVideoChannelAvatar, 176 updateVideoChannelImage,
161 getVideoChannelsList, 177 getVideoChannelsList,
162 getAccountVideoChannelsList, 178 getAccountVideoChannelsList,
163 addVideoChannel, 179 addVideoChannel,
164 updateVideoChannel, 180 updateVideoChannel,
165 deleteVideoChannel, 181 deleteVideoChannel,
166 getVideoChannel, 182 getVideoChannel,
167 setDefaultVideoChannel 183 setDefaultVideoChannel,
184 deleteVideoChannelImage
168} 185}