X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fvideo-abuses.ts;h=e643cb95e529acf6f25cb5d47ef728dd40ae94c3;hb=feb34f6b6b991046aab6a10df747b48fa4da07a7;hp=a79ab4201419fc0b6a4bb83e543158783a514da1;hpb=2a8c5d0af13f3ccb9a505e1fbc9d324b9d33ba1f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/video-abuses.ts b/server/tests/api/check-params/video-abuses.ts index a79ab4201..e643cb95e 100644 --- a/server/tests/api/check-params/video-abuses.ts +++ b/server/tests/api/check-params/video-abuses.ts @@ -1,26 +1,25 @@ -/* tslint:disable:no-unused-expression */ +/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' import { + cleanupTests, createUser, deleteVideoAbuse, - flushTests, - killallServers, + flushAndRunServer, makeGetRequest, makePostBodyRequest, - runServer, ServerInfo, setAccessTokensToServers, updateVideoAbuse, uploadVideo, userLogin -} from '../../../../shared/utils' +} from '../../../../shared/extra-utils' import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination -} from '../../../../shared/utils/requests/check-api-params' +} from '../../../../shared/extra-utils/requests/check-api-params' import { VideoAbuseState } from '../../../../shared/models/videos' describe('Test video abuses API validators', function () { @@ -33,15 +32,13 @@ describe('Test video abuses API validators', function () { before(async function () { this.timeout(30000) - await flushTests() - - server = await runServer(1) + server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) const username = 'user1' const password = 'my super password' - await createUser(server.url, server.accessToken, username, password) + await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) userAccessToken = await userLogin(server, { username, password }) const res = await uploadVideo(server.url, server.accessToken, {}) @@ -79,6 +76,22 @@ describe('Test video abuses API validators', function () { statusCodeExpected: 403 }) }) + + it('Should fail with a bad id filter', async function () { + await makeGetRequest({ url: server.url, path, token: server.accessToken, query: { id: 'toto' } }) + }) + + it('Should fail with a bad state filter', async function () { + await makeGetRequest({ url: server.url, path, token: server.accessToken, query: { state: 'toto' } }) + }) + + it('Should fail with a bad videoIs filter', async function () { + await makeGetRequest({ url: server.url, path, token: server.accessToken, query: { videoIs: 'toto' } }) + }) + + it('Should succeed with the correct params', async function () { + await makeGetRequest({ url: server.url, path, token: server.accessToken, query: { id: 13 }, statusCodeExpected: 200 }) + }) }) describe('When reporting a video abuse', function () { @@ -113,8 +126,8 @@ describe('Test video abuses API validators', function () { await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) }) - it('Should fail with a reason too big', async function () { - const fields = { reason: 'super'.repeat(61) } + it('Should fail with a too big reason', async function () { + const fields = { reason: 'super'.repeat(605) } await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) }) @@ -129,6 +142,7 @@ describe('Test video abuses API validators', function () { describe('When updating a video abuse', function () { const basePath = '/api/v1/videos/' + // eslint-disable-next-line @typescript-eslint/no-unused-vars let path: string before(() => { @@ -154,7 +168,7 @@ describe('Test video abuses API validators', function () { }) it('Should fail with a bad moderation comment', async function () { - const body = { moderationComment: 'b'.repeat(305) } + const body = { moderationComment: 'b'.repeat(3001) } await updateVideoAbuse(server.url, server.accessToken, server.video.uuid, videoAbuseId, body, 400) }) @@ -166,6 +180,7 @@ describe('Test video abuses API validators', function () { describe('When deleting a video abuse', function () { const basePath = '/api/v1/videos/' + // eslint-disable-next-line @typescript-eslint/no-unused-vars let path: string before(() => { @@ -191,11 +206,6 @@ describe('Test video abuses API validators', function () { }) after(async function () { - killallServers([ server ]) - - // Keep the logs if the test failed - if (this['ok']) { - await flushTests() - } + await cleanupTests([ server ]) }) })