diff options
Diffstat (limited to 'server/tests/api/check-params/video-playlists.ts')
-rw-r--r-- | server/tests/api/check-params/video-playlists.ts | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts index 8c5e44bdd..ae5aa287f 100644 --- a/server/tests/api/check-params/video-playlists.ts +++ b/server/tests/api/check-params/video-playlists.ts | |||
@@ -37,6 +37,7 @@ describe('Test video playlists API validator', function () { | |||
37 | let watchLaterPlaylistId: number | 37 | let watchLaterPlaylistId: number |
38 | let videoId: number | 38 | let videoId: number |
39 | let videoId2: number | 39 | let videoId2: number |
40 | let playlistElementId: number | ||
40 | 41 | ||
41 | // --------------------------------------------------------------- | 42 | // --------------------------------------------------------------- |
42 | 43 | ||
@@ -132,18 +133,18 @@ describe('Test video playlists API validator', function () { | |||
132 | }) | 133 | }) |
133 | 134 | ||
134 | describe('When listing videos of a playlist', function () { | 135 | describe('When listing videos of a playlist', function () { |
135 | const path = '/api/v1/video-playlists' | 136 | const path = '/api/v1/video-playlists/' |
136 | 137 | ||
137 | it('Should fail with a bad start pagination', async function () { | 138 | it('Should fail with a bad start pagination', async function () { |
138 | await checkBadStartPagination(server.url, path, server.accessToken) | 139 | await checkBadStartPagination(server.url, path + playlistUUID + '/videos', server.accessToken) |
139 | }) | 140 | }) |
140 | 141 | ||
141 | it('Should fail with a bad count pagination', async function () { | 142 | it('Should fail with a bad count pagination', async function () { |
142 | await checkBadCountPagination(server.url, path, server.accessToken) | 143 | await checkBadCountPagination(server.url, path + playlistUUID + '/videos', server.accessToken) |
143 | }) | 144 | }) |
144 | 145 | ||
145 | it('Should fail with a bad filter', async function () { | 146 | it('Should success with the correct parameters', async function () { |
146 | await checkBadSortPagination(server.url, path, server.accessToken) | 147 | await makeGetRequest({ url: server.url, path: path + playlistUUID + '/videos', statusCodeExpected: 200 }) |
147 | }) | 148 | }) |
148 | }) | 149 | }) |
149 | 150 | ||
@@ -296,7 +297,7 @@ describe('Test video playlists API validator', function () { | |||
296 | token: server.accessToken, | 297 | token: server.accessToken, |
297 | playlistId: playlistUUID, | 298 | playlistId: playlistUUID, |
298 | elementAttrs: Object.assign({ | 299 | elementAttrs: Object.assign({ |
299 | videoId: videoId, | 300 | videoId, |
300 | startTimestamp: 2, | 301 | startTimestamp: 2, |
301 | stopTimestamp: 3 | 302 | stopTimestamp: 3 |
302 | }, elementAttrs) | 303 | }, elementAttrs) |
@@ -344,7 +345,8 @@ describe('Test video playlists API validator', function () { | |||
344 | 345 | ||
345 | it('Succeed with the correct params', async function () { | 346 | it('Succeed with the correct params', async function () { |
346 | const params = getBase({}, { expectedStatus: 200 }) | 347 | const params = getBase({}, { expectedStatus: 200 }) |
347 | await addVideoInPlaylist(params) | 348 | const res = await addVideoInPlaylist(params) |
349 | playlistElementId = res.body.videoPlaylistElement.id | ||
348 | }) | 350 | }) |
349 | 351 | ||
350 | it('Should fail if the video was already added in the playlist', async function () { | 352 | it('Should fail if the video was already added in the playlist', async function () { |
@@ -362,7 +364,7 @@ describe('Test video playlists API validator', function () { | |||
362 | startTimestamp: 1, | 364 | startTimestamp: 1, |
363 | stopTimestamp: 2 | 365 | stopTimestamp: 2 |
364 | }, elementAttrs), | 366 | }, elementAttrs), |
365 | videoId: videoId, | 367 | playlistElementId, |
366 | playlistId: playlistUUID, | 368 | playlistId: playlistUUID, |
367 | expectedStatus: 400 | 369 | expectedStatus: 400 |
368 | }, wrapper) | 370 | }, wrapper) |
@@ -390,14 +392,14 @@ describe('Test video playlists API validator', function () { | |||
390 | } | 392 | } |
391 | }) | 393 | }) |
392 | 394 | ||
393 | it('Should fail with an unknown or incorrect video id', async function () { | 395 | it('Should fail with an unknown or incorrect playlistElement id', async function () { |
394 | { | 396 | { |
395 | const params = getBase({}, { videoId: 'toto' }) | 397 | const params = getBase({}, { playlistElementId: 'toto' }) |
396 | await updateVideoPlaylistElement(params) | 398 | await updateVideoPlaylistElement(params) |
397 | } | 399 | } |
398 | 400 | ||
399 | { | 401 | { |
400 | const params = getBase({}, { videoId: 42, expectedStatus: 404 }) | 402 | const params = getBase({}, { playlistElementId: 42, expectedStatus: 404 }) |
401 | await updateVideoPlaylistElement(params) | 403 | await updateVideoPlaylistElement(params) |
402 | } | 404 | } |
403 | }) | 405 | }) |
@@ -415,7 +417,7 @@ describe('Test video playlists API validator', function () { | |||
415 | }) | 417 | }) |
416 | 418 | ||
417 | it('Should fail with an unknown element', async function () { | 419 | it('Should fail with an unknown element', async function () { |
418 | const params = getBase({}, { videoId: videoId2, expectedStatus: 404 }) | 420 | const params = getBase({}, { playlistElementId: 888, expectedStatus: 404 }) |
419 | await updateVideoPlaylistElement(params) | 421 | await updateVideoPlaylistElement(params) |
420 | }) | 422 | }) |
421 | 423 | ||
@@ -587,7 +589,7 @@ describe('Test video playlists API validator', function () { | |||
587 | return Object.assign({ | 589 | return Object.assign({ |
588 | url: server.url, | 590 | url: server.url, |
589 | token: server.accessToken, | 591 | token: server.accessToken, |
590 | videoId: videoId, | 592 | playlistElementId, |
591 | playlistId: playlistUUID, | 593 | playlistId: playlistUUID, |
592 | expectedStatus: 400 | 594 | expectedStatus: 400 |
593 | }, wrapper) | 595 | }, wrapper) |
@@ -617,18 +619,18 @@ describe('Test video playlists API validator', function () { | |||
617 | 619 | ||
618 | it('Should fail with an unknown or incorrect video id', async function () { | 620 | it('Should fail with an unknown or incorrect video id', async function () { |
619 | { | 621 | { |
620 | const params = getBase({ videoId: 'toto' }) | 622 | const params = getBase({ playlistElementId: 'toto' }) |
621 | await removeVideoFromPlaylist(params) | 623 | await removeVideoFromPlaylist(params) |
622 | } | 624 | } |
623 | 625 | ||
624 | { | 626 | { |
625 | const params = getBase({ videoId: 42, expectedStatus: 404 }) | 627 | const params = getBase({ playlistElementId: 42, expectedStatus: 404 }) |
626 | await removeVideoFromPlaylist(params) | 628 | await removeVideoFromPlaylist(params) |
627 | } | 629 | } |
628 | }) | 630 | }) |
629 | 631 | ||
630 | it('Should fail with an unknown element', async function () { | 632 | it('Should fail with an unknown element', async function () { |
631 | const params = getBase({ videoId: videoId2, expectedStatus: 404 }) | 633 | const params = getBase({ playlistElementId: 888, expectedStatus: 404 }) |
632 | await removeVideoFromPlaylist(params) | 634 | await removeVideoFromPlaylist(params) |
633 | }) | 635 | }) |
634 | 636 | ||