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,
12 } from '../../../../shared/extra-utils'
13 import { makeGetRequest, makePutBodyRequest } from '../../../../shared/extra-utils/requests/requests'
15 describe('Test custom pages validators', function () {
16 const path = '/api/v1/custom-pages/homepage/instance'
18 let server: ServerInfo
19 let userAccessToken: string
21 // ---------------------------------------------------------------
23 before(async function () {
26 server = await flushAndRunServer(1)
27 await setAccessTokensToServers([ server ])
29 const user = { username: 'user1', password: 'password' }
30 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
32 userAccessToken = await userLogin(server, user)
35 describe('When updating instance homepage', function () {
37 it('Should fail with an unauthenticated user', async function () {
38 await makePutBodyRequest({
41 fields: { content: 'super content' },
42 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
46 it('Should fail with a non admin user', async function () {
47 await makePutBodyRequest({
50 token: userAccessToken,
51 fields: { content: 'super content' },
52 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
56 it('Should succeed with the correct params', async function () {
57 await makePutBodyRequest({
60 token: server.accessToken,
61 fields: { content: 'super content' },
62 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
67 describe('When getting instance homapage', function () {
69 it('Should succeed with the correct params', async function () {
70 await makeGetRequest({
73 statusCodeExpected: HttpStatusCode.OK_200
78 after(async function () {
79 await cleanupTests([ server ])