diff options
Diffstat (limited to 'server/tests/api/check-params/video-playlists.ts')
-rw-r--r-- | server/tests/api/check-params/video-playlists.ts | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts index bbea88354..18253d11a 100644 --- a/server/tests/api/check-params/video-playlists.ts +++ b/server/tests/api/check-params/video-playlists.ts | |||
@@ -1,8 +1,13 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { VideoPlaylistCreateResult, VideoPlaylistPrivacy, VideoPlaylistType } from '@shared/models' | ||
5 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
4 | import { | 6 | import { |
5 | addVideoInPlaylist, | 7 | addVideoInPlaylist, |
8 | checkBadCountPagination, | ||
9 | checkBadSortPagination, | ||
10 | checkBadStartPagination, | ||
6 | cleanupTests, | 11 | cleanupTests, |
7 | createVideoPlaylist, | 12 | createVideoPlaylist, |
8 | deleteVideoPlaylist, | 13 | deleteVideoPlaylist, |
@@ -21,20 +26,14 @@ import { | |||
21 | updateVideoPlaylistElement, | 26 | updateVideoPlaylistElement, |
22 | uploadVideoAndGetId | 27 | uploadVideoAndGetId |
23 | } from '../../../../shared/extra-utils' | 28 | } from '../../../../shared/extra-utils' |
24 | import { | ||
25 | checkBadCountPagination, | ||
26 | checkBadSortPagination, | ||
27 | checkBadStartPagination | ||
28 | } from '../../../../shared/extra-utils/requests/check-api-params' | ||
29 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | ||
30 | import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' | ||
31 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
32 | 29 | ||
33 | describe('Test video playlists API validator', function () { | 30 | describe('Test video playlists API validator', function () { |
34 | let server: ServerInfo | 31 | let server: ServerInfo |
35 | let userAccessToken: string | 32 | let userAccessToken: string |
36 | let playlistUUID: string | 33 | |
34 | let playlist: VideoPlaylistCreateResult | ||
37 | let privatePlaylistUUID: string | 35 | let privatePlaylistUUID: string |
36 | |||
38 | let watchLaterPlaylistId: number | 37 | let watchLaterPlaylistId: number |
39 | let videoId: number | 38 | let videoId: number |
40 | let playlistElementId: number | 39 | let playlistElementId: number |
@@ -67,7 +66,7 @@ describe('Test video playlists API validator', function () { | |||
67 | videoChannelId: server.videoChannel.id | 66 | videoChannelId: server.videoChannel.id |
68 | } | 67 | } |
69 | }) | 68 | }) |
70 | playlistUUID = res.body.videoPlaylist.uuid | 69 | playlist = res.body.videoPlaylist |
71 | } | 70 | } |
72 | 71 | ||
73 | { | 72 | { |
@@ -150,15 +149,15 @@ describe('Test video playlists API validator', function () { | |||
150 | const path = '/api/v1/video-playlists/' | 149 | const path = '/api/v1/video-playlists/' |
151 | 150 | ||
152 | it('Should fail with a bad start pagination', async function () { | 151 | it('Should fail with a bad start pagination', async function () { |
153 | await checkBadStartPagination(server.url, path + playlistUUID + '/videos', server.accessToken) | 152 | await checkBadStartPagination(server.url, path + playlist.shortUUID + '/videos', server.accessToken) |
154 | }) | 153 | }) |
155 | 154 | ||
156 | it('Should fail with a bad count pagination', async function () { | 155 | it('Should fail with a bad count pagination', async function () { |
157 | await checkBadCountPagination(server.url, path + playlistUUID + '/videos', server.accessToken) | 156 | await checkBadCountPagination(server.url, path + playlist.shortUUID + '/videos', server.accessToken) |
158 | }) | 157 | }) |
159 | 158 | ||
160 | it('Should success with the correct parameters', async function () { | 159 | it('Should success with the correct parameters', async function () { |
161 | await makeGetRequest({ url: server.url, path: path + playlistUUID + '/videos', statusCodeExpected: HttpStatusCode.OK_200 }) | 160 | await makeGetRequest({ url: server.url, path: path + playlist.shortUUID + '/videos', statusCodeExpected: HttpStatusCode.OK_200 }) |
162 | }) | 161 | }) |
163 | }) | 162 | }) |
164 | 163 | ||
@@ -177,6 +176,7 @@ describe('Test video playlists API validator', function () { | |||
177 | token: server.accessToken, | 176 | token: server.accessToken, |
178 | playlistAttrs: { | 177 | playlistAttrs: { |
179 | displayName: 'super playlist', | 178 | displayName: 'super playlist', |
179 | videoChannelId: server.videoChannel.id, | ||
180 | privacy: VideoPlaylistPrivacy.UNLISTED | 180 | privacy: VideoPlaylistPrivacy.UNLISTED |
181 | } | 181 | } |
182 | }) | 182 | }) |
@@ -187,7 +187,7 @@ describe('Test video playlists API validator', function () { | |||
187 | }) | 187 | }) |
188 | 188 | ||
189 | it('Should succeed with the correct params', async function () { | 189 | it('Should succeed with the correct params', async function () { |
190 | await getVideoPlaylist(server.url, playlistUUID, HttpStatusCode.OK_200) | 190 | await getVideoPlaylist(server.url, playlist.uuid, HttpStatusCode.OK_200) |
191 | }) | 191 | }) |
192 | }) | 192 | }) |
193 | 193 | ||
@@ -213,7 +213,7 @@ describe('Test video playlists API validator', function () { | |||
213 | const params = getBase({}, { token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) | 213 | const params = getBase({}, { token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
214 | 214 | ||
215 | await createVideoPlaylist(params) | 215 | await createVideoPlaylist(params) |
216 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 216 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
217 | }) | 217 | }) |
218 | 218 | ||
219 | it('Should fail without displayName', async function () { | 219 | it('Should fail without displayName', async function () { |
@@ -226,42 +226,42 @@ describe('Test video playlists API validator', function () { | |||
226 | const params = getBase({ displayName: 's'.repeat(300) }) | 226 | const params = getBase({ displayName: 's'.repeat(300) }) |
227 | 227 | ||
228 | await createVideoPlaylist(params) | 228 | await createVideoPlaylist(params) |
229 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 229 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
230 | }) | 230 | }) |
231 | 231 | ||
232 | it('Should fail with an incorrect description', async function () { | 232 | it('Should fail with an incorrect description', async function () { |
233 | const params = getBase({ description: 't' }) | 233 | const params = getBase({ description: 't' }) |
234 | 234 | ||
235 | await createVideoPlaylist(params) | 235 | await createVideoPlaylist(params) |
236 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 236 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
237 | }) | 237 | }) |
238 | 238 | ||
239 | it('Should fail with an incorrect privacy', async function () { | 239 | it('Should fail with an incorrect privacy', async function () { |
240 | const params = getBase({ privacy: 45 }) | 240 | const params = getBase({ privacy: 45 }) |
241 | 241 | ||
242 | await createVideoPlaylist(params) | 242 | await createVideoPlaylist(params) |
243 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 243 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
244 | }) | 244 | }) |
245 | 245 | ||
246 | it('Should fail with an unknown video channel id', async function () { | 246 | it('Should fail with an unknown video channel id', async function () { |
247 | const params = getBase({ videoChannelId: 42 }, { expectedStatus: HttpStatusCode.NOT_FOUND_404 }) | 247 | const params = getBase({ videoChannelId: 42 }, { expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
248 | 248 | ||
249 | await createVideoPlaylist(params) | 249 | await createVideoPlaylist(params) |
250 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 250 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
251 | }) | 251 | }) |
252 | 252 | ||
253 | it('Should fail with an incorrect thumbnail file', async function () { | 253 | it('Should fail with an incorrect thumbnail file', async function () { |
254 | const params = getBase({ thumbnailfile: 'video_short.mp4' }) | 254 | const params = getBase({ thumbnailfile: 'video_short.mp4' }) |
255 | 255 | ||
256 | await createVideoPlaylist(params) | 256 | await createVideoPlaylist(params) |
257 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 257 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
258 | }) | 258 | }) |
259 | 259 | ||
260 | it('Should fail with a thumbnail file too big', async function () { | 260 | it('Should fail with a thumbnail file too big', async function () { |
261 | const params = getBase({ thumbnailfile: 'preview-big.png' }) | 261 | const params = getBase({ thumbnailfile: 'preview-big.png' }) |
262 | 262 | ||
263 | await createVideoPlaylist(params) | 263 | await createVideoPlaylist(params) |
264 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 264 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
265 | }) | 265 | }) |
266 | 266 | ||
267 | it('Should fail to set "public" a playlist not assigned to a channel', async function () { | 267 | it('Should fail to set "public" a playlist not assigned to a channel', async function () { |
@@ -272,8 +272,8 @@ describe('Test video playlists API validator', function () { | |||
272 | await createVideoPlaylist(params) | 272 | await createVideoPlaylist(params) |
273 | await createVideoPlaylist(params2) | 273 | await createVideoPlaylist(params2) |
274 | await updateVideoPlaylist(getUpdate(params, privatePlaylistUUID)) | 274 | await updateVideoPlaylist(getUpdate(params, privatePlaylistUUID)) |
275 | await updateVideoPlaylist(getUpdate(params2, playlistUUID)) | 275 | await updateVideoPlaylist(getUpdate(params2, playlist.shortUUID)) |
276 | await updateVideoPlaylist(getUpdate(params3, playlistUUID)) | 276 | await updateVideoPlaylist(getUpdate(params3, playlist.shortUUID)) |
277 | }) | 277 | }) |
278 | 278 | ||
279 | it('Should fail with an unknown playlist to update', async function () { | 279 | it('Should fail with an unknown playlist to update', async function () { |
@@ -286,7 +286,7 @@ describe('Test video playlists API validator', function () { | |||
286 | it('Should fail to update a playlist of another user', async function () { | 286 | it('Should fail to update a playlist of another user', async function () { |
287 | await updateVideoPlaylist(getUpdate( | 287 | await updateVideoPlaylist(getUpdate( |
288 | getBase({}, { token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }), | 288 | getBase({}, { token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }), |
289 | playlistUUID | 289 | playlist.shortUUID |
290 | )) | 290 | )) |
291 | }) | 291 | }) |
292 | 292 | ||
@@ -305,7 +305,7 @@ describe('Test video playlists API validator', function () { | |||
305 | 305 | ||
306 | { | 306 | { |
307 | const params = getBase({}, { expectedStatus: HttpStatusCode.NO_CONTENT_204 }) | 307 | const params = getBase({}, { expectedStatus: HttpStatusCode.NO_CONTENT_204 }) |
308 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | 308 | await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) |
309 | } | 309 | } |
310 | }) | 310 | }) |
311 | }) | 311 | }) |
@@ -316,7 +316,7 @@ describe('Test video playlists API validator', function () { | |||
316 | expectedStatus: HttpStatusCode.BAD_REQUEST_400, | 316 | expectedStatus: HttpStatusCode.BAD_REQUEST_400, |
317 | url: server.url, | 317 | url: server.url, |
318 | token: server.accessToken, | 318 | token: server.accessToken, |
319 | playlistId: playlistUUID, | 319 | playlistId: playlist.id, |
320 | elementAttrs: Object.assign({ | 320 | elementAttrs: Object.assign({ |
321 | videoId, | 321 | videoId, |
322 | startTimestamp: 2, | 322 | startTimestamp: 2, |
@@ -381,7 +381,7 @@ describe('Test video playlists API validator', function () { | |||
381 | stopTimestamp: 2 | 381 | stopTimestamp: 2 |
382 | }, elementAttrs), | 382 | }, elementAttrs), |
383 | playlistElementId, | 383 | playlistElementId, |
384 | playlistId: playlistUUID, | 384 | playlistId: playlist.id, |
385 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | 385 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
386 | }, wrapper) | 386 | }, wrapper) |
387 | } | 387 | } |
@@ -451,7 +451,7 @@ describe('Test video playlists API validator', function () { | |||
451 | return Object.assign({ | 451 | return Object.assign({ |
452 | url: server.url, | 452 | url: server.url, |
453 | token: server.accessToken, | 453 | token: server.accessToken, |
454 | playlistId: playlistUUID, | 454 | playlistId: playlist.shortUUID, |
455 | elementAttrs: Object.assign({ | 455 | elementAttrs: Object.assign({ |
456 | startPosition: 1, | 456 | startPosition: 1, |
457 | insertAfterPosition: 2, | 457 | insertAfterPosition: 2, |
@@ -469,7 +469,7 @@ describe('Test video playlists API validator', function () { | |||
469 | await addVideoInPlaylist({ | 469 | await addVideoInPlaylist({ |
470 | url: server.url, | 470 | url: server.url, |
471 | token: server.accessToken, | 471 | token: server.accessToken, |
472 | playlistId: playlistUUID, | 472 | playlistId: playlist.shortUUID, |
473 | elementAttrs: { videoId: id } | 473 | elementAttrs: { videoId: id } |
474 | }) | 474 | }) |
475 | } | 475 | } |
@@ -606,7 +606,7 @@ describe('Test video playlists API validator', function () { | |||
606 | url: server.url, | 606 | url: server.url, |
607 | token: server.accessToken, | 607 | token: server.accessToken, |
608 | playlistElementId, | 608 | playlistElementId, |
609 | playlistId: playlistUUID, | 609 | playlistId: playlist.uuid, |
610 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | 610 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
611 | }, wrapper) | 611 | }, wrapper) |
612 | } | 612 | } |
@@ -662,7 +662,7 @@ describe('Test video playlists API validator', function () { | |||
662 | }) | 662 | }) |
663 | 663 | ||
664 | it('Should fail with a playlist of another user', async function () { | 664 | it('Should fail with a playlist of another user', async function () { |
665 | await deleteVideoPlaylist(server.url, userAccessToken, playlistUUID, HttpStatusCode.FORBIDDEN_403) | 665 | await deleteVideoPlaylist(server.url, userAccessToken, playlist.uuid, HttpStatusCode.FORBIDDEN_403) |
666 | }) | 666 | }) |
667 | 667 | ||
668 | it('Should fail with the watch later playlist', async function () { | 668 | it('Should fail with the watch later playlist', async function () { |
@@ -670,7 +670,7 @@ describe('Test video playlists API validator', function () { | |||
670 | }) | 670 | }) |
671 | 671 | ||
672 | it('Should succeed with the correct params', async function () { | 672 | it('Should succeed with the correct params', async function () { |
673 | await deleteVideoPlaylist(server.url, server.accessToken, playlistUUID) | 673 | await deleteVideoPlaylist(server.url, server.accessToken, playlist.uuid) |
674 | }) | 674 | }) |
675 | }) | 675 | }) |
676 | 676 | ||