1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
10 setAccessTokensToServers, uninstallPlugin
11 } from '../../../shared/extra-utils'
12 import { expect } from 'chai'
13 import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
15 describe('Test plugin helpers', function () {
16 let server: ServerInfo
18 '/plugins/test-five/router/',
19 '/plugins/test-five/0.0.1/router/'
22 before(async function () {
25 server = await flushAndRunServer(1)
26 await setAccessTokensToServers([ server ])
30 accessToken: server.accessToken,
31 path: getPluginTestPath('-five')
35 it('Should answer "pong"', async function () {
36 for (const path of basePaths) {
37 const res = await makeGetRequest({
40 statusCodeExpected: HttpStatusCode.OK_200
43 expect(res.body.message).to.equal('pong')
47 it('Should mirror post body', async function () {
54 for (const path of basePaths) {
55 const res = await makePostBodyRequest({
57 path: path + 'form/post/mirror',
59 statusCodeExpected: HttpStatusCode.OK_200
62 expect(res.body).to.deep.equal(body)
66 it('Should remove the plugin and remove the routes', async function () {
67 await uninstallPlugin({
69 accessToken: server.accessToken,
70 npmName: 'peertube-plugin-test-five'
73 for (const path of basePaths) {
74 await makeGetRequest({
77 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
80 await makePostBodyRequest({
84 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
89 after(async function () {
90 await cleanupTests([ server ])