]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/plugins/html-injection.ts
shared/ typescript types dir server-commands
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / html-injection.ts
1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3 import 'mocha'
4 import * as chai from 'chai'
5 import {
6 cleanupTests,
7 createSingleServer,
8 makeHTMLRequest,
9 PeerTubeServer,
10 PluginsCommand,
11 setAccessTokensToServers
12 } from '../../../shared/server-commands'
13
14 const expect = chai.expect
15
16 describe('Test plugins HTML injection', function () {
17 let server: PeerTubeServer = null
18 let command: PluginsCommand
19
20 before(async function () {
21 this.timeout(30000)
22
23 server = await createSingleServer(1)
24 await setAccessTokensToServers([ server ])
25
26 command = server.plugins
27 })
28
29 it('Should not inject global css file in HTML', async function () {
30 {
31 const text = await command.getCSS()
32 expect(text).to.be.empty
33 }
34
35 for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) {
36 const res = await makeHTMLRequest(server.url, path)
37 expect(res.text).to.not.include('link rel="stylesheet" href="/plugins/global.css')
38 }
39 })
40
41 it('Should install a plugin and a theme', async function () {
42 this.timeout(30000)
43
44 await command.install({ npmName: 'peertube-plugin-hello-world' })
45 })
46
47 it('Should have the correct global css', async function () {
48 {
49 const text = await command.getCSS()
50 expect(text).to.contain('background-color: red')
51 }
52
53 for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) {
54 const res = await makeHTMLRequest(server.url, path)
55 expect(res.text).to.include('link rel="stylesheet" href="/plugins/global.css')
56 }
57 })
58
59 it('Should have an empty global css on uninstall', async function () {
60 await command.uninstall({ npmName: 'peertube-plugin-hello-world' })
61
62 {
63 const text = await command.getCSS()
64 expect(text).to.be.empty
65 }
66
67 for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) {
68 const res = await makeHTMLRequest(server.url, path)
69 expect(res.text).to.not.include('link rel="stylesheet" href="/plugins/global.css')
70 }
71 })
72
73 after(async function () {
74 await cleanupTests([ server ])
75 })
76 })