aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-04-25 10:21:38 +0200
committerChocobozzz <me@florianbigard.com>2018-04-25 13:50:48 +0200
commit6b738c7a31591a83fdcd9c78b6b1f98e543c378b (patch)
treedb771d0e99e9ff27570885fe2a6f58a7c1948fbc /server/tests/api/check-params/videos.ts
parent48dce1c90dff4e90a4bcffefaecf157336cf904b (diff)
downloadPeerTube-6b738c7a31591a83fdcd9c78b6b1f98e543c378b.tar.gz
PeerTube-6b738c7a31591a83fdcd9c78b6b1f98e543c378b.tar.zst
PeerTube-6b738c7a31591a83fdcd9c78b6b1f98e543c378b.zip
Video channel API routes refractor
Diffstat (limited to 'server/tests/api/check-params/videos.ts')
-rw-r--r--server/tests/api/check-params/videos.ts73
1 files changed, 70 insertions, 3 deletions
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index da41f515b..850ad12e0 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -10,6 +10,7 @@ import {
10 makeGetRequest, makeUploadRequest, makePutBodyRequest, removeVideo, runServer, ServerInfo, setAccessTokensToServers, userLogin 10 makeGetRequest, makeUploadRequest, makePutBodyRequest, removeVideo, runServer, ServerInfo, setAccessTokensToServers, userLogin
11} from '../../utils' 11} from '../../utils'
12import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' 12import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
13import { getAccountsList } from '../../utils/users/accounts'
13 14
14const expect = chai.expect 15const expect = chai.expect
15 16
@@ -17,7 +18,9 @@ describe('Test videos API validator', function () {
17 const path = '/api/v1/videos/' 18 const path = '/api/v1/videos/'
18 let server: ServerInfo 19 let server: ServerInfo
19 let userAccessToken = '' 20 let userAccessToken = ''
21 let accountUUID: string
20 let channelId: number 22 let channelId: number
23 let channelUUID: string
21 let videoId 24 let videoId
22 25
23 // --------------------------------------------------------------- 26 // ---------------------------------------------------------------
@@ -36,8 +39,12 @@ describe('Test videos API validator', function () {
36 await createUser(server.url, server.accessToken, username, password) 39 await createUser(server.url, server.accessToken, username, password)
37 userAccessToken = await userLogin(server, { username, password }) 40 userAccessToken = await userLogin(server, { username, password })
38 41
39 const res = await getMyUserInformation(server.url, server.accessToken) 42 {
40 channelId = res.body.videoChannels[0].id 43 const res = await getMyUserInformation(server.url, server.accessToken)
44 channelId = res.body.videoChannels[ 0 ].id
45 channelUUID = res.body.videoChannels[ 0 ].uuid
46 accountUUID = res.body.account.uuid
47 }
41 }) 48 })
42 49
43 describe('When listing a video', function () { 50 describe('When listing a video', function () {
@@ -52,6 +59,10 @@ describe('Test videos API validator', function () {
52 it('Should fail with an incorrect sort', async function () { 59 it('Should fail with an incorrect sort', async function () {
53 await checkBadSortPagination(server.url, path) 60 await checkBadSortPagination(server.url, path)
54 }) 61 })
62
63 it('Should success with the correct parameters', async function () {
64 await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 })
65 })
55 }) 66 })
56 67
57 describe('When searching a video', function () { 68 describe('When searching a video', function () {
@@ -75,6 +86,10 @@ describe('Test videos API validator', function () {
75 it('Should fail with an incorrect sort', async function () { 86 it('Should fail with an incorrect sort', async function () {
76 await checkBadSortPagination(server.url, join(path, 'search', 'test')) 87 await checkBadSortPagination(server.url, join(path, 'search', 'test'))
77 }) 88 })
89
90 it('Should success with the correct parameters', async function () {
91 await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 })
92 })
78 }) 93 })
79 94
80 describe('When listing my videos', function () { 95 describe('When listing my videos', function () {
@@ -91,6 +106,58 @@ describe('Test videos API validator', function () {
91 it('Should fail with an incorrect sort', async function () { 106 it('Should fail with an incorrect sort', async function () {
92 await checkBadSortPagination(server.url, path, server.accessToken) 107 await checkBadSortPagination(server.url, path, server.accessToken)
93 }) 108 })
109
110 it('Should success with the correct parameters', async function () {
111 await makeGetRequest({ url: server.url, token: server.accessToken, path, statusCodeExpected: 200 })
112 })
113 })
114
115 describe('When listing account videos', function () {
116 let path: string
117
118 before(async function () {
119 path = '/api/v1/accounts/' + accountUUID + '/videos'
120 })
121
122 it('Should fail with a bad start pagination', async function () {
123 await checkBadStartPagination(server.url, path, server.accessToken)
124 })
125
126 it('Should fail with a bad count pagination', async function () {
127 await checkBadCountPagination(server.url, path, server.accessToken)
128 })
129
130 it('Should fail with an incorrect sort', async function () {
131 await checkBadSortPagination(server.url, path, server.accessToken)
132 })
133
134 it('Should success with the correct parameters', async function () {
135 await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 })
136 })
137 })
138
139 describe('When listing video channel videos', function () {
140 let path: string
141
142 before(async function () {
143 path = '/api/v1/accounts/' + accountUUID + '/video-channels/' + channelUUID + '/videos'
144 })
145
146 it('Should fail with a bad start pagination', async function () {
147 await checkBadStartPagination(server.url, path, server.accessToken)
148 })
149
150 it('Should fail with a bad count pagination', async function () {
151 await checkBadCountPagination(server.url, path, server.accessToken)
152 })
153
154 it('Should fail with an incorrect sort', async function () {
155 await checkBadSortPagination(server.url, path, server.accessToken)
156 })
157
158 it('Should success with the correct parameters', async function () {
159 await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 })
160 })
94 }) 161 })
95 162
96 describe('When adding a video', function () { 163 describe('When adding a video', function () {
@@ -112,7 +179,7 @@ describe('Test videos API validator', function () {
112 support: 'my super support text', 179 support: 'my super support text',
113 tags: [ 'tag1', 'tag2' ], 180 tags: [ 'tag1', 'tag2' ],
114 privacy: VideoPrivacy.PUBLIC, 181 privacy: VideoPrivacy.PUBLIC,
115 channelId 182 channelId: channelId
116 } 183 }
117 }) 184 })
118 185