X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fvideos-filter.ts;h=5a5668665f6553a39df2078c6cbcbb385889e60a;hb=8c559fad1e1c4c2ab7f1388c73200aa4c6256d74;hp=82cc0f638e2fa4d015299d08c7d09c047bcf4b80;hpb=210feb6cc484a6c5c63c98f770de34e223f944cb;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts index 82cc0f638..5a5668665 100644 --- a/server/tests/api/check-params/videos-filter.ts +++ b/server/tests/api/check-params/videos-filter.ts @@ -2,26 +2,25 @@ import 'mocha' import { + cleanupTests, createUser, createVideoPlaylist, - flushTests, - killallServers, - makeGetRequest, flushAndRunServer, + makeGetRequest, ServerInfo, - setAccessTokensToServers, setDefaultVideoChannel, + setAccessTokensToServers, + setDefaultVideoChannel, userLogin } from '../../../../shared/extra-utils' import { UserRole } from '../../../../shared/models/users' import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' -async function testEndpoints (server: ServerInfo, token: string, filter: string, playlistUUID: string, statusCodeExpected: number) { +async function testEndpoints (server: ServerInfo, token: string, filter: string, statusCodeExpected: number) { const paths = [ '/api/v1/video-channels/root_channel/videos', '/api/v1/accounts/root/videos', '/api/v1/videos', - '/api/v1/search/videos', - '/api/v1/video-playlists/' + playlistUUID + '/videos' + '/api/v1/search/videos' ] for (const path of paths) { @@ -70,39 +69,28 @@ describe('Test videos filters', function () { } ) moderatorAccessToken = await userLogin(server, moderator) - - const res = await createVideoPlaylist({ - url: server.url, - token: server.accessToken, - playlistAttrs: { - displayName: 'super playlist', - privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: server.videoChannel.id - } - }) - playlistUUID = res.body.videoPlaylist.uuid }) describe('When setting a video filter', function () { it('Should fail with a bad filter', async function () { - await testEndpoints(server, server.accessToken, 'bad-filter', playlistUUID, 400) + await testEndpoints(server, server.accessToken, 'bad-filter', 400) }) it('Should succeed with a good filter', async function () { - await testEndpoints(server, server.accessToken,'local', playlistUUID, 200) + await testEndpoints(server, server.accessToken,'local', 200) }) it('Should fail to list all-local with a simple user', async function () { - await testEndpoints(server, userAccessToken, 'all-local', playlistUUID, 401) + await testEndpoints(server, userAccessToken, 'all-local', 401) }) it('Should succeed to list all-local with a moderator', async function () { - await testEndpoints(server, moderatorAccessToken, 'all-local', playlistUUID, 200) + await testEndpoints(server, moderatorAccessToken, 'all-local', 200) }) it('Should succeed to list all-local with an admin', async function () { - await testEndpoints(server, server.accessToken, 'all-local', playlistUUID, 200) + await testEndpoints(server, server.accessToken, 'all-local', 200) }) // Because we cannot authenticate the user on the RSS endpoint @@ -129,7 +117,7 @@ describe('Test videos filters', function () { }) }) - after(function () { - killallServers([ server ]) + after(async function () { + await cleanupTests([ server ]) }) })