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