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