X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fcli%2Fplugins.ts;h=c646e20d97aacbaf19927b5070f2e5ac65368848;hb=cffef25313bdf7a6c435f56ac6715fdd91acf7b3;hp=7f19f14b7f7e6eac7c30033d4fa4aca8e748f0bf;hpb=a15871560f80e07386c1dabb8370cd2664ecfd1f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts index 7f19f14b7..c646e20d9 100644 --- a/server/tests/cli/plugins.ts +++ b/server/tests/cli/plugins.ts @@ -1,55 +1,46 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' +import { expect } from 'chai' import { cleanupTests, - execCLI, - flushAndRunServer, - getConfig, - getEnvCli, - getPluginTestPath, + createSingleServer, killallServers, - reRunServer, - ServerInfo, + PeerTubeServer, + PluginsCommand, setAccessTokensToServers -} from '../../../shared/extra-utils' -import { ServerConfig } from '../../../shared/models/server' -import { expect } from 'chai' +} from '@shared/server-commands' describe('Test plugin scripts', function () { - let server: ServerInfo + let server: PeerTubeServer before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) }) it('Should install a plugin from stateless CLI', async function () { this.timeout(60000) - const packagePath = getPluginTestPath() + const packagePath = PluginsCommand.getPluginTestPath() - const env = getEnvCli(server) - await execCLI(`${env} npm run plugin:install -- --plugin-path ${packagePath}`) + await server.cli.execWithEnv(`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`) + await server.cli.execWithEnv(`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) + await killallServers([ server ]) + await server.run() - const res = await getConfig(server.url) - const config: ServerConfig = res.body + const config = await server.config.getConfig() const plugin = config.plugin.registered .find(p => p.name === 'test') @@ -63,18 +54,16 @@ describe('Test plugin scripts', function () { 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`) + await server.cli.execWithEnv(`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) + await killallServers([ server ]) + await server.run() - const res = await getConfig(server.url) - const config: ServerConfig = res.body + const config = await server.config.getConfig() const plugin = config.plugin.registered .find(p => p.name === 'test')