X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fvideo-playlists.ts;h=8db91a3f9821a6f1eddfbf70c45cbf226fe43d54;hb=fd3c2e87051f5029cdec39d877b576a62f48e219;hp=ebd7e24139692b968d692f08b71a2ade1d8a6344;hpb=d23dd9fbfc4d26026352c10f81d2795ceaf2908a;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 ebd7e2413..8db91a3f9 100644 --- a/server/tests/api/check-params/video-playlists.ts +++ b/server/tests/api/check-params/video-playlists.ts @@ -1,20 +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, - cleanupTests, - flushAndRunServer, - makeGetRequest, - PlaylistsCommand, - ServerInfo, - setAccessTokensToServers, - setDefaultVideoChannel -} from '@shared/extra-utils' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' import { + HttpStatusCode, VideoPlaylistCreate, VideoPlaylistCreateResult, VideoPlaylistElementCreate, @@ -23,9 +12,18 @@ import { VideoPlaylistReorder, VideoPlaylistType } from '@shared/models' +import { + cleanupTests, + createSingleServer, + makeGetRequest, + PeerTubeServer, + PlaylistsCommand, + setAccessTokensToServers, + setDefaultVideoChannel +} from '@shared/server-commands' describe('Test video playlists API validator', function () { - let server: ServerInfo + let server: PeerTubeServer let userAccessToken: string let playlist: VideoPlaylistCreateResult @@ -42,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 server.usersCommand.generateUserAndToken('user1') - videoId = (await server.videosCommand.quickUpload({ name: '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({ @@ -68,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 } }) } @@ -119,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 }) }) @@ -130,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 }) }) @@ -159,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 }) }) }) @@ -176,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 } }) @@ -200,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 }, @@ -211,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 () { @@ -485,8 +483,8 @@ describe('Test video playlists API validator', function () { } before(async function () { - videoId3 = (await server.videosCommand.quickUpload({ name: 'video 3' })).id - videoId4 = (await server.videosCommand.quickUpload({ name: '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 } }) @@ -580,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 }) }) @@ -613,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 }) }) })