aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
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
parent2cb03dc1f4e01ba491c36caff30c33fe9c5bad89 (diff)
downloadPeerTube-213e30ef90806369529684ac9c247d73b8dc7928.tar.gz
PeerTube-213e30ef90806369529684ac9c247d73b8dc7928.tar.zst
PeerTube-213e30ef90806369529684ac9c247d73b8dc7928.zip
Add banner tests
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/requests/requests.ts7
-rw-r--r--shared/extra-utils/users/users.ts4
-rw-r--r--shared/extra-utils/videos/video-channels.ts29
3 files changed, 29 insertions, 11 deletions
diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.ts
index 3e773ee03..8b5cddf4a 100644
--- a/shared/extra-utils/requests/requests.ts
+++ b/shared/extra-utils/requests/requests.ts
@@ -152,11 +152,12 @@ function makeHTMLRequest (url: string, path: string) {
152 .expect(HttpStatusCode.OK_200) 152 .expect(HttpStatusCode.OK_200)
153} 153}
154 154
155function updateAvatarRequest (options: { 155function updateImageRequest (options: {
156 url: string 156 url: string
157 path: string 157 path: string
158 accessToken: string 158 accessToken: string
159 fixture: string 159 fixture: string
160 fieldname: string
160}) { 161}) {
161 let filePath = '' 162 let filePath = ''
162 if (isAbsolute(options.fixture)) { 163 if (isAbsolute(options.fixture)) {
@@ -170,7 +171,7 @@ function updateAvatarRequest (options: {
170 path: options.path, 171 path: options.path,
171 token: options.accessToken, 172 token: options.accessToken,
172 fields: {}, 173 fields: {},
173 attaches: { avatarfile: filePath }, 174 attaches: { [options.fieldname]: filePath },
174 statusCodeExpected: HttpStatusCode.OK_200 175 statusCodeExpected: HttpStatusCode.OK_200
175 }) 176 })
176} 177}
@@ -191,5 +192,5 @@ export {
191 makePutBodyRequest, 192 makePutBodyRequest,
192 makeDeleteRequest, 193 makeDeleteRequest,
193 makeRawRequest, 194 makeRawRequest,
194 updateAvatarRequest 195 updateImageRequest
195} 196}
diff --git a/shared/extra-utils/users/users.ts b/shared/extra-utils/users/users.ts
index db532dbb0..6040dd9c0 100644
--- a/shared/extra-utils/users/users.ts
+++ b/shared/extra-utils/users/users.ts
@@ -4,7 +4,7 @@ import { UserUpdateMe } from '../../models/users'
4import { UserAdminFlag } from '../../models/users/user-flag.model' 4import { UserAdminFlag } from '../../models/users/user-flag.model'
5import { UserRegister } from '../../models/users/user-register.model' 5import { UserRegister } from '../../models/users/user-register.model'
6import { UserRole } from '../../models/users/user-role' 6import { UserRole } from '../../models/users/user-role'
7import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' 7import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateImageRequest } from '../requests/requests'
8import { ServerInfo } from '../server/servers' 8import { ServerInfo } from '../server/servers'
9import { userLogin } from './login' 9import { userLogin } from './login'
10import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 10import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
@@ -275,7 +275,7 @@ function updateMyAvatar (options: {
275}) { 275}) {
276 const path = '/api/v1/users/me/avatar/pick' 276 const path = '/api/v1/users/me/avatar/pick'
277 277
278 return updateAvatarRequest(Object.assign(options, { path })) 278 return updateImageRequest({ ...options, path, fieldname: 'avatarfile' })
279} 279}
280 280
281function updateUser (options: { 281function updateUser (options: {
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}