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.ts42
1 files changed, 16 insertions, 26 deletions
diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts
index 7f19f14b7..07c78cc89 100644
--- a/server/tests/cli/plugins.ts
+++ b/server/tests/cli/plugins.ts
@@ -1,55 +1,47 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai'
4import { 5import {
5 cleanupTests, 6 cleanupTests,
6 execCLI, 7 createSingleServer,
7 flushAndRunServer,
8 getConfig,
9 getEnvCli,
10 getPluginTestPath,
11 killallServers, 8 killallServers,
12 reRunServer, 9 PeerTubeServer,
13 ServerInfo, 10 PluginsCommand,
14 setAccessTokensToServers 11 setAccessTokensToServers
15} from '../../../shared/extra-utils' 12} from '../../../shared/extra-utils'
16import { ServerConfig } from '../../../shared/models/server'
17import { expect } from 'chai'
18 13
19describe('Test plugin scripts', function () { 14describe('Test plugin scripts', function () {
20 let server: ServerInfo 15 let server: PeerTubeServer
21 16
22 before(async function () { 17 before(async function () {
23 this.timeout(30000) 18 this.timeout(30000)
24 19
25 server = await flushAndRunServer(1) 20 server = await createSingleServer(1)
26 await setAccessTokensToServers([ server ]) 21 await setAccessTokensToServers([ server ])
27 }) 22 })
28 23
29 it('Should install a plugin from stateless CLI', async function () { 24 it('Should install a plugin from stateless CLI', async function () {
30 this.timeout(60000) 25 this.timeout(60000)
31 26
32 const packagePath = getPluginTestPath() 27 const packagePath = PluginsCommand.getPluginTestPath()
33 28
34 const env = getEnvCli(server) 29 await server.cli.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`)
35 await execCLI(`${env} npm run plugin:install -- --plugin-path ${packagePath}`)
36 }) 30 })
37 31
38 it('Should install a theme from stateless CLI', async function () { 32 it('Should install a theme from stateless CLI', async function () {
39 this.timeout(60000) 33 this.timeout(60000)
40 34
41 const env = getEnvCli(server) 35 await server.cli.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`)
42 await execCLI(`${env} npm run plugin:install -- --npm-name peertube-theme-background-red`)
43 }) 36 })
44 37
45 it('Should have the theme and the plugin registered when we restart peertube', async function () { 38 it('Should have the theme and the plugin registered when we restart peertube', async function () {
46 this.timeout(30000) 39 this.timeout(30000)
47 40
48 killallServers([ server ]) 41 await killallServers([ server ])
49 await reRunServer(server) 42 await server.run()
50 43
51 const res = await getConfig(server.url) 44 const config = await server.config.getConfig()
52 const config: ServerConfig = res.body
53 45
54 const plugin = config.plugin.registered 46 const plugin = config.plugin.registered
55 .find(p => p.name === 'test') 47 .find(p => p.name === 'test')
@@ -63,18 +55,16 @@ describe('Test plugin scripts', function () {
63 it('Should uninstall a plugin from stateless CLI', async function () { 55 it('Should uninstall a plugin from stateless CLI', async function () {
64 this.timeout(60000) 56 this.timeout(60000)
65 57
66 const env = getEnvCli(server) 58 await server.cli.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
67 await execCLI(`${env} npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
68 }) 59 })
69 60
70 it('Should have removed the plugin on another peertube restart', async function () { 61 it('Should have removed the plugin on another peertube restart', async function () {
71 this.timeout(30000) 62 this.timeout(30000)
72 63
73 killallServers([ server ]) 64 await killallServers([ server ])
74 await reRunServer(server) 65 await server.run()
75 66
76 const res = await getConfig(server.url) 67 const config = await server.config.getConfig()
77 const config: ServerConfig = res.body
78 68
79 const plugin = config.plugin.registered 69 const plugin = config.plugin.registered
80 .find(p => p.name === 'test') 70 .find(p => p.name === 'test')