From 9b474844e85cce916370693cc24f53339a695570 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 19 Jul 2019 10:37:35 +0200 Subject: Add CLI plugins tests --- server/tests/cli/plugins.ts | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 server/tests/cli/plugins.ts (limited to 'server/tests/cli/plugins.ts') diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts new file mode 100644 index 000000000..d7bf8a690 --- /dev/null +++ b/server/tests/cli/plugins.ts @@ -0,0 +1,87 @@ +/* tslint:disable:no-unused-expression */ + +import 'mocha' +import { + cleanupTests, + execCLI, + flushAndRunServer, + getConfig, + getEnvCli, killallServers, + reRunServer, + root, + ServerInfo, + setAccessTokensToServers +} from '../../../shared/extra-utils' +import { join } from 'path' +import { ServerConfig } from '../../../shared/models/server' +import { expect } from 'chai' + +describe('Test plugin scripts', function () { + let server: ServerInfo + + before(async function () { + this.timeout(30000) + + server = await flushAndRunServer(1) + await setAccessTokensToServers([ server ]) + }) + + it('Should install a plugin from stateless CLI', async function () { + this.timeout(60000) + + const packagePath = join(root(), 'server', 'tests', 'fixtures', 'peertube-plugin-test') + + const env = getEnvCli(server) + await execCLI(`${env} npm run plugin:install -- --plugin-path ${packagePath}`) + }) + + it('Should install a theme from stateless CLI', async function () { + this.timeout(60000) + + const env = getEnvCli(server) + await execCLI(`${env} npm run plugin:install -- --npm-name peertube-theme-background-red`) + }) + + it('Should have the theme and the plugin registered when we restart peertube', async function () { + this.timeout(30000) + + killallServers([ server ]) + await reRunServer(server) + + const res = await getConfig(server.url) + const config: ServerConfig = res.body + + const plugin = config.plugin.registered + .find(p => p.name === 'test') + expect(plugin).to.not.be.undefined + + const theme = config.theme.registered + .find(t => t.name === 'background-red') + expect(theme).to.not.be.undefined + }) + + it('Should uninstall a plugin from stateless CLI', async function () { + this.timeout(60000) + + const env = getEnvCli(server) + await execCLI(`${env} npm run plugin:uninstall -- --npm-name peertube-plugin-test`) + }) + + it('Should have removed the plugin on another peertube restart', async function () { + this.timeout(30000) + + killallServers([ server ]) + await reRunServer(server) + + const res = await getConfig(server.url) + const config: ServerConfig = res.body + + const plugin = config.plugin.registered + .find(p => p.name === 'test') + expect(plugin).to.be.undefined + }) + + after(async function () { + await cleanupTests([ server ]) + }) +}) -- cgit v1.2.3