]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/cli/plugins.ts
Fix notification on create transcoding job
[github/Chocobozzz/PeerTube.git] / server / tests / cli / plugins.ts
index d7bf8a69046d057a4c81109a2c1afa311e9509b3..07c78cc89ea9956b8246b362732efe99ff4f94d0 100644 (file)
@@ -1,55 +1,47 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import 'mocha'
+import { expect } from 'chai'
 import {
   cleanupTests,
-  execCLI,
-  flushAndRunServer,
-  getConfig,
-  getEnvCli, killallServers,
-  reRunServer,
-  root,
-  ServerInfo,
+  createSingleServer,
+  killallServers,
+  PeerTubeServer,
+  PluginsCommand,
   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
+  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 = join(root(), 'server', 'tests', 'fixtures', 'peertube-plugin-test')
+    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 +55,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')