X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fvideo-playlists.ts;h=6cb34c8a15d71df17a9b7ee537f32d3610a0c2e2;hb=3f3530c3dbc5339b4cba53710b8568b4ad39152e;hp=46c09bb11cc77e46915f090b120c3f81a0f83ab2;hpb=7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts index 46c09bb11..6cb34c8a1 100644 --- a/server/tests/api/check-params/video-playlists.ts +++ b/server/tests/api/check-params/video-playlists.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' -import { HttpStatusCode } from '@shared/core-utils' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' import { + HttpStatusCode, VideoPlaylistCreate, VideoPlaylistCreateResult, VideoPlaylistElementCreate, @@ -12,21 +12,17 @@ import { VideoPlaylistType } from '@shared/models' import { - checkBadCountPagination, - checkBadSortPagination, - checkBadStartPagination, cleanupTests, - flushAndRunServer, + createSingleServer, makeGetRequest, + PeerTubeServer, PlaylistsCommand, - ServerInfo, setAccessTokensToServers, - setDefaultVideoChannel, - uploadVideoAndGetId -} from '../../../../shared/extra-utils' + setDefaultVideoChannel +} from '@shared/server-commands' describe('Test video playlists API validator', function () { - let server: ServerInfo + let server: PeerTubeServer let userAccessToken: string let playlist: VideoPlaylistCreateResult @@ -43,15 +39,15 @@ describe('Test video playlists API validator', function () { before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) await setDefaultVideoChannel([ server ]) - userAccessToken = await server.usersCommand.generateUserAndToken('user1') - videoId = (await uploadVideoAndGetId({ server, videoName: 'video 1' })).id + userAccessToken = await server.users.generateUserAndToken('user1') + videoId = (await server.videos.quickUpload({ name: 'video 1' })).id - command = server.playlistsCommand + command = server.playlists { const { data } = await command.listByAccount({ @@ -69,7 +65,7 @@ describe('Test video playlists API validator', function () { attributes: { displayName: 'super playlist', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: server.videoChannel.id + videoChannelId: server.store.channel.id } }) } @@ -120,7 +116,7 @@ describe('Test video playlists API validator', function () { await makeGetRequest({ url: server.url, path: accountPath, - statusCodeExpected: HttpStatusCode.NOT_FOUND_404, + expectedStatus: HttpStatusCode.NOT_FOUND_404, token: server.accessToken }) }) @@ -131,18 +127,18 @@ describe('Test video playlists API validator', function () { await makeGetRequest({ url: server.url, path: accountPath, - statusCodeExpected: HttpStatusCode.NOT_FOUND_404, + expectedStatus: HttpStatusCode.NOT_FOUND_404, token: server.accessToken }) }) it('Should success with the correct parameters', async function () { - await makeGetRequest({ url: server.url, path: globalPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken }) - await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken }) + await makeGetRequest({ url: server.url, path: globalPath, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken }) + await makeGetRequest({ url: server.url, path: accountPath, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken }) await makeGetRequest({ url: server.url, path: videoChannelPath, - statusCodeExpected: HttpStatusCode.OK_200, + expectedStatus: HttpStatusCode.OK_200, token: server.accessToken }) }) @@ -160,7 +156,7 @@ describe('Test video playlists API validator', function () { }) it('Should success with the correct parameters', async function () { - await makeGetRequest({ url: server.url, path: path + playlist.shortUUID + '/videos', statusCodeExpected: HttpStatusCode.OK_200 }) + await makeGetRequest({ url: server.url, path: path + playlist.shortUUID + '/videos', expectedStatus: HttpStatusCode.OK_200 }) }) }) @@ -177,7 +173,7 @@ describe('Test video playlists API validator', function () { const playlist = await command.create({ attributes: { displayName: 'super playlist', - videoChannelId: server.videoChannel.id, + videoChannelId: server.store.channel.id, privacy: VideoPlaylistPrivacy.UNLISTED } }) @@ -201,7 +197,7 @@ describe('Test video playlists API validator', function () { displayName: 'display name', privacy: VideoPlaylistPrivacy.UNLISTED, thumbnailfile: 'thumbnail.jpg', - videoChannelId: server.videoChannel.id, + videoChannelId: server.store.channel.id, ...attributes }, @@ -212,7 +208,7 @@ describe('Test video playlists API validator', function () { } } const getUpdate = (params: any, playlistId: number | string) => { - return { ...params, playlistId: playlistId } + return { ...params, playlistId } } it('Should fail with an unauthenticated user', async function () { @@ -486,8 +482,8 @@ describe('Test video playlists API validator', function () { } before(async function () { - videoId3 = (await uploadVideoAndGetId({ server, videoName: 'video 3' })).id - videoId4 = (await uploadVideoAndGetId({ server, videoName: 'video 4' })).id + videoId3 = (await server.videos.quickUpload({ name: 'video 3' })).id + videoId4 = (await server.videos.quickUpload({ name: 'video 4' })).id for (const id of [ videoId3, videoId4 ]) { await command.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: id } }) @@ -581,7 +577,7 @@ describe('Test video playlists API validator', function () { url: server.url, path, query: { videoIds: [ 1, 2 ] }, - statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 + expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) @@ -614,7 +610,7 @@ describe('Test video playlists API validator', function () { token: server.accessToken, path, query: { videoIds: [ 1, 2 ] }, - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) }) })