1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
14 setAccessTokensToServers
15 } from '../../../shared/extra-utils'
16 import { ServerConfig } from '../../../shared/models/server'
17 import { expect } from 'chai'
19 describe('Test plugin scripts', function () {
20 let server: ServerInfo
22 before(async function () {
25 server = await flushAndRunServer(1)
26 await setAccessTokensToServers([ server ])
29 it('Should install a plugin from stateless CLI', async function () {
32 const packagePath = getPluginTestPath()
34 const env = getEnvCli(server)
35 await execCLI(`${env} npm run plugin:install -- --plugin-path ${packagePath}`)
38 it('Should install a theme from stateless CLI', async function () {
41 const env = getEnvCli(server)
42 await execCLI(`${env} npm run plugin:install -- --npm-name peertube-theme-background-red`)
45 it('Should have the theme and the plugin registered when we restart peertube', async function () {
48 killallServers([ server ])
49 await reRunServer(server)
51 const res = await getConfig(server.url)
52 const config: ServerConfig = res.body
54 const plugin = config.plugin.registered
55 .find(p => p.name === 'test')
56 expect(plugin).to.not.be.undefined
58 const theme = config.theme.registered
59 .find(t => t.name === 'background-red')
60 expect(theme).to.not.be.undefined
63 it('Should uninstall a plugin from stateless CLI', async function () {
66 const env = getEnvCli(server)
67 await execCLI(`${env} npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
70 it('Should have removed the plugin on another peertube restart', async function () {
73 killallServers([ server ])
74 await reRunServer(server)
76 const res = await getConfig(server.url)
77 const config: ServerConfig = res.body
79 const plugin = config.plugin.registered
80 .find(p => p.name === 'test')
81 expect(plugin).to.be.undefined
84 after(async function () {
85 await cleanupTests([ server ])