diff options
Diffstat (limited to 'server/tests/plugins/html-injection.ts')
-rw-r--r-- | server/tests/plugins/html-injection.ts | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/server/tests/plugins/html-injection.ts b/server/tests/plugins/html-injection.ts index 4fa8caa3a..95c0cd687 100644 --- a/server/tests/plugins/html-injection.ts +++ b/server/tests/plugins/html-injection.ts | |||
@@ -4,31 +4,32 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { |
6 | cleanupTests, | 6 | cleanupTests, |
7 | flushAndRunServer, | 7 | createSingleServer, |
8 | getPluginsCSS, | ||
9 | installPlugin, | ||
10 | makeHTMLRequest, | 8 | makeHTMLRequest, |
11 | ServerInfo, | 9 | PeerTubeServer, |
12 | setAccessTokensToServers, | 10 | PluginsCommand, |
13 | uninstallPlugin | 11 | setAccessTokensToServers |
14 | } from '../../../shared/extra-utils' | 12 | } from '../../../shared/extra-utils' |
15 | 13 | ||
16 | const expect = chai.expect | 14 | const expect = chai.expect |
17 | 15 | ||
18 | describe('Test plugins HTML injection', function () { | 16 | describe('Test plugins HTML injection', function () { |
19 | let server: ServerInfo = null | 17 | let server: PeerTubeServer = null |
18 | let command: PluginsCommand | ||
20 | 19 | ||
21 | before(async function () { | 20 | before(async function () { |
22 | this.timeout(30000) | 21 | this.timeout(30000) |
23 | 22 | ||
24 | server = await flushAndRunServer(1) | 23 | server = await createSingleServer(1) |
25 | await setAccessTokensToServers([ server ]) | 24 | await setAccessTokensToServers([ server ]) |
25 | |||
26 | command = server.plugins | ||
26 | }) | 27 | }) |
27 | 28 | ||
28 | it('Should not inject global css file in HTML', async function () { | 29 | it('Should not inject global css file in HTML', async function () { |
29 | { | 30 | { |
30 | const res = await getPluginsCSS(server.url) | 31 | const text = await command.getCSS() |
31 | expect(res.text).to.be.empty | 32 | expect(text).to.be.empty |
32 | } | 33 | } |
33 | 34 | ||
34 | for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) { | 35 | for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) { |
@@ -40,17 +41,13 @@ describe('Test plugins HTML injection', function () { | |||
40 | it('Should install a plugin and a theme', async function () { | 41 | it('Should install a plugin and a theme', async function () { |
41 | this.timeout(30000) | 42 | this.timeout(30000) |
42 | 43 | ||
43 | await installPlugin({ | 44 | await command.install({ npmName: 'peertube-plugin-hello-world' }) |
44 | url: server.url, | ||
45 | accessToken: server.accessToken, | ||
46 | npmName: 'peertube-plugin-hello-world' | ||
47 | }) | ||
48 | }) | 45 | }) |
49 | 46 | ||
50 | it('Should have the correct global css', async function () { | 47 | it('Should have the correct global css', async function () { |
51 | { | 48 | { |
52 | const res = await getPluginsCSS(server.url) | 49 | const text = await command.getCSS() |
53 | expect(res.text).to.contain('background-color: red') | 50 | expect(text).to.contain('background-color: red') |
54 | } | 51 | } |
55 | 52 | ||
56 | for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) { | 53 | for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) { |
@@ -60,15 +57,11 @@ describe('Test plugins HTML injection', function () { | |||
60 | }) | 57 | }) |
61 | 58 | ||
62 | it('Should have an empty global css on uninstall', async function () { | 59 | it('Should have an empty global css on uninstall', async function () { |
63 | await uninstallPlugin({ | 60 | await command.uninstall({ npmName: 'peertube-plugin-hello-world' }) |
64 | url: server.url, | ||
65 | accessToken: server.accessToken, | ||
66 | npmName: 'peertube-plugin-hello-world' | ||
67 | }) | ||
68 | 61 | ||
69 | { | 62 | { |
70 | const res = await getPluginsCSS(server.url) | 63 | const text = await command.getCSS() |
71 | expect(res.text).to.be.empty | 64 | expect(text).to.be.empty |
72 | } | 65 | } |
73 | 66 | ||
74 | for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) { | 67 | for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) { |