X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fjobs.ts;h=3c1d2049bbbcb7e00dd101a286e1956f20e94be9;hb=0d8de2756fdc43be61a82a96c17d12ee52ba0143;hp=5fb2b96060dd9fff66e0272729ad849517d06da2;hpb=1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts index 5fb2b9606..3c1d2049b 100644 --- a/server/tests/api/check-params/jobs.ts +++ b/server/tests/api/check-params/jobs.ts @@ -1,22 +1,22 @@ -/* tslint:disable:no-unused-expression */ +/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' import { + cleanupTests, createUser, - flushTests, - killallServers, - runServer, + flushAndRunServer, ServerInfo, setAccessTokensToServers, userLogin -} from '../../../../shared/utils' +} from '../../../../shared/extra-utils' import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination -} from '../../../../shared/utils/requests/check-api-params' -import { makeGetRequest } from '../../../../shared/utils/requests/requests' +} from '../../../../shared/extra-utils/requests/check-api-params' +import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' describe('Test jobs API validators', function () { const path = '/api/v1/jobs/failed' @@ -28,9 +28,7 @@ describe('Test jobs API validators', function () { before(async function () { this.timeout(120000) - await flushTests() - - server = await runServer(1) + server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) @@ -52,6 +50,17 @@ describe('Test jobs API validators', function () { }) }) + it('Should fail with an incorrect job type', async function () { + await makeGetRequest({ + url: server.url, + token: server.accessToken, + path, + query: { + jobType: 'toto' + } + }) + }) + it('Should fail with a bad start pagination', async function () { await checkBadStartPagination(server.url, path, server.accessToken) }) @@ -68,7 +77,7 @@ describe('Test jobs API validators', function () { await makeGetRequest({ url: server.url, path, - statusCodeExpected: 401 + statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) }) @@ -77,17 +86,13 @@ describe('Test jobs API validators', function () { url: server.url, path, token: userAccessToken, - statusCodeExpected: 403 + statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) }) + }) after(async function () { - killallServers([ server ]) - - // Keep the logs if the test failed - if (this['ok']) { - await flushTests() - } + await cleanupTests([ server ]) }) })