aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/tests/api/server/homepage.ts25
1 files changed, 12 insertions, 13 deletions
diff --git a/server/tests/api/server/homepage.ts b/server/tests/api/server/homepage.ts
index e8ba89ca6..4a3ec0479 100644
--- a/server/tests/api/server/homepage.ts
+++ b/server/tests/api/server/homepage.ts
@@ -3,17 +3,16 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/core-utils'
6import { CustomPage, ServerConfig } from '@shared/models' 6import { ServerConfig } from '@shared/models'
7import { 7import {
8 cleanupTests, 8 cleanupTests,
9 CustomPagesCommand,
9 flushAndRunServer, 10 flushAndRunServer,
10 getConfig, 11 getConfig,
11 getInstanceHomepage,
12 killallServers, 12 killallServers,
13 reRunServer, 13 reRunServer,
14 ServerInfo, 14 ServerInfo,
15 setAccessTokensToServers, 15 setAccessTokensToServers
16 updateInstanceHomepage
17} from '../../../../shared/extra-utils/index' 16} from '../../../../shared/extra-utils/index'
18 17
19const expect = chai.expect 18const expect = chai.expect
@@ -27,26 +26,28 @@ async function getHomepageState (server: ServerInfo) {
27 26
28describe('Test instance homepage actions', function () { 27describe('Test instance homepage actions', function () {
29 let server: ServerInfo 28 let server: ServerInfo
29 let command: CustomPagesCommand
30 30
31 before(async function () { 31 before(async function () {
32 this.timeout(30000) 32 this.timeout(30000)
33 33
34 server = await flushAndRunServer(1) 34 server = await flushAndRunServer(1)
35 await setAccessTokensToServers([ server ]) 35 await setAccessTokensToServers([ server ])
36
37 command = server.customPageCommand
36 }) 38 })
37 39
38 it('Should not have a homepage', async function () { 40 it('Should not have a homepage', async function () {
39 const state = await getHomepageState(server) 41 const state = await getHomepageState(server)
40 expect(state).to.be.false 42 expect(state).to.be.false
41 43
42 await getInstanceHomepage(server.url, HttpStatusCode.NOT_FOUND_404) 44 await command.getInstanceHomepage({ expectedStatus: HttpStatusCode.NOT_FOUND_404 })
43 }) 45 })
44 46
45 it('Should set a homepage', async function () { 47 it('Should set a homepage', async function () {
46 await updateInstanceHomepage(server.url, server.accessToken, '<picsou-magazine></picsou-magazine>') 48 await command.updateInstanceHomepage({ content: '<picsou-magazine></picsou-magazine>' })
47 49
48 const res = await getInstanceHomepage(server.url) 50 const page = await command.getInstanceHomepage()
49 const page: CustomPage = res.body
50 expect(page.content).to.equal('<picsou-magazine></picsou-magazine>') 51 expect(page.content).to.equal('<picsou-magazine></picsou-magazine>')
51 52
52 const state = await getHomepageState(server) 53 const state = await getHomepageState(server)
@@ -60,8 +61,7 @@ describe('Test instance homepage actions', function () {
60 61
61 await reRunServer(server) 62 await reRunServer(server)
62 63
63 const res = await getInstanceHomepage(server.url) 64 const page = await command.getInstanceHomepage()
64 const page: CustomPage = res.body
65 expect(page.content).to.equal('<picsou-magazine></picsou-magazine>') 65 expect(page.content).to.equal('<picsou-magazine></picsou-magazine>')
66 66
67 const state = await getHomepageState(server) 67 const state = await getHomepageState(server)
@@ -69,10 +69,9 @@ describe('Test instance homepage actions', function () {
69 }) 69 })
70 70
71 it('Should empty the homepage', async function () { 71 it('Should empty the homepage', async function () {
72 await updateInstanceHomepage(server.url, server.accessToken, '') 72 await command.updateInstanceHomepage({ content: '' })
73 73
74 const res = await getInstanceHomepage(server.url) 74 const page = await command.getInstanceHomepage()
75 const page: CustomPage = res.body
76 expect(page.content).to.be.empty 75 expect(page.content).to.be.empty
77 76
78 const state = await getHomepageState(server) 77 const state = await getHomepageState(server)