X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fjobs.ts;h=c7013951424d69a43012600acdfb63e9c41a7740;hb=7cd4d2ba10106c10602c86f74f55743ded588896;hp=46b05cb4e88c0498568d0a48ec01be9eb9174642;hpb=93e4a311f37d7fc82ec81190553f8beae28fdef5;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts index 46b05cb4e..c70139514 100644 --- a/server/tests/api/check-params/jobs.ts +++ b/server/tests/api/check-params/jobs.ts @@ -1,14 +1,26 @@ /* tslint:disable:no-unused-expression */ import 'mocha' -import * as request from 'supertest' -import { createUser, flushTests, userLogin, killallServers, runServer, ServerInfo, setAccessTokensToServers } from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' -import { makeGetRequest } from '../../utils/requests/requests' +import { + createUser, + flushTests, + killallServers, + flushAndRunServer, + ServerInfo, + setAccessTokensToServers, + userLogin, + cleanupTests +} from '../../../../shared/extra-utils' +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/extra-utils/requests/check-api-params' +import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests' describe('Test jobs API validators', function () { - const path = '/api/v1/jobs/' + const path = '/api/v1/jobs/failed' let server: ServerInfo let userAccessToken = '' @@ -17,9 +29,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 ]) @@ -27,11 +37,20 @@ describe('Test jobs API validators', function () { username: 'user1', password: 'my super password' } - await createUser(server.url, server.accessToken, user.username, user.password) + await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) userAccessToken = await userLogin(server, user) }) describe('When listing jobs', function () { + + it('Should fail with a bad state', async function () { + await makeGetRequest({ + url: server.url, + token: server.accessToken, + path: path + 'ade' + }) + }) + it('Should fail with a bad start pagination', async function () { await checkBadStartPagination(server.url, path, server.accessToken) }) @@ -63,11 +82,6 @@ describe('Test jobs API validators', function () { }) after(async function () { - killallServers([ server ]) - - // Keep the logs if the test failed - if (this['ok']) { - await flushTests() - } + await cleanupTests([ server ]) }) })