X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fvideo-playlists.ts;h=8db91a3f9821a6f1eddfbf70c45cbf226fe43d54;hb=fd3c2e87051f5029cdec39d877b576a62f48e219;hp=3799e73b6d3d2d4f91f30da817ea612f3d01c15d;hpb=6c5065a011b099618681a37bd77eaa7bd3db752e;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 3799e73b6..8db91a3f9 100644 --- a/server/tests/api/check-params/video-playlists.ts +++ b/server/tests/api/check-params/video-playlists.ts @@ -1,8 +1,9 @@ /* 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,22 +13,17 @@ import { VideoPlaylistType } from '@shared/models' import { - checkBadCountPagination, - checkBadSortPagination, - checkBadStartPagination, cleanupTests, - flushAndRunServer, - generateUserAccessToken, + 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 @@ -44,15 +40,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 generateUserAccessToken(server, '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({ @@ -70,7 +66,7 @@ describe('Test video playlists API validator', function () { attributes: { displayName: 'super playlist', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: server.videoChannel.id + videoChannelId: server.store.channel.id } }) } @@ -121,7 +117,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 }) }) @@ -132,18 +128,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 }) }) @@ -161,7 +157,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 }) }) }) @@ -178,7 +174,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 } }) @@ -202,7 +198,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 }, @@ -213,7 +209,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 () { @@ -487,8 +483,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 } }) @@ -582,7 +578,7 @@ describe('Test video playlists API validator', function () { url: server.url, path, query: { videoIds: [ 1, 2 ] }, - statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 + expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) @@ -615,7 +611,7 @@ describe('Test video playlists API validator', function () { token: server.accessToken, path, query: { videoIds: [ 1, 2 ] }, - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) }) })