1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import { HttpStatusCode } from '@shared/models'
10 setAccessTokensToServers
11 } from '@shared/server-commands'
13 describe('Test custom pages validators', function () {
14 const path = '/api/v1/custom-pages/homepage/instance'
16 let server: PeerTubeServer
17 let userAccessToken: string
19 // ---------------------------------------------------------------
21 before(async function () {
24 server = await createSingleServer(1)
25 await setAccessTokensToServers([ server ])
27 const user = { username: 'user1', password: 'password' }
28 await server.users.create({ username: user.username, password: user.password })
30 userAccessToken = await server.login.getAccessToken(user)
33 describe('When updating instance homepage', function () {
35 it('Should fail with an unauthenticated user', async function () {
36 await makePutBodyRequest({
39 fields: { content: 'super content' },
40 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
44 it('Should fail with a non admin user', async function () {
45 await makePutBodyRequest({
48 token: userAccessToken,
49 fields: { content: 'super content' },
50 expectedStatus: HttpStatusCode.FORBIDDEN_403
54 it('Should succeed with the correct params', async function () {
55 await makePutBodyRequest({
58 token: server.accessToken,
59 fields: { content: 'super content' },
60 expectedStatus: HttpStatusCode.NO_CONTENT_204
65 describe('When getting instance homapage', function () {
67 it('Should succeed with the correct params', async function () {
68 await makeGetRequest({
71 expectedStatus: HttpStatusCode.OK_200
76 after(async function () {
77 await cleanupTests([ server ])