]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/cli/plugins.ts
Use different p2p policy for embeds and webapp
[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 createSingleServer,
8 killallServers,
9 PeerTubeServer,
10 PluginsCommand,
11 setAccessTokensToServers
12 } from '../../../shared/extra-utils'
13
14 describe('Test plugin scripts', function () {
15 let server: PeerTubeServer
16
17 before(async function () {
18 this.timeout(30000)
19
20 server = await createSingleServer(1)
21 await setAccessTokensToServers([ server ])
22 })
23
24 it('Should install a plugin from stateless CLI', async function () {
25 this.timeout(60000)
26
27 const packagePath = PluginsCommand.getPluginTestPath()
28
29 await server.cli.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`)
30 })
31
32 it('Should install a theme from stateless CLI', async function () {
33 this.timeout(60000)
34
35 await server.cli.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`)
36 })
37
38 it('Should have the theme and the plugin registered when we restart peertube', async function () {
39 this.timeout(30000)
40
41 await killallServers([ server ])
42 await server.run()
43
44 const config = await server.config.getConfig()
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
58 await server.cli.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
59 })
60
61 it('Should have removed the plugin on another peertube restart', async function () {
62 this.timeout(30000)
63
64 await killallServers([ server ])
65 await server.run()
66
67 const config = await server.config.getConfig()
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 })