diff options
author | Chocobozzz <chocobozzz@cpy.re> | 2021-05-27 15:59:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-27 15:59:55 +0200 |
commit | 2539932e16129992a2c0889b4ff527c265a8e2c7 (patch) | |
tree | fb5048e63e02a2485eb96d27455f43e4b22e8ae0 /server/tests/api/check-params | |
parent | eb34ec30e0b57286fc6f85160490d2e973a3b0b1 (diff) | |
download | PeerTube-2539932e16129992a2c0889b4ff527c265a8e2c7.tar.gz PeerTube-2539932e16129992a2c0889b4ff527c265a8e2c7.tar.zst PeerTube-2539932e16129992a2c0889b4ff527c265a8e2c7.zip |
Instance homepage support (#4007)
* Prepare homepage parsers
* Add ability to update instance hompage
* Add ability to set homepage as landing page
* Add homepage preview in admin
* Dynamically update left menu for homepage
* Inject home content in homepage
* Add videos list and channel miniature custom markup
* Remove unused elements in markup service
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r-- | server/tests/api/check-params/custom-pages.ts | 81 | ||||
-rw-r--r-- | server/tests/api/check-params/index.ts | 1 |
2 files changed, 82 insertions, 0 deletions
diff --git a/server/tests/api/check-params/custom-pages.ts b/server/tests/api/check-params/custom-pages.ts new file mode 100644 index 000000000..74ca3384c --- /dev/null +++ b/server/tests/api/check-params/custom-pages.ts | |||
@@ -0,0 +1,81 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import 'mocha' | ||
4 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
5 | import { | ||
6 | cleanupTests, | ||
7 | createUser, | ||
8 | flushAndRunServer, | ||
9 | ServerInfo, | ||
10 | setAccessTokensToServers, | ||
11 | userLogin | ||
12 | } from '../../../../shared/extra-utils' | ||
13 | import { makeGetRequest, makePutBodyRequest } from '../../../../shared/extra-utils/requests/requests' | ||
14 | |||
15 | describe('Test custom pages validators', function () { | ||
16 | const path = '/api/v1/custom-pages/homepage/instance' | ||
17 | |||
18 | let server: ServerInfo | ||
19 | let userAccessToken: string | ||
20 | |||
21 | // --------------------------------------------------------------- | ||
22 | |||
23 | before(async function () { | ||
24 | this.timeout(120000) | ||
25 | |||
26 | server = await flushAndRunServer(1) | ||
27 | await setAccessTokensToServers([ server ]) | ||
28 | |||
29 | const user = { username: 'user1', password: 'password' } | ||
30 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | ||
31 | |||
32 | userAccessToken = await userLogin(server, user) | ||
33 | }) | ||
34 | |||
35 | describe('When updating instance homepage', function () { | ||
36 | |||
37 | it('Should fail with an unauthenticated user', async function () { | ||
38 | await makePutBodyRequest({ | ||
39 | url: server.url, | ||
40 | path, | ||
41 | fields: { content: 'super content' }, | ||
42 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | ||
43 | }) | ||
44 | }) | ||
45 | |||
46 | it('Should fail with a non admin user', async function () { | ||
47 | await makePutBodyRequest({ | ||
48 | url: server.url, | ||
49 | path, | ||
50 | token: userAccessToken, | ||
51 | fields: { content: 'super content' }, | ||
52 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | ||
53 | }) | ||
54 | }) | ||
55 | |||
56 | it('Should succeed with the correct params', async function () { | ||
57 | await makePutBodyRequest({ | ||
58 | url: server.url, | ||
59 | path, | ||
60 | token: server.accessToken, | ||
61 | fields: { content: 'super content' }, | ||
62 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | ||
63 | }) | ||
64 | }) | ||
65 | }) | ||
66 | |||
67 | describe('When getting instance homapage', function () { | ||
68 | |||
69 | it('Should succeed with the correct params', async function () { | ||
70 | await makeGetRequest({ | ||
71 | url: server.url, | ||
72 | path, | ||
73 | statusCodeExpected: HttpStatusCode.OK_200 | ||
74 | }) | ||
75 | }) | ||
76 | }) | ||
77 | |||
78 | after(async function () { | ||
79 | await cleanupTests([ server ]) | ||
80 | }) | ||
81 | }) | ||
diff --git a/server/tests/api/check-params/index.ts b/server/tests/api/check-params/index.ts index 143515838..ce2335e42 100644 --- a/server/tests/api/check-params/index.ts +++ b/server/tests/api/check-params/index.ts | |||
@@ -3,6 +3,7 @@ import './accounts' | |||
3 | import './blocklist' | 3 | import './blocklist' |
4 | import './bulk' | 4 | import './bulk' |
5 | import './config' | 5 | import './config' |
6 | import './custom-pages' | ||
6 | import './contact-form' | 7 | import './contact-form' |
7 | import './debug' | 8 | import './debug' |
8 | import './follows' | 9 | import './follows' |