]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/cli/plugins.ts
Merge branch 'release/2.1.0' into develop
[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'
4import {
5 cleanupTests,
6 execCLI,
7 flushAndRunServer,
8 getConfig,
89cd1275
C
9 getEnvCli,
10 getPluginTestPath,
11 killallServers,
9b474844 12 reRunServer,
9b474844
C
13 ServerInfo,
14 setAccessTokensToServers
15} from '../../../shared/extra-utils'
9b474844
C
16import { ServerConfig } from '../../../shared/models/server'
17import { expect } from 'chai'
18
19describe('Test plugin scripts', function () {
20 let server: ServerInfo
21
22 before(async function () {
23 this.timeout(30000)
24
25 server = await flushAndRunServer(1)
26 await setAccessTokensToServers([ server ])
27 })
28
29 it('Should install a plugin from stateless CLI', async function () {
30 this.timeout(60000)
31
89cd1275 32 const packagePath = getPluginTestPath()
9b474844
C
33
34 const env = getEnvCli(server)
35 await execCLI(`${env} npm run plugin:install -- --plugin-path ${packagePath}`)
36 })
37
38 it('Should install a theme from stateless CLI', async function () {
39 this.timeout(60000)
40
41 const env = getEnvCli(server)
42 await execCLI(`${env} npm run plugin:install -- --npm-name peertube-theme-background-red`)
43 })
44
45 it('Should have the theme and the plugin registered when we restart peertube', async function () {
46 this.timeout(30000)
47
48 killallServers([ server ])
49 await reRunServer(server)
50
51 const res = await getConfig(server.url)
52 const config: ServerConfig = res.body
53
54 const plugin = config.plugin.registered
55 .find(p => p.name === 'test')
56 expect(plugin).to.not.be.undefined
57
58 const theme = config.theme.registered
59 .find(t => t.name === 'background-red')
60 expect(theme).to.not.be.undefined
61 })
62
63 it('Should uninstall a plugin from stateless CLI', async function () {
64 this.timeout(60000)
65
66 const env = getEnvCli(server)
67 await execCLI(`${env} npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
68 })
69
70 it('Should have removed the plugin on another peertube restart', async function () {
71 this.timeout(30000)
72
73 killallServers([ server ])
74 await reRunServer(server)
75
76 const res = await getConfig(server.url)
77 const config: ServerConfig = res.body
78
79 const plugin = config.plugin.registered
80 .find(p => p.name === 'test')
81 expect(plugin).to.be.undefined
82 })
83
84 after(async function () {
85 await cleanupTests([ server ])
86 })
87})