]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/plugins/html-injection.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / html-injection.ts
CommitLineData
1f5221fb
C
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
86347717 3import { expect } from 'chai'
1f5221fb
C
4import {
5 cleanupTests,
254d3579 6 createSingleServer,
1f5221fb 7 makeHTMLRequest,
254d3579 8 PeerTubeServer,
4c7e60bc 9 PluginsCommand,
ae2abfd3 10 setAccessTokensToServers
c55e3d72 11} from '@shared/server-commands'
1f5221fb 12
29b7426c 13describe('Test plugins HTML injection', function () {
254d3579 14 let server: PeerTubeServer = null
ae2abfd3 15 let command: PluginsCommand
1f5221fb
C
16
17 before(async function () {
18 this.timeout(30000)
19
254d3579 20 server = await createSingleServer(1)
1f5221fb 21 await setAccessTokensToServers([ server ])
ae2abfd3 22
89d241a7 23 command = server.plugins
1f5221fb
C
24 })
25
26 it('Should not inject global css file in HTML', async function () {
27 {
ae2abfd3
C
28 const text = await command.getCSS()
29 expect(text).to.be.empty
1f5221fb
C
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
ae2abfd3 41 await command.install({ npmName: 'peertube-plugin-hello-world' })
1f5221fb
C
42 })
43
44 it('Should have the correct global css', async function () {
45 {
ae2abfd3
C
46 const text = await command.getCSS()
47 expect(text).to.contain('background-color: red')
1f5221fb
C
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 () {
ae2abfd3 57 await command.uninstall({ npmName: 'peertube-plugin-hello-world' })
1f5221fb
C
58
59 {
ae2abfd3
C
60 const text = await command.getCSS()
61 expect(text).to.be.empty
1f5221fb
C
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})