aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins/html-injection.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-24 13:37:49 +0200
committerChocobozzz <me@florianbigard.com>2020-08-24 13:37:49 +0200
commit1f5221fb4a511bb175083a9c7f578679c6122ce3 (patch)
tree6cd1b955135601188ef0816682641ec327c4bf4f /server/tests/plugins/html-injection.ts
parent6c733e46174c3f5b185402f9d37c88175543cf3c (diff)
downloadPeerTube-1f5221fb4a511bb175083a9c7f578679c6122ce3.tar.gz
PeerTube-1f5221fb4a511bb175083a9c7f578679c6122ce3.tar.zst
PeerTube-1f5221fb4a511bb175083a9c7f578679c6122ce3.zip
Move html injection plugin tests in its own file
Diffstat (limited to 'server/tests/plugins/html-injection.ts')
-rw-r--r--server/tests/plugins/html-injection.ts83
1 files changed, 83 insertions, 0 deletions
diff --git a/server/tests/plugins/html-injection.ts b/server/tests/plugins/html-injection.ts
new file mode 100644
index 000000000..293c1df21
--- /dev/null
+++ b/server/tests/plugins/html-injection.ts
@@ -0,0 +1,83 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import 'mocha'
4import * as chai from 'chai'
5import {
6 cleanupTests,
7 flushAndRunServer,
8 getPluginsCSS,
9 installPlugin,
10 makeHTMLRequest,
11 ServerInfo,
12 setAccessTokensToServers,
13 uninstallPlugin
14} from '../../../shared/extra-utils'
15
16const expect = chai.expect
17
18describe('Test plugins HTML inection', function () {
19 let server: ServerInfo = null
20
21 before(async function () {
22 this.timeout(30000)
23
24 server = await flushAndRunServer(1)
25 await setAccessTokensToServers([ server ])
26 })
27
28 it('Should not inject global css file in HTML', async function () {
29 {
30 const res = await getPluginsCSS(server.url)
31 expect(res.text).to.be.empty
32 }
33
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')
37 }
38 })
39
40 it('Should install a plugin and a theme', async function () {
41 this.timeout(30000)
42
43 await installPlugin({
44 url: server.url,
45 accessToken: server.accessToken,
46 npmName: 'peertube-plugin-hello-world'
47 })
48 })
49
50 it('Should have the correct global css', async function () {
51 {
52 const res = await getPluginsCSS(server.url)
53 expect(res.text).to.contain('background-color: red')
54 }
55
56 for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) {
57 const res = await makeHTMLRequest(server.url, path)
58 expect(res.text).to.include('link rel="stylesheet" href="/plugins/global.css')
59 }
60 })
61
62 it('Should have an empty global css on uninstall', async function () {
63 await uninstallPlugin({
64 url: server.url,
65 accessToken: server.accessToken,
66 npmName: 'peertube-plugin-hello-world'
67 })
68
69 {
70 const res = await getPluginsCSS(server.url)
71 expect(res.text).to.be.empty
72 }
73
74 for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) {
75 const res = await makeHTMLRequest(server.url, path)
76 expect(res.text).to.not.include('link rel="stylesheet" href="/plugins/global.css')
77 }
78 })
79
80 after(async function () {
81 await cleanupTests([ server ])
82 })
83})