X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fvideo-abuses.ts;h=e643cb95e529acf6f25cb5d47ef728dd40ae94c3;hb=3b0bd70aa05ab82fa30fe67ed4899d44652c703a;hp=3b8f5f14d80425420918dd46b70c8e8d7f7abec1;hpb=88108880bbdba473cfe36ecbebc1c3c4f972e102;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 3b8f5f14d..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 () { @@ -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(() => { @@ -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 ]) }) })