X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Ffollows.ts;h=2c2224a452b848a972362b6d06505b76ee78ec47;hb=77e9f859c6ad75ba179dec74e5410cc651eaa49b;hp=ed1d2db595eb8124f05eea2c2500104afbaa2353;hpb=14893eb71cb2d4ca47e07589c81958863603aba4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts index ed1d2db59..2c2224a45 100644 --- a/server/tests/api/check-params/follows.ts +++ b/server/tests/api/check-params/follows.ts @@ -1,16 +1,22 @@ -/* tslint:disable:no-unused-expression */ +/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' import { - createUser, flushTests, killallServers, makeDeleteRequest, makePostBodyRequest, runServer, ServerInfo, setAccessTokensToServers, + cleanupTests, + createUser, + flushAndRunServer, + makeDeleteRequest, makeGetRequest, + makePostBodyRequest, + ServerInfo, + setAccessTokensToServers, 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' describe('Test server follows API validators', function () { let server: ServerInfo @@ -20,8 +26,7 @@ describe('Test server follows API validators', function () { before(async function () { this.timeout(30000) - await flushTests() - server = await runServer(1) + server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) }) @@ -35,7 +40,7 @@ describe('Test server follows API validators', function () { password: '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) }) @@ -126,6 +131,38 @@ describe('Test server follows API validators', function () { it('Should fail with an incorrect sort', async function () { await checkBadSortPagination(server.url, path) }) + + it('Should fail with an incorrect state', async function () { + await makeGetRequest({ + url: server.url, + path, + query: { + state: 'blabla' + } + }) + }) + + it('Should fail with an incorrect actor type', async function () { + await makeGetRequest({ + url: server.url, + path, + query: { + actorType: 'blabla' + } + }) + }) + + it('Should fail succeed with the correct params', async function () { + await makeGetRequest({ + url: server.url, + path, + statusCodeExpected: 200, + query: { + state: 'accepted', + actorType: 'Application' + } + }) + }) }) describe('When listing followers', function () { @@ -142,6 +179,38 @@ describe('Test server follows API validators', function () { it('Should fail with an incorrect sort', async function () { await checkBadSortPagination(server.url, path) }) + + it('Should fail with an incorrect actor type', async function () { + await makeGetRequest({ + url: server.url, + path, + query: { + actorType: 'blabla' + } + }) + }) + + it('Should fail with an incorrect state', async function () { + await makeGetRequest({ + url: server.url, + path, + query: { + state: 'blabla', + actorType: 'Application' + } + }) + }) + + it('Should fail succeed with the correct params', async function () { + await makeGetRequest({ + url: server.url, + path, + statusCodeExpected: 200, + query: { + state: 'accepted' + } + }) + }) }) describe('When removing a follower', function () { @@ -297,11 +366,6 @@ describe('Test server follows API validators', function () { }) after(async function () { - killallServers([ server ]) - - // Keep the logs if the test failed - if (this['ok']) { - await flushTests() - } + await cleanupTests([ server ]) }) })