]>
Commit | Line | Data |
---|---|---|
1f5221fb C |
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | ||
3 | import 'mocha' | |
4 | import * as chai from 'chai' | |
5 | import { | |
6 | cleanupTests, | |
254d3579 | 7 | createSingleServer, |
1f5221fb | 8 | makeHTMLRequest, |
254d3579 | 9 | PeerTubeServer, |
4c7e60bc | 10 | PluginsCommand, |
ae2abfd3 | 11 | setAccessTokensToServers |
1f5221fb C |
12 | } from '../../../shared/extra-utils' |
13 | ||
14 | const expect = chai.expect | |
15 | ||
29b7426c | 16 | describe('Test plugins HTML injection', function () { |
254d3579 | 17 | let server: PeerTubeServer = null |
ae2abfd3 | 18 | let command: PluginsCommand |
1f5221fb C |
19 | |
20 | before(async function () { | |
21 | this.timeout(30000) | |
22 | ||
254d3579 | 23 | server = await createSingleServer(1) |
1f5221fb | 24 | await setAccessTokensToServers([ server ]) |
ae2abfd3 | 25 | |
89d241a7 | 26 | command = server.plugins |
1f5221fb C |
27 | }) |
28 | ||
29 | it('Should not inject global css file in HTML', async function () { | |
30 | { | |
ae2abfd3 C |
31 | const text = await command.getCSS() |
32 | expect(text).to.be.empty | |
1f5221fb C |
33 | } |
34 | ||
35 | for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) { | |
36 | const res = await makeHTMLRequest(server.url, path) | |
37 | expect(res.text).to.not.include('link rel="stylesheet" href="/plugins/global.css') | |
38 | } | |
39 | }) | |
40 | ||
41 | it('Should install a plugin and a theme', async function () { | |
42 | this.timeout(30000) | |
43 | ||
ae2abfd3 | 44 | await command.install({ npmName: 'peertube-plugin-hello-world' }) |
1f5221fb C |
45 | }) |
46 | ||
47 | it('Should have the correct global css', async function () { | |
48 | { | |
ae2abfd3 C |
49 | const text = await command.getCSS() |
50 | expect(text).to.contain('background-color: red') | |
1f5221fb C |
51 | } |
52 | ||
53 | for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) { | |
54 | const res = await makeHTMLRequest(server.url, path) | |
55 | expect(res.text).to.include('link rel="stylesheet" href="/plugins/global.css') | |
56 | } | |
57 | }) | |
58 | ||
59 | it('Should have an empty global css on uninstall', async function () { | |
ae2abfd3 | 60 | await command.uninstall({ npmName: 'peertube-plugin-hello-world' }) |
1f5221fb C |
61 | |
62 | { | |
ae2abfd3 C |
63 | const text = await command.getCSS() |
64 | expect(text).to.be.empty | |
1f5221fb C |
65 | } |
66 | ||
67 | for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) { | |
68 | const res = await makeHTMLRequest(server.url, path) | |
69 | expect(res.text).to.not.include('link rel="stylesheet" href="/plugins/global.css') | |
70 | } | |
71 | }) | |
72 | ||
73 | after(async function () { | |
74 | await cleanupTests([ server ]) | |
75 | }) | |
76 | }) |