allow limiting video-comments rss feeds to an account or video channel
[oweals/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 {
5   cleanupTests,
6   execCLI,
7   flushAndRunServer,
8   getConfig,
9   getEnvCli,
10   getPluginTestPath,
11   killallServers,
12   reRunServer,
13   ServerInfo,
14   setAccessTokensToServers
15 } from '../../../shared/extra-utils'
16 import { ServerConfig } from '../../../shared/models/server'
17 import { expect } from 'chai'
18
19 describe('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
32     const packagePath = getPluginTestPath()
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 })