]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/cli/plugins.ts
178a7a2d9c17004c98ebf24f5a5d7cfbca0cb147
[github/Chocobozzz/PeerTube.git] / server / tests / cli / plugins.ts
1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3 import 'mocha'
4 import { expect } from 'chai'
5 import {
6 cleanupTests,
7 flushAndRunServer,
8 killallServers,
9 PluginsCommand,
10 reRunServer,
11 ServerInfo,
12 setAccessTokensToServers
13 } from '../../../shared/extra-utils'
14
15 describe('Test plugin scripts', function () {
16 let server: ServerInfo
17
18 before(async function () {
19 this.timeout(30000)
20
21 server = await flushAndRunServer(1)
22 await setAccessTokensToServers([ server ])
23 })
24
25 it('Should install a plugin from stateless CLI', async function () {
26 this.timeout(60000)
27
28 const packagePath = PluginsCommand.getPluginTestPath()
29
30 await server.cli.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`)
31 })
32
33 it('Should install a theme from stateless CLI', async function () {
34 this.timeout(60000)
35
36 await server.cli.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`)
37 })
38
39 it('Should have the theme and the plugin registered when we restart peertube', async function () {
40 this.timeout(30000)
41
42 await killallServers([ server ])
43 await reRunServer(server)
44
45 const config = await server.config.getConfig()
46
47 const plugin = config.plugin.registered
48 .find(p => p.name === 'test')
49 expect(plugin).to.not.be.undefined
50
51 const theme = config.theme.registered
52 .find(t => t.name === 'background-red')
53 expect(theme).to.not.be.undefined
54 })
55
56 it('Should uninstall a plugin from stateless CLI', async function () {
57 this.timeout(60000)
58
59 await server.cli.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
60 })
61
62 it('Should have removed the plugin on another peertube restart', async function () {
63 this.timeout(30000)
64
65 await killallServers([ server ])
66 await reRunServer(server)
67
68 const config = await server.config.getConfig()
69
70 const plugin = config.plugin.registered
71 .find(p => p.name === 'test')
72 expect(plugin).to.be.undefined
73 })
74
75 after(async function () {
76 await cleanupTests([ server ])
77 })
78 })