]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/plugins/html-injection.ts
Merge branch 'release/5.0.0' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / html-injection.ts
index 4fa8caa3a33c787365eec4f43c5a9adaefa523a8..fe16bf1e6899d7a5ebde7a6a46810f7b59015336 100644 (file)
@@ -1,34 +1,32 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import 'mocha'
-import * as chai from 'chai'
+import { expect } from 'chai'
 import {
   cleanupTests,
-  flushAndRunServer,
-  getPluginsCSS,
-  installPlugin,
+  createSingleServer,
   makeHTMLRequest,
-  ServerInfo,
-  setAccessTokensToServers,
-  uninstallPlugin
-} from '../../../shared/extra-utils'
-
-const expect = chai.expect
+  PeerTubeServer,
+  PluginsCommand,
+  setAccessTokensToServers
+} from '@shared/server-commands'
 
 describe('Test plugins HTML injection', function () {
-  let server: ServerInfo = null
+  let server: PeerTubeServer = null
+  let command: PluginsCommand
 
   before(async function () {
     this.timeout(30000)
 
-    server = await flushAndRunServer(1)
+    server = await createSingleServer(1)
     await setAccessTokensToServers([ server ])
+
+    command = server.plugins
   })
 
   it('Should not inject global css file in HTML', async function () {
     {
-      const res = await getPluginsCSS(server.url)
-      expect(res.text).to.be.empty
+      const text = await command.getCSS()
+      expect(text).to.be.empty
     }
 
     for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) {
@@ -40,17 +38,13 @@ describe('Test plugins HTML injection', function () {
   it('Should install a plugin and a theme', async function () {
     this.timeout(30000)
 
-    await installPlugin({
-      url: server.url,
-      accessToken: server.accessToken,
-      npmName: 'peertube-plugin-hello-world'
-    })
+    await command.install({ npmName: 'peertube-plugin-hello-world' })
   })
 
   it('Should have the correct global css', async function () {
     {
-      const res = await getPluginsCSS(server.url)
-      expect(res.text).to.contain('background-color: red')
+      const text = await command.getCSS()
+      expect(text).to.contain('background-color: red')
     }
 
     for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) {
@@ -60,15 +54,11 @@ describe('Test plugins HTML injection', function () {
   })
 
   it('Should have an empty global css on uninstall', async function () {
-    await uninstallPlugin({
-      url: server.url,
-      accessToken: server.accessToken,
-      npmName: 'peertube-plugin-hello-world'
-    })
+    await command.uninstall({ npmName: 'peertube-plugin-hello-world' })
 
     {
-      const res = await getPluginsCSS(server.url)
-      expect(res.text).to.be.empty
+      const text = await command.getCSS()
+      expect(text).to.be.empty
     }
 
     for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) {