]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
9b474844 C |
2 | |
3 | import 'mocha' | |
329619b3 | 4 | import { expect } from 'chai' |
9b474844 C |
5 | import { |
6 | cleanupTests, | |
9b474844 | 7 | flushAndRunServer, |
89cd1275 | 8 | killallServers, |
ae2abfd3 | 9 | PluginsCommand, |
9b474844 | 10 | reRunServer, |
9b474844 C |
11 | ServerInfo, |
12 | setAccessTokensToServers | |
13 | } from '../../../shared/extra-utils' | |
9b474844 C |
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 | ||
ae2abfd3 | 28 | const packagePath = PluginsCommand.getPluginTestPath() |
9b474844 | 29 | |
329619b3 | 30 | await server.cliCommand.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`) |
9b474844 C |
31 | }) |
32 | ||
33 | it('Should install a theme from stateless CLI', async function () { | |
34 | this.timeout(60000) | |
35 | ||
329619b3 | 36 | await server.cliCommand.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`) |
9b474844 C |
37 | }) |
38 | ||
39 | it('Should have the theme and the plugin registered when we restart peertube', async function () { | |
40 | this.timeout(30000) | |
41 | ||
9293139f | 42 | await killallServers([ server ]) |
9b474844 C |
43 | await reRunServer(server) |
44 | ||
65e6e260 | 45 | const config = await server.configCommand.getConfig() |
9b474844 C |
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 | ||
329619b3 | 59 | await server.cliCommand.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`) |
9b474844 C |
60 | }) |
61 | ||
62 | it('Should have removed the plugin on another peertube restart', async function () { | |
63 | this.timeout(30000) | |
64 | ||
9293139f | 65 | await killallServers([ server ]) |
9b474844 C |
66 | await reRunServer(server) |
67 | ||
65e6e260 | 68 | const config = await server.configCommand.getConfig() |
9b474844 C |
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 | }) |