1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
10 setAccessTokensToServers
11 } from '@shared/extra-utils'
12 import { HttpStatusCode } from '@shared/models'
14 describe('Test custom pages validators', function () {
15 const path = '/api/v1/custom-pages/homepage/instance'
17 let server: PeerTubeServer
18 let userAccessToken: string
20 // ---------------------------------------------------------------
22 before(async function () {
25 server = await createSingleServer(1)
26 await setAccessTokensToServers([ server ])
28 const user = { username: 'user1', password: 'password' }
29 await server.users.create({ username: user.username, password: user.password })
31 userAccessToken = await server.login.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 expectedStatus: 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 expectedStatus: 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 expectedStatus: 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 expectedStatus: HttpStatusCode.OK_200
77 after(async function () {
78 await cleanupTests([ server ])