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