1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import { expect } from 'chai'
10 setAccessTokensToServers
11 } from '@shared/server-commands'
13 describe('Test plugins HTML injection', function () {
14 let server: PeerTubeServer = null
15 let command: PluginsCommand
17 before(async function () {
20 server = await createSingleServer(1)
21 await setAccessTokensToServers([ server ])
23 command = server.plugins
26 it('Should not inject global css file in HTML', async function () {
28 const text = await command.getCSS()
29 expect(text).to.be.empty
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')
38 it('Should install a plugin and a theme', async function () {
41 await command.install({ npmName: 'peertube-plugin-hello-world' })
44 it('Should have the correct global css', async function () {
46 const text = await command.getCSS()
47 expect(text).to.contain('background-color: red')
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')
56 it('Should have an empty global css on uninstall', async function () {
57 await command.uninstall({ npmName: 'peertube-plugin-hello-world' })
60 const text = await command.getCSS()
61 expect(text).to.be.empty
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')
70 after(async function () {
71 await cleanupTests([ server ])