1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import * as chai from 'chai'
10 setAccessTokensToServers
11 } from '@shared/server-commands'
13 const expect = chai.expect
15 describe('Test plugins HTML injection', function () {
16 let server: PeerTubeServer = null
17 let command: PluginsCommand
19 before(async function () {
22 server = await createSingleServer(1)
23 await setAccessTokensToServers([ server ])
25 command = server.plugins
28 it('Should not inject global css file in HTML', async function () {
30 const text = await command.getCSS()
31 expect(text).to.be.empty
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')
40 it('Should install a plugin and a theme', async function () {
43 await command.install({ npmName: 'peertube-plugin-hello-world' })
46 it('Should have the correct global css', async function () {
48 const text = await command.getCSS()
49 expect(text).to.contain('background-color: red')
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')
58 it('Should have an empty global css on uninstall', async function () {
59 await command.uninstall({ npmName: 'peertube-plugin-hello-world' })
62 const text = await command.getCSS()
63 expect(text).to.be.empty
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')
72 after(async function () {
73 await cleanupTests([ server ])