X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fplugins%2Fhtml-injection.ts;h=fe16bf1e6899d7a5ebde7a6a46810f7b59015336;hb=4e4c23c5b8d55ab0aa48a7be8c53ec71d1d7e796;hp=4fa8caa3a33c787365eec4f43c5a9adaefa523a8;hpb=cf21b2cbef61929177b9c09b5e017c3b7eb8535d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/plugins/html-injection.ts b/server/tests/plugins/html-injection.ts index 4fa8caa3a..fe16bf1e6 100644 --- a/server/tests/plugins/html-injection.ts +++ b/server/tests/plugins/html-injection.ts @@ -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' ]) {