]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/check-params/video-playlists.ts
Fix audio encoding params
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / video-playlists.ts
CommitLineData
a1587156 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
418d092a 2
418d092a 3import 'mocha'
418d092a 4import {
df0b219d 5 addVideoInPlaylist,
7c3b7976 6 cleanupTests,
07b1a18a
C
7 createVideoPlaylist,
8 deleteVideoPlaylist,
7c3b7976 9 flushAndRunServer,
df0b219d
C
10 generateUserAccessToken,
11 getAccountPlaylistsListWithToken,
07b1a18a 12 getVideoPlaylist,
418d092a 13 immutableAssign,
418d092a 14 makeGetRequest,
df0b219d
C
15 removeVideoFromPlaylist,
16 reorderVideosPlaylist,
418d092a 17 ServerInfo,
7c3b7976
C
18 setAccessTokensToServers,
19 setDefaultVideoChannel,
07b1a18a 20 updateVideoPlaylist,
df0b219d
C
21 updateVideoPlaylistElement,
22 uploadVideoAndGetId
94565d52 23} from '../../../../shared/extra-utils'
418d092a
C
24import {
25 checkBadCountPagination,
26 checkBadSortPagination,
27 checkBadStartPagination
94565d52 28} from '../../../../shared/extra-utils/requests/check-api-params'
07b1a18a 29import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
df0b219d 30import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model'
418d092a
C
31
32describe('Test video playlists API validator', function () {
418d092a 33 let server: ServerInfo
df0b219d 34 let userAccessToken: string
07b1a18a 35 let playlistUUID: string
c5e4e36d 36 let privatePlaylistUUID: string
df0b219d 37 let watchLaterPlaylistId: number
07b1a18a 38 let videoId: number
bfbd9128 39 let playlistElementId: number
418d092a
C
40
41 // ---------------------------------------------------------------
42
43 before(async function () {
44 this.timeout(30000)
45
210feb6c 46 server = await flushAndRunServer(1)
418d092a
C
47
48 await setAccessTokensToServers([ server ])
c5e4e36d 49 await setDefaultVideoChannel([ server ])
418d092a 50
df0b219d
C
51 userAccessToken = await generateUserAccessToken(server, 'user1')
52 videoId = (await uploadVideoAndGetId({ server, videoName: 'video 1' })).id
07b1a18a
C
53
54 {
9d45db29 55 const res = await getAccountPlaylistsListWithToken(server.url, server.accessToken, 'root', 0, 5, VideoPlaylistType.WATCH_LATER)
df0b219d 56 watchLaterPlaylistId = res.body.data[0].id
07b1a18a
C
57 }
58
59 {
60 const res = await createVideoPlaylist({
61 url: server.url,
62 token: server.accessToken,
63 playlistAttrs: {
64 displayName: 'super playlist',
c5e4e36d
C
65 privacy: VideoPlaylistPrivacy.PUBLIC,
66 videoChannelId: server.videoChannel.id
07b1a18a
C
67 }
68 })
69 playlistUUID = res.body.videoPlaylist.uuid
70 }
c5e4e36d
C
71
72 {
73 const res = await createVideoPlaylist({
74 url: server.url,
75 token: server.accessToken,
76 playlistAttrs: {
77 displayName: 'private',
78 privacy: VideoPlaylistPrivacy.PRIVATE
79 }
80 })
81 privatePlaylistUUID = res.body.videoPlaylist.uuid
82 }
418d092a
C
83 })
84
07b1a18a 85 describe('When listing playlists', function () {
418d092a
C
86 const globalPath = '/api/v1/video-playlists'
87 const accountPath = '/api/v1/accounts/root/video-playlists'
88 const videoChannelPath = '/api/v1/video-channels/root_channel/video-playlists'
89
90 it('Should fail with a bad start pagination', async function () {
91 await checkBadStartPagination(server.url, globalPath, server.accessToken)
92 await checkBadStartPagination(server.url, accountPath, server.accessToken)
93 await checkBadStartPagination(server.url, videoChannelPath, server.accessToken)
94 })
95
96 it('Should fail with a bad count pagination', async function () {
97 await checkBadCountPagination(server.url, globalPath, server.accessToken)
98 await checkBadCountPagination(server.url, accountPath, server.accessToken)
99 await checkBadCountPagination(server.url, videoChannelPath, server.accessToken)
100 })
101
102 it('Should fail with an incorrect sort', async function () {
103 await checkBadSortPagination(server.url, globalPath, server.accessToken)
104 await checkBadSortPagination(server.url, accountPath, server.accessToken)
105 await checkBadSortPagination(server.url, videoChannelPath, server.accessToken)
106 })
107
df0b219d
C
108 it('Should fail with a bad playlist type', async function () {
109 await makeGetRequest({ url: server.url, path: globalPath, query: { playlistType: 3 } })
110 await makeGetRequest({ url: server.url, path: accountPath, query: { playlistType: 3 } })
111 await makeGetRequest({ url: server.url, path: videoChannelPath, query: { playlistType: 3 } })
112 })
113
418d092a
C
114 it('Should fail with a bad account parameter', async function () {
115 const accountPath = '/api/v1/accounts/root2/video-playlists'
116
117 await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: 404, token: server.accessToken })
118 })
119
120 it('Should fail with a bad video channel parameter', async function () {
121 const accountPath = '/api/v1/video-channels/bad_channel/video-playlists'
122
123 await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: 404, token: server.accessToken })
124 })
125
126 it('Should success with the correct parameters', async function () {
127 await makeGetRequest({ url: server.url, path: globalPath, statusCodeExpected: 200, token: server.accessToken })
128 await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: 200, token: server.accessToken })
129 await makeGetRequest({ url: server.url, path: videoChannelPath, statusCodeExpected: 200, token: server.accessToken })
130 })
131 })
132
07b1a18a 133 describe('When listing videos of a playlist', function () {
bfbd9128 134 const path = '/api/v1/video-playlists/'
418d092a
C
135
136 it('Should fail with a bad start pagination', async function () {
bfbd9128 137 await checkBadStartPagination(server.url, path + playlistUUID + '/videos', server.accessToken)
418d092a
C
138 })
139
140 it('Should fail with a bad count pagination', async function () {
bfbd9128 141 await checkBadCountPagination(server.url, path + playlistUUID + '/videos', server.accessToken)
418d092a
C
142 })
143
bfbd9128
C
144 it('Should success with the correct parameters', async function () {
145 await makeGetRequest({ url: server.url, path: path + playlistUUID + '/videos', statusCodeExpected: 200 })
418d092a
C
146 })
147 })
148
07b1a18a
C
149 describe('When getting a video playlist', function () {
150 it('Should fail with a bad id or uuid', async function () {
151 await getVideoPlaylist(server.url, 'toto', 400)
152 })
153
154 it('Should fail with an unknown playlist', async function () {
155 await getVideoPlaylist(server.url, 42, 404)
156 })
157
158 it('Should fail to get an unlisted playlist with the number id', async function () {
159 const res = await createVideoPlaylist({
160 url: server.url,
161 token: server.accessToken,
162 playlistAttrs: {
163 displayName: 'super playlist',
164 privacy: VideoPlaylistPrivacy.UNLISTED
165 }
166 })
167 const playlist = res.body.videoPlaylist
168
169 await getVideoPlaylist(server.url, playlist.id, 404)
170 await getVideoPlaylist(server.url, playlist.uuid, 200)
171 })
172
173 it('Should succeed with the correct params', async function () {
174 await getVideoPlaylist(server.url, playlistUUID, 200)
175 })
176 })
177
178 describe('When creating/updating a video playlist', function () {
df0b219d
C
179 const getBase = (playlistAttrs: any = {}, wrapper: any = {}) => {
180 return Object.assign({
181 expectedStatus: 400,
182 url: server.url,
183 token: server.accessToken,
184 playlistAttrs: Object.assign({
185 displayName: 'display name',
186 privacy: VideoPlaylistPrivacy.UNLISTED,
c5e4e36d
C
187 thumbnailfile: 'thumbnail.jpg',
188 videoChannelId: server.videoChannel.id
df0b219d
C
189 }, playlistAttrs)
190 }, wrapper)
191 }
192 const getUpdate = (params: any, playlistId: number | string) => {
193 return immutableAssign(params, { playlistId: playlistId })
194 }
07b1a18a
C
195
196 it('Should fail with an unauthenticated user', async function () {
df0b219d 197 const params = getBase({}, { token: null, expectedStatus: 401 })
07b1a18a 198
df0b219d
C
199 await createVideoPlaylist(params)
200 await updateVideoPlaylist(getUpdate(params, playlistUUID))
07b1a18a
C
201 })
202
203 it('Should fail without displayName', async function () {
df0b219d 204 const params = getBase({ displayName: undefined })
07b1a18a 205
df0b219d 206 await createVideoPlaylist(params)
07b1a18a
C
207 })
208
209 it('Should fail with an incorrect display name', async function () {
df0b219d 210 const params = getBase({ displayName: 's'.repeat(300) })
07b1a18a 211
df0b219d
C
212 await createVideoPlaylist(params)
213 await updateVideoPlaylist(getUpdate(params, playlistUUID))
07b1a18a
C
214 })
215
216 it('Should fail with an incorrect description', async function () {
df0b219d 217 const params = getBase({ description: 't' })
07b1a18a 218
df0b219d
C
219 await createVideoPlaylist(params)
220 await updateVideoPlaylist(getUpdate(params, playlistUUID))
07b1a18a
C
221 })
222
223 it('Should fail with an incorrect privacy', async function () {
df0b219d 224 const params = getBase({ privacy: 45 })
07b1a18a 225
df0b219d
C
226 await createVideoPlaylist(params)
227 await updateVideoPlaylist(getUpdate(params, playlistUUID))
07b1a18a
C
228 })
229
230 it('Should fail with an unknown video channel id', async function () {
df0b219d 231 const params = getBase({ videoChannelId: 42 }, { expectedStatus: 404 })
07b1a18a 232
df0b219d
C
233 await createVideoPlaylist(params)
234 await updateVideoPlaylist(getUpdate(params, playlistUUID))
07b1a18a
C
235 })
236
237 it('Should fail with an incorrect thumbnail file', async function () {
df0b219d 238 const params = getBase({ thumbnailfile: 'avatar.png' })
07b1a18a 239
df0b219d
C
240 await createVideoPlaylist(params)
241 await updateVideoPlaylist(getUpdate(params, playlistUUID))
07b1a18a
C
242 })
243
c5e4e36d
C
244 it('Should fail to set "public" a playlist not assigned to a channel', async function () {
245 const params = getBase({ privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: undefined })
246 const params2 = getBase({ privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: 'null' })
247 const params3 = getBase({ privacy: undefined, videoChannelId: 'null' })
248
249 await createVideoPlaylist(params)
250 await createVideoPlaylist(params2)
251 await updateVideoPlaylist(getUpdate(params, privatePlaylistUUID))
252 await updateVideoPlaylist(getUpdate(params2, playlistUUID))
253 await updateVideoPlaylist(getUpdate(params3, playlistUUID))
254 })
255
07b1a18a 256 it('Should fail with an unknown playlist to update', async function () {
df0b219d
C
257 await updateVideoPlaylist(getUpdate(
258 getBase({}, { expectedStatus: 404 }),
259 42
260 ))
07b1a18a
C
261 })
262
263 it('Should fail to update a playlist of another user', async function () {
df0b219d
C
264 await updateVideoPlaylist(getUpdate(
265 getBase({}, { token: userAccessToken, expectedStatus: 403 }),
266 playlistUUID
267 ))
07b1a18a
C
268 })
269
df0b219d
C
270 it('Should fail to update the watch later playlist', async function () {
271 await updateVideoPlaylist(getUpdate(
c5e4e36d 272 getBase({}, { expectedStatus: 400 }),
df0b219d
C
273 watchLaterPlaylistId
274 ))
07b1a18a
C
275 })
276
277 it('Should succeed with the correct params', async function () {
df0b219d
C
278 {
279 const params = getBase({}, { expectedStatus: 200 })
280 await createVideoPlaylist(params)
07b1a18a
C
281 }
282
df0b219d
C
283 {
284 const params = getBase({}, { expectedStatus: 204 })
285 await updateVideoPlaylist(getUpdate(params, playlistUUID))
286 }
07b1a18a
C
287 })
288 })
289
290 describe('When adding an element in a playlist', function () {
df0b219d
C
291 const getBase = (elementAttrs: any = {}, wrapper: any = {}) => {
292 return Object.assign({
293 expectedStatus: 400,
07b1a18a 294 url: server.url,
df0b219d 295 token: server.accessToken,
07b1a18a 296 playlistId: playlistUUID,
df0b219d 297 elementAttrs: Object.assign({
bfbd9128 298 videoId,
df0b219d
C
299 startTimestamp: 2,
300 stopTimestamp: 3
301 }, elementAttrs)
302 }, wrapper)
303 }
304
305 it('Should fail with an unauthenticated user', async function () {
306 const params = getBase({}, { token: null, expectedStatus: 401 })
307 await addVideoInPlaylist(params)
07b1a18a
C
308 })
309
310 it('Should fail with the playlist of another user', async function () {
df0b219d
C
311 const params = getBase({}, { token: userAccessToken, expectedStatus: 403 })
312 await addVideoInPlaylist(params)
07b1a18a
C
313 })
314
315 it('Should fail with an unknown or incorrect playlist id', async function () {
df0b219d
C
316 {
317 const params = getBase({}, { playlistId: 'toto' })
318 await addVideoInPlaylist(params)
319 }
07b1a18a 320
df0b219d
C
321 {
322 const params = getBase({}, { playlistId: 42, expectedStatus: 404 })
323 await addVideoInPlaylist(params)
324 }
07b1a18a
C
325 })
326
327 it('Should fail with an unknown or incorrect video id', async function () {
df0b219d
C
328 const params = getBase({ videoId: 42 }, { expectedStatus: 404 })
329 await addVideoInPlaylist(params)
07b1a18a
C
330 })
331
332 it('Should fail with a bad start/stop timestamp', async function () {
df0b219d
C
333 {
334 const params = getBase({ startTimestamp: -42 })
335 await addVideoInPlaylist(params)
336 }
07b1a18a 337
df0b219d
C
338 {
339 const params = getBase({ stopTimestamp: 'toto' as any })
340 await addVideoInPlaylist(params)
341 }
07b1a18a
C
342 })
343
344 it('Succeed with the correct params', async function () {
df0b219d 345 const params = getBase({}, { expectedStatus: 200 })
bfbd9128
C
346 const res = await addVideoInPlaylist(params)
347 playlistElementId = res.body.videoPlaylistElement.id
07b1a18a 348 })
07b1a18a
C
349 })
350
351 describe('When updating an element in a playlist', function () {
df0b219d
C
352 const getBase = (elementAttrs: any = {}, wrapper: any = {}) => {
353 return Object.assign({
07b1a18a 354 url: server.url,
df0b219d
C
355 token: server.accessToken,
356 elementAttrs: Object.assign({
357 startTimestamp: 1,
358 stopTimestamp: 2
359 }, elementAttrs),
bfbd9128 360 playlistElementId,
07b1a18a 361 playlistId: playlistUUID,
df0b219d
C
362 expectedStatus: 400
363 }, wrapper)
364 }
365
366 it('Should fail with an unauthenticated user', async function () {
367 const params = getBase({}, { token: null, expectedStatus: 401 })
368 await updateVideoPlaylistElement(params)
07b1a18a
C
369 })
370
371 it('Should fail with the playlist of another user', async function () {
df0b219d
C
372 const params = getBase({}, { token: userAccessToken, expectedStatus: 403 })
373 await updateVideoPlaylistElement(params)
07b1a18a
C
374 })
375
376 it('Should fail with an unknown or incorrect playlist id', async function () {
df0b219d
C
377 {
378 const params = getBase({}, { playlistId: 'toto' })
379 await updateVideoPlaylistElement(params)
380 }
07b1a18a 381
df0b219d
C
382 {
383 const params = getBase({}, { playlistId: 42, expectedStatus: 404 })
384 await updateVideoPlaylistElement(params)
385 }
07b1a18a
C
386 })
387
bfbd9128 388 it('Should fail with an unknown or incorrect playlistElement id', async function () {
df0b219d 389 {
bfbd9128 390 const params = getBase({}, { playlistElementId: 'toto' })
df0b219d
C
391 await updateVideoPlaylistElement(params)
392 }
07b1a18a 393
df0b219d 394 {
bfbd9128 395 const params = getBase({}, { playlistElementId: 42, expectedStatus: 404 })
df0b219d
C
396 await updateVideoPlaylistElement(params)
397 }
07b1a18a
C
398 })
399
400 it('Should fail with a bad start/stop timestamp', async function () {
df0b219d
C
401 {
402 const params = getBase({ startTimestamp: 'toto' as any })
403 await updateVideoPlaylistElement(params)
404 }
07b1a18a 405
df0b219d
C
406 {
407 const params = getBase({ stopTimestamp: -42 })
408 await updateVideoPlaylistElement(params)
409 }
07b1a18a
C
410 })
411
412 it('Should fail with an unknown element', async function () {
bfbd9128 413 const params = getBase({}, { playlistElementId: 888, expectedStatus: 404 })
df0b219d 414 await updateVideoPlaylistElement(params)
07b1a18a
C
415 })
416
417 it('Succeed with the correct params', async function () {
df0b219d
C
418 const params = getBase({}, { expectedStatus: 204 })
419 await updateVideoPlaylistElement(params)
07b1a18a
C
420 })
421 })
422
423 describe('When reordering elements of a playlist', function () {
424 let videoId3: number
425 let videoId4: number
426
df0b219d
C
427 const getBase = (elementAttrs: any = {}, wrapper: any = {}) => {
428 return Object.assign({
07b1a18a
C
429 url: server.url,
430 token: server.accessToken,
431 playlistId: playlistUUID,
df0b219d
C
432 elementAttrs: Object.assign({
433 startPosition: 1,
434 insertAfterPosition: 2,
435 reorderLength: 3
436 }, elementAttrs),
437 expectedStatus: 400
438 }, wrapper)
439 }
07b1a18a 440
df0b219d
C
441 before(async function () {
442 videoId3 = (await uploadVideoAndGetId({ server, videoName: 'video 3' })).id
443 videoId4 = (await uploadVideoAndGetId({ server, videoName: 'video 4' })).id
444
a1587156 445 for (const id of [ videoId3, videoId4 ]) {
df0b219d
C
446 await addVideoInPlaylist({
447 url: server.url,
448 token: server.accessToken,
449 playlistId: playlistUUID,
450 elementAttrs: { videoId: id }
451 })
452 }
07b1a18a
C
453 })
454
455 it('Should fail with an unauthenticated user', async function () {
df0b219d
C
456 const params = getBase({}, { token: null, expectedStatus: 401 })
457 await reorderVideosPlaylist(params)
07b1a18a
C
458 })
459
460 it('Should fail with the playlist of another user', async function () {
df0b219d
C
461 const params = getBase({}, { token: userAccessToken, expectedStatus: 403 })
462 await reorderVideosPlaylist(params)
07b1a18a
C
463 })
464
465 it('Should fail with an invalid playlist', async function () {
df0b219d
C
466 {
467 const params = getBase({}, { playlistId: 'toto' })
468 await reorderVideosPlaylist(params)
469 }
07b1a18a 470
df0b219d 471 {
a1587156 472 const params = getBase({}, { playlistId: 42, expectedStatus: 404 })
df0b219d
C
473 await reorderVideosPlaylist(params)
474 }
07b1a18a
C
475 })
476
477 it('Should fail with an invalid start position', async function () {
df0b219d
C
478 {
479 const params = getBase({ startPosition: -1 })
480 await reorderVideosPlaylist(params)
481 }
07b1a18a 482
df0b219d
C
483 {
484 const params = getBase({ startPosition: 'toto' as any })
485 await reorderVideosPlaylist(params)
486 }
07b1a18a 487
df0b219d
C
488 {
489 const params = getBase({ startPosition: 42 })
490 await reorderVideosPlaylist(params)
491 }
07b1a18a
C
492 })
493
494 it('Should fail with an invalid insert after position', async function () {
df0b219d
C
495 {
496 const params = getBase({ insertAfterPosition: 'toto' as any })
497 await reorderVideosPlaylist(params)
498 }
07b1a18a 499
df0b219d
C
500 {
501 const params = getBase({ insertAfterPosition: -2 })
502 await reorderVideosPlaylist(params)
503 }
07b1a18a 504
df0b219d
C
505 {
506 const params = getBase({ insertAfterPosition: 42 })
507 await reorderVideosPlaylist(params)
508 }
07b1a18a
C
509 })
510
511 it('Should fail with an invalid reorder length', async function () {
df0b219d
C
512 {
513 const params = getBase({ reorderLength: 'toto' as any })
514 await reorderVideosPlaylist(params)
515 }
07b1a18a 516
df0b219d
C
517 {
518 const params = getBase({ reorderLength: -2 })
519 await reorderVideosPlaylist(params)
520 }
07b1a18a 521
df0b219d
C
522 {
523 const params = getBase({ reorderLength: 42 })
524 await reorderVideosPlaylist(params)
525 }
07b1a18a
C
526 })
527
528 it('Succeed with the correct params', async function () {
df0b219d
C
529 const params = getBase({}, { expectedStatus: 204 })
530 await reorderVideosPlaylist(params)
07b1a18a
C
531 })
532 })
533
0b16f5f2
C
534 describe('When checking exists in playlist endpoint', function () {
535 const path = '/api/v1/users/me/video-playlists/videos-exist'
536
537 it('Should fail with an unauthenticated user', async function () {
538 await makeGetRequest({
539 url: server.url,
540 path,
541 query: { videoIds: [ 1, 2 ] },
542 statusCodeExpected: 401
543 })
544 })
545
546 it('Should fail with invalid video ids', async function () {
547 await makeGetRequest({
548 url: server.url,
549 token: server.accessToken,
550 path,
551 query: { videoIds: 'toto' }
552 })
553
554 await makeGetRequest({
555 url: server.url,
556 token: server.accessToken,
557 path,
558 query: { videoIds: [ 'toto' ] }
559 })
560
561 await makeGetRequest({
562 url: server.url,
563 token: server.accessToken,
564 path,
565 query: { videoIds: [ 1, 'toto' ] }
566 })
567 })
568
569 it('Should succeed with the correct params', async function () {
570 await makeGetRequest({
571 url: server.url,
572 token: server.accessToken,
573 path,
574 query: { videoIds: [ 1, 2 ] },
575 statusCodeExpected: 200
576 })
577 })
578 })
579
07b1a18a 580 describe('When deleting an element in a playlist', function () {
df0b219d
C
581 const getBase = (wrapper: any = {}) => {
582 return Object.assign({
07b1a18a 583 url: server.url,
df0b219d 584 token: server.accessToken,
bfbd9128 585 playlistElementId,
07b1a18a 586 playlistId: playlistUUID,
df0b219d
C
587 expectedStatus: 400
588 }, wrapper)
589 }
590
591 it('Should fail with an unauthenticated user', async function () {
592 const params = getBase({ token: null, expectedStatus: 401 })
593 await removeVideoFromPlaylist(params)
07b1a18a
C
594 })
595
596 it('Should fail with the playlist of another user', async function () {
df0b219d
C
597 const params = getBase({ token: userAccessToken, expectedStatus: 403 })
598 await removeVideoFromPlaylist(params)
07b1a18a
C
599 })
600
601 it('Should fail with an unknown or incorrect playlist id', async function () {
df0b219d
C
602 {
603 const params = getBase({ playlistId: 'toto' })
604 await removeVideoFromPlaylist(params)
605 }
07b1a18a 606
df0b219d
C
607 {
608 const params = getBase({ playlistId: 42, expectedStatus: 404 })
609 await removeVideoFromPlaylist(params)
610 }
07b1a18a
C
611 })
612
613 it('Should fail with an unknown or incorrect video id', async function () {
df0b219d 614 {
bfbd9128 615 const params = getBase({ playlistElementId: 'toto' })
df0b219d
C
616 await removeVideoFromPlaylist(params)
617 }
07b1a18a 618
df0b219d 619 {
bfbd9128 620 const params = getBase({ playlistElementId: 42, expectedStatus: 404 })
df0b219d
C
621 await removeVideoFromPlaylist(params)
622 }
07b1a18a
C
623 })
624
625 it('Should fail with an unknown element', async function () {
bfbd9128 626 const params = getBase({ playlistElementId: 888, expectedStatus: 404 })
df0b219d 627 await removeVideoFromPlaylist(params)
07b1a18a
C
628 })
629
630 it('Succeed with the correct params', async function () {
df0b219d
C
631 const params = getBase({ expectedStatus: 204 })
632 await removeVideoFromPlaylist(params)
07b1a18a
C
633 })
634 })
635
636 describe('When deleting a playlist', function () {
637 it('Should fail with an unknown playlist', async function () {
638 await deleteVideoPlaylist(server.url, server.accessToken, 42, 404)
639 })
640
641 it('Should fail with a playlist of another user', async function () {
642 await deleteVideoPlaylist(server.url, userAccessToken, playlistUUID, 403)
643 })
644
df0b219d 645 it('Should fail with the watch later playlist', async function () {
c5e4e36d 646 await deleteVideoPlaylist(server.url, server.accessToken, watchLaterPlaylistId, 400)
df0b219d
C
647 })
648
07b1a18a
C
649 it('Should succeed with the correct params', async function () {
650 await deleteVideoPlaylist(server.url, server.accessToken, playlistUUID)
651 })
652 })
653
7c3b7976
C
654 after(async function () {
655 await cleanupTests([ server ])
418d092a
C
656 })
657})