1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
10 setAccessTokensToServers
11 } from '../../../../shared/extra-utils'
12 import { makeGetRequest, makePutBodyRequest } from '../../../../shared/extra-utils/requests/requests'
14 describe('Test custom pages validators', function () {
15 const path = '/api/v1/custom-pages/homepage/instance'
17 let server: ServerInfo
18 let userAccessToken: string
20 // ---------------------------------------------------------------
22 before(async function () {
25 server = await flushAndRunServer(1)
26 await setAccessTokensToServers([ server ])
28 const user = { username: 'user1', password: 'password' }
29 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
31 userAccessToken = await server.loginCommand.getAccessToken(user)
34 describe('When updating instance homepage', function () {
36 it('Should fail with an unauthenticated user', async function () {
37 await makePutBodyRequest({
40 fields: { content: 'super content' },
41 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
45 it('Should fail with a non admin user', async function () {
46 await makePutBodyRequest({
49 token: userAccessToken,
50 fields: { content: 'super content' },
51 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
55 it('Should succeed with the correct params', async function () {
56 await makePutBodyRequest({
59 token: server.accessToken,
60 fields: { content: 'super content' },
61 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
66 describe('When getting instance homapage', function () {
68 it('Should succeed with the correct params', async function () {
69 await makeGetRequest({
72 statusCodeExpected: HttpStatusCode.OK_200
77 after(async function () {
78 await cleanupTests([ server ])