aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/client.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/client.ts')
-rw-r--r--server/tests/client.ts28
1 files changed, 23 insertions, 5 deletions
diff --git a/server/tests/client.ts b/server/tests/client.ts
index e76220631..d9a472fdd 100644
--- a/server/tests/client.ts
+++ b/server/tests/client.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import * as request from 'supertest' 5import * as request from 'supertest'
6import { Account, VideoPlaylistPrivacy } from '@shared/models' 6import { Account, HTMLServerConfig, ServerConfig, VideoPlaylistPrivacy } from '@shared/models'
7import { 7import {
8 addVideoInPlaylist, 8 addVideoInPlaylist,
9 cleanupTests, 9 cleanupTests,
@@ -11,6 +11,7 @@ import {
11 doubleFollow, 11 doubleFollow,
12 flushAndRunMultipleServers, 12 flushAndRunMultipleServers,
13 getAccount, 13 getAccount,
14 getConfig,
14 getCustomConfig, 15 getCustomConfig,
15 getVideosList, 16 getVideosList,
16 makeHTMLRequest, 17 makeHTMLRequest,
@@ -25,13 +26,17 @@ import {
25 waitJobs 26 waitJobs
26} from '../../shared/extra-utils' 27} from '../../shared/extra-utils'
27import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 28import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
29import { omit } from 'lodash'
28 30
29const expect = chai.expect 31const expect = chai.expect
30 32
31function checkIndexTags (html: string, title: string, description: string, css: string) { 33function checkIndexTags (html: string, title: string, description: string, css: string, config: ServerConfig) {
32 expect(html).to.contain('<title>' + title + '</title>') 34 expect(html).to.contain('<title>' + title + '</title>')
33 expect(html).to.contain('<meta name="description" content="' + description + '" />') 35 expect(html).to.contain('<meta name="description" content="' + description + '" />')
34 expect(html).to.contain('<style class="custom-css-style">' + css + '</style>') 36 expect(html).to.contain('<style class="custom-css-style">' + css + '</style>')
37
38 const htmlConfig: HTMLServerConfig = omit(config, 'signup')
39 expect(html).to.contain(`<script type="application/javascript">window.PeerTubeServerConfig = '${JSON.stringify(htmlConfig)}'</script>`)
35} 40}
36 41
37describe('Test a client controllers', function () { 42describe('Test a client controllers', function () {
@@ -368,10 +373,11 @@ describe('Test a client controllers', function () {
368 describe('Index HTML', function () { 373 describe('Index HTML', function () {
369 374
370 it('Should have valid index html tags (title, description...)', async function () { 375 it('Should have valid index html tags (title, description...)', async function () {
376 const resConfig = await getConfig(servers[0].url)
371 const res = await makeHTMLRequest(servers[0].url, '/videos/trending') 377 const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
372 378
373 const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.' 379 const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.'
374 checkIndexTags(res.text, 'PeerTube', description, '') 380 checkIndexTags(res.text, 'PeerTube', description, '', resConfig.body)
375 }) 381 })
376 382
377 it('Should update the customized configuration and have the correct index html tags', async function () { 383 it('Should update the customized configuration and have the correct index html tags', async function () {
@@ -390,15 +396,17 @@ describe('Test a client controllers', function () {
390 } 396 }
391 }) 397 })
392 398
399 const resConfig = await getConfig(servers[0].url)
393 const res = await makeHTMLRequest(servers[0].url, '/videos/trending') 400 const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
394 401
395 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }') 402 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', resConfig.body)
396 }) 403 })
397 404
398 it('Should have valid index html updated tags (title, description...)', async function () { 405 it('Should have valid index html updated tags (title, description...)', async function () {
406 const resConfig = await getConfig(servers[0].url)
399 const res = await makeHTMLRequest(servers[0].url, '/videos/trending') 407 const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
400 408
401 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }') 409 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', resConfig.body)
402 }) 410 })
403 411
404 it('Should use the original video URL for the canonical tag', async function () { 412 it('Should use the original video URL for the canonical tag', async function () {
@@ -432,6 +440,16 @@ describe('Test a client controllers', function () {
432 }) 440 })
433 }) 441 })
434 442
443 describe('Embed HTML', function () {
444
445 it('Should have the correct embed html tags', async function () {
446 const resConfig = await getConfig(servers[0].url)
447 const res = await makeHTMLRequest(servers[0].url, servers[0].video.embedPath)
448
449 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', resConfig.body)
450 })
451 })
452
435 after(async function () { 453 after(async function () {
436 await cleanupTests(servers) 454 await cleanupTests(servers)
437 }) 455 })