aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/server/config.ts26
-rw-r--r--server/tests/real-world/populate-database.ts11
-rw-r--r--server/tests/utils/requests/requests.ts8
3 files changed, 39 insertions, 6 deletions
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index 79b5aaf2d..7d21b6ce9 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -4,7 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { About } from '../../../../shared/models/server/about.model' 5import { About } from '../../../../shared/models/server/about.model'
6import { CustomConfig } from '../../../../shared/models/server/custom-config.model' 6import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
7import { deleteCustomConfig, getAbout, killallServers, reRunServer } from '../../utils' 7import { deleteCustomConfig, getAbout, killallServers, makeHTMLRequest, reRunServer } from '../../utils'
8const expect = chai.expect 8const expect = chai.expect
9 9
10import { 10import {
@@ -69,6 +69,12 @@ function checkUpdatedConfig (data: CustomConfig) {
69 expect(data.transcoding.resolutions['1080p']).to.be.false 69 expect(data.transcoding.resolutions['1080p']).to.be.false
70} 70}
71 71
72function checkIndexTags (html: string, title: string, description: string, css: string) {
73 expect(html).to.contain('<title>' + title + '</title>')
74 expect(html).to.contain('<meta name="description" content="' + description + '" />')
75 expect(html).to.contain('<style class="custom-css-style">' + css + '</style>')
76}
77
72describe('Test config', function () { 78describe('Test config', function () {
73 let server = null 79 let server = null
74 80
@@ -109,6 +115,14 @@ describe('Test config', function () {
109 checkInitialConfig(data) 115 checkInitialConfig(data)
110 }) 116 })
111 117
118 it('Should have valid index html tags (title, description...)', async function () {
119 const res = await makeHTMLRequest(server.url, '/videos/trending')
120
121 const description = 'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser ' +
122 'with WebTorrent and Angular.'
123 checkIndexTags(res.text, 'PeerTube', description, '')
124 })
125
112 it('Should update the customized configuration', async function () { 126 it('Should update the customized configuration', async function () {
113 const newCustomConfig: CustomConfig = { 127 const newCustomConfig: CustomConfig = {
114 instance: { 128 instance: {
@@ -167,6 +181,12 @@ describe('Test config', function () {
167 checkUpdatedConfig(data) 181 checkUpdatedConfig(data)
168 }) 182 })
169 183
184 it('Should have valid index html updated tags (title, description...)', async function () {
185 const res = await makeHTMLRequest(server.url, '/videos/trending')
186
187 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }')
188 })
189
170 it('Should have the configuration updated after a restart', async function () { 190 it('Should have the configuration updated after a restart', async function () {
171 this.timeout(10000) 191 this.timeout(10000)
172 192
@@ -178,6 +198,10 @@ describe('Test config', function () {
178 const data = res.body 198 const data = res.body
179 199
180 checkUpdatedConfig(data) 200 checkUpdatedConfig(data)
201
202 // Check HTML too
203 const resHtml = await makeHTMLRequest(server.url, '/videos/trending')
204 checkIndexTags(resHtml.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }')
181 }) 205 })
182 206
183 it('Should fetch the about information', async function () { 207 it('Should fetch the about information', async function () {
diff --git a/server/tests/real-world/populate-database.ts b/server/tests/real-world/populate-database.ts
index 5f93d09db..f0f82f7f8 100644
--- a/server/tests/real-world/populate-database.ts
+++ b/server/tests/real-world/populate-database.ts
@@ -19,6 +19,12 @@ start()
19// ---------------------------------------------------------------------------- 19// ----------------------------------------------------------------------------
20 20
21async function start () { 21async function start () {
22 await flushTests()
23
24 console.log('Flushed tests.')
25
26 const server = await runServer(6)
27
22 process.on('exit', async () => { 28 process.on('exit', async () => {
23 killallServers([ server ]) 29 killallServers([ server ])
24 return 30 return
@@ -26,11 +32,6 @@ async function start () {
26 process.on('SIGINT', goodbye) 32 process.on('SIGINT', goodbye)
27 process.on('SIGTERM', goodbye) 33 process.on('SIGTERM', goodbye)
28 34
29 await flushTests()
30
31 console.log('Flushed tests.')
32
33 const server = await runServer(6)
34 await setAccessTokensToServers([ server ]) 35 await setAccessTokensToServers([ server ])
35 36
36 console.log('Servers ran.') 37 console.log('Servers ran.')
diff --git a/server/tests/utils/requests/requests.ts b/server/tests/utils/requests/requests.ts
index ebde692cd..b88b3ce5b 100644
--- a/server/tests/utils/requests/requests.ts
+++ b/server/tests/utils/requests/requests.ts
@@ -123,6 +123,13 @@ function makePutBodyRequest (options: {
123 .expect(options.statusCodeExpected) 123 .expect(options.statusCodeExpected)
124} 124}
125 125
126function makeHTMLRequest (url: string, path: string) {
127 return request(url)
128 .get(path)
129 .set('Accept', 'text/html')
130 .expect(200)
131}
132
126function updateAvatarRequest (options: { 133function updateAvatarRequest (options: {
127 url: string, 134 url: string,
128 path: string, 135 path: string,
@@ -149,6 +156,7 @@ function updateAvatarRequest (options: {
149// --------------------------------------------------------------------------- 156// ---------------------------------------------------------------------------
150 157
151export { 158export {
159 makeHTMLRequest,
152 makeGetRequest, 160 makeGetRequest,
153 makeUploadRequest, 161 makeUploadRequest,
154 makePostBodyRequest, 162 makePostBodyRequest,