1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
5 import { HttpStatusCode } from '@shared/models'
6 import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
8 describe('Test jobs API validators', function () {
9 const path = '/api/v1/jobs/failed'
10 let server: PeerTubeServer
11 let userAccessToken = ''
13 // ---------------------------------------------------------------
15 before(async function () {
18 server = await createSingleServer(1)
20 await setAccessTokensToServers([ server ])
24 password: 'my super password'
26 await server.users.create({ username: user.username, password: user.password })
27 userAccessToken = await server.login.getAccessToken(user)
30 describe('When listing jobs', function () {
32 it('Should fail with a bad state', async function () {
33 await makeGetRequest({
35 token: server.accessToken,
40 it('Should fail with an incorrect job type', async function () {
41 await makeGetRequest({
43 token: server.accessToken,
51 it('Should fail with a bad start pagination', async function () {
52 await checkBadStartPagination(server.url, path, server.accessToken)
55 it('Should fail with a bad count pagination', async function () {
56 await checkBadCountPagination(server.url, path, server.accessToken)
59 it('Should fail with an incorrect sort', async function () {
60 await checkBadSortPagination(server.url, path, server.accessToken)
63 it('Should fail with a non authenticated user', async function () {
64 await makeGetRequest({
67 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
71 it('Should fail with a non admin user', async function () {
72 await makeGetRequest({
75 token: userAccessToken,
76 expectedStatus: HttpStatusCode.FORBIDDEN_403
82 after(async function () {
83 await cleanupTests([ server ])