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 check if authenticated', async function () {
48 for (const path of basePaths) {
49 const res = await makeGetRequest({
51 path: path + 'is-authenticated',
52 token: server.accessToken,
53 statusCodeExpected: 200
56 expect(res.body.isAuthenticated).to.equal(true)
58 const secRes = await makeGetRequest({
60 path: path + 'is-authenticated',
61 statusCodeExpected: 200
64 expect(secRes.body.isAuthenticated).to.equal(false)
68 it('Should mirror post body', async function () {
75 for (const path of basePaths) {
76 const res = await makePostBodyRequest({
78 path: path + 'form/post/mirror',
80 statusCodeExpected: HttpStatusCode.OK_200
83 expect(res.body).to.deep.equal(body)
87 it('Should remove the plugin and remove the routes', async function () {
88 await uninstallPlugin({
90 accessToken: server.accessToken,
91 npmName: 'peertube-plugin-test-five'
94 for (const path of basePaths) {
95 await makeGetRequest({
98 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
101 await makePostBodyRequest({
105 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
110 after(async function () {
111 await cleanupTests([ server ])