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