aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/video-channels.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-17 15:45:42 +0200
committerChocobozzz <me@florianbigard.com>2018-08-27 09:41:54 +0200
commit8a19bee1a1ee39f973bb37429e4f73c3f2873cdb (patch)
tree33c93ef19451d7e46d4be74ce0681359d2dcc70e /server/tests/api/check-params/video-channels.ts
parent965c4b22d0e4d2f853501e844e6ebbb861bd389d (diff)
downloadPeerTube-8a19bee1a1ee39f973bb37429e4f73c3f2873cdb.tar.gz
PeerTube-8a19bee1a1ee39f973bb37429e4f73c3f2873cdb.tar.zst
PeerTube-8a19bee1a1ee39f973bb37429e4f73c3f2873cdb.zip
Add ability to set a name to a channel
Diffstat (limited to 'server/tests/api/check-params/video-channels.ts')
-rw-r--r--server/tests/api/check-params/video-channels.ts47
1 files changed, 20 insertions, 27 deletions
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 0980de73b..bcf4b7473 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -31,7 +31,6 @@ describe('Test video channels API validator', function () {
31 const videoChannelPath = '/api/v1/video-channels' 31 const videoChannelPath = '/api/v1/video-channels'
32 let server: ServerInfo 32 let server: ServerInfo
33 let accessTokenUser: string 33 let accessTokenUser: string
34 let videoChannelUUID: string
35 34
36 // --------------------------------------------------------------- 35 // ---------------------------------------------------------------
37 36
@@ -53,12 +52,6 @@ describe('Test video channels API validator', function () {
53 await createUser(server.url, server.accessToken, user.username, user.password) 52 await createUser(server.url, server.accessToken, user.username, user.password)
54 accessTokenUser = await userLogin(server, user) 53 accessTokenUser = await userLogin(server, user)
55 } 54 }
56
57 {
58 const res = await getMyUserInformation(server.url, server.accessToken)
59 const user: User = res.body
60 videoChannelUUID = user.videoChannels[0].uuid
61 }
62 }) 55 })
63 56
64 describe('When listing a video channels', function () { 57 describe('When listing a video channels', function () {
@@ -83,6 +76,7 @@ describe('Test video channels API validator', function () {
83 76
84 describe('When adding a video channel', function () { 77 describe('When adding a video channel', function () {
85 const baseCorrectParams = { 78 const baseCorrectParams = {
79 name: 'super_channel',
86 displayName: 'hello', 80 displayName: 'hello',
87 description: 'super description', 81 description: 'super description',
88 support: 'super support text' 82 support: 'super support text'
@@ -104,6 +98,16 @@ describe('Test video channels API validator', function () {
104 }) 98 })
105 99
106 it('Should fail without a name', async function () { 100 it('Should fail without a name', async function () {
101 const fields = omit(baseCorrectParams, 'name')
102 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
103 })
104
105 it('Should fail with a bad name', async function () {
106 const fields = immutableAssign(baseCorrectParams, { name: 'super name' })
107 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
108 })
109
110 it('Should fail without a name', async function () {
107 const fields = omit(baseCorrectParams, 'displayName') 111 const fields = omit(baseCorrectParams, 'displayName')
108 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }) 112 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
109 }) 113 })
@@ -142,7 +146,7 @@ describe('Test video channels API validator', function () {
142 let path: string 146 let path: string
143 147
144 before(async function () { 148 before(async function () {
145 path = videoChannelPath + '/' + videoChannelUUID 149 path = videoChannelPath + '/super_channel'
146 }) 150 })
147 151
148 it('Should fail with a non authenticated user', async function () { 152 it('Should fail with a non authenticated user', async function () {
@@ -195,7 +199,7 @@ describe('Test video channels API validator', function () {
195 let path: string 199 let path: string
196 200
197 before(async function () { 201 before(async function () {
198 path = videoChannelPath + '/' + videoChannelUUID 202 path = videoChannelPath + '/super_channel'
199 }) 203 })
200 204
201 it('Should fail with an incorrect input file', async function () { 205 it('Should fail with an incorrect input file', async function () {
@@ -255,18 +259,10 @@ describe('Test video channels API validator', function () {
255 expect(res.body.data).to.be.an('array') 259 expect(res.body.data).to.be.an('array')
256 }) 260 })
257 261
258 it('Should fail without a correct uuid', async function () {
259 await makeGetRequest({
260 url: server.url,
261 path: videoChannelPath + '/coucou',
262 statusCodeExpected: 400
263 })
264 })
265
266 it('Should return 404 with an incorrect video channel', async function () { 262 it('Should return 404 with an incorrect video channel', async function () {
267 await makeGetRequest({ 263 await makeGetRequest({
268 url: server.url, 264 url: server.url,
269 path: videoChannelPath + '/4da6fde3-88f7-4d16-b119-108df5630b06', 265 path: videoChannelPath + '/super_channel2',
270 statusCodeExpected: 404 266 statusCodeExpected: 404
271 }) 267 })
272 }) 268 })
@@ -274,7 +270,7 @@ describe('Test video channels API validator', function () {
274 it('Should succeed with the correct parameters', async function () { 270 it('Should succeed with the correct parameters', async function () {
275 await makeGetRequest({ 271 await makeGetRequest({
276 url: server.url, 272 url: server.url,
277 path: videoChannelPath + '/' + videoChannelUUID, 273 path: videoChannelPath + '/super_channel',
278 statusCodeExpected: 200 274 statusCodeExpected: 200
279 }) 275 })
280 }) 276 })
@@ -282,26 +278,23 @@ describe('Test video channels API validator', function () {
282 278
283 describe('When deleting a video channel', function () { 279 describe('When deleting a video channel', function () {
284 it('Should fail with a non authenticated user', async function () { 280 it('Should fail with a non authenticated user', async function () {
285 await deleteVideoChannel(server.url, 'coucou', videoChannelUUID, 401) 281 await deleteVideoChannel(server.url, 'coucou', 'super_channel', 401)
286 }) 282 })
287 283
288 it('Should fail with another authenticated user', async function () { 284 it('Should fail with another authenticated user', async function () {
289 await deleteVideoChannel(server.url, accessTokenUser, videoChannelUUID, 403) 285 await deleteVideoChannel(server.url, accessTokenUser, 'super_channel', 403)
290 }) 286 })
291 287
292 it('Should fail with an unknown video channel id', async function () { 288 it('Should fail with an unknown video channel id', async function () {
293 await deleteVideoChannel(server.url, server.accessToken,454554, 404) 289 await deleteVideoChannel(server.url, server.accessToken,'super_channel2', 404)
294 }) 290 })
295 291
296 it('Should succeed with the correct parameters', async function () { 292 it('Should succeed with the correct parameters', async function () {
297 await deleteVideoChannel(server.url, server.accessToken, videoChannelUUID) 293 await deleteVideoChannel(server.url, server.accessToken, 'super_channel')
298 }) 294 })
299 295
300 it('Should fail to delete the last user video channel', async function () { 296 it('Should fail to delete the last user video channel', async function () {
301 const res = await getVideoChannelsList(server.url, 0, 1) 297 await deleteVideoChannel(server.url, server.accessToken, 'root_channel', 409)
302 const lastVideoChannelUUID = res.body.data[0].uuid
303
304 await deleteVideoChannel(server.url, server.accessToken, lastVideoChannelUUID, 409)
305 }) 298 })
306 }) 299 })
307 300