aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli/plugins.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/cli/plugins.ts')
-rw-r--r--server/tests/cli/plugins.ts87
1 files changed, 87 insertions, 0 deletions
diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts
new file mode 100644
index 000000000..d7bf8a690
--- /dev/null
+++ b/server/tests/cli/plugins.ts
@@ -0,0 +1,87 @@
1/* tslint:disable:no-unused-expression */
2
3import 'mocha'
4import {
5 cleanupTests,
6 execCLI,
7 flushAndRunServer,
8 getConfig,
9 getEnvCli, killallServers,
10 reRunServer,
11 root,
12 ServerInfo,
13 setAccessTokensToServers
14} from '../../../shared/extra-utils'
15import { join } from 'path'
16import { ServerConfig } from '../../../shared/models/server'
17import { expect } from 'chai'
18
19describe('Test plugin scripts', function () {
20 let server: ServerInfo
21
22 before(async function () {
23 this.timeout(30000)
24
25 server = await flushAndRunServer(1)
26 await setAccessTokensToServers([ server ])
27 })
28
29 it('Should install a plugin from stateless CLI', async function () {
30 this.timeout(60000)
31
32 const packagePath = join(root(), 'server', 'tests', 'fixtures', 'peertube-plugin-test')
33
34 const env = getEnvCli(server)
35 await execCLI(`${env} npm run plugin:install -- --plugin-path ${packagePath}`)
36 })
37
38 it('Should install a theme from stateless CLI', async function () {
39 this.timeout(60000)
40
41 const env = getEnvCli(server)
42 await execCLI(`${env} npm run plugin:install -- --npm-name peertube-theme-background-red`)
43 })
44
45 it('Should have the theme and the plugin registered when we restart peertube', async function () {
46 this.timeout(30000)
47
48 killallServers([ server ])
49 await reRunServer(server)
50
51 const res = await getConfig(server.url)
52 const config: ServerConfig = res.body
53
54 const plugin = config.plugin.registered
55 .find(p => p.name === 'test')
56 expect(plugin).to.not.be.undefined
57
58 const theme = config.theme.registered
59 .find(t => t.name === 'background-red')
60 expect(theme).to.not.be.undefined
61 })
62
63 it('Should uninstall a plugin from stateless CLI', async function () {
64 this.timeout(60000)
65
66 const env = getEnvCli(server)
67 await execCLI(`${env} npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
68 })
69
70 it('Should have removed the plugin on another peertube restart', async function () {
71 this.timeout(30000)
72
73 killallServers([ server ])
74 await reRunServer(server)
75
76 const res = await getConfig(server.url)
77 const config: ServerConfig = res.body
78
79 const plugin = config.plugin.registered
80 .find(p => p.name === 'test')
81 expect(plugin).to.be.undefined
82 })
83
84 after(async function () {
85 await cleanupTests([ server ])
86 })
87})