1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import { expect } from 'chai'
12 setAccessTokensToServers
13 } from '@shared/server-commands'
14 import { HttpStatusCode } from '@shared/models'
16 describe('Test plugin helpers', function () {
17 let server: PeerTubeServer
19 '/plugins/test-five/router/',
20 '/plugins/test-five/0.0.1/router/'
23 before(async function () {
26 server = await createSingleServer(1)
27 await setAccessTokensToServers([ server ])
29 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-five') })
32 it('Should answer "pong"', async function () {
33 for (const path of basePaths) {
34 const res = await makeGetRequest({
37 expectedStatus: HttpStatusCode.OK_200
40 expect(res.body.message).to.equal('pong')
44 it('Should check if authenticated', async function () {
45 for (const path of basePaths) {
46 const res = await makeGetRequest({
48 path: path + 'is-authenticated',
49 token: server.accessToken,
53 expect(res.body.isAuthenticated).to.equal(true)
55 const secRes = await makeGetRequest({
57 path: path + 'is-authenticated',
61 expect(secRes.body.isAuthenticated).to.equal(false)
65 it('Should mirror post body', async function () {
72 for (const path of basePaths) {
73 const res = await makePostBodyRequest({
75 path: path + 'form/post/mirror',
77 expectedStatus: HttpStatusCode.OK_200
80 expect(res.body).to.deep.equal(body)
84 it('Should remove the plugin and remove the routes', async function () {
85 await server.plugins.uninstall({ npmName: 'peertube-plugin-test-five' })
87 for (const path of basePaths) {
88 await makeGetRequest({
91 expectedStatus: HttpStatusCode.NOT_FOUND_404
94 await makePostBodyRequest({
98 expectedStatus: HttpStatusCode.NOT_FOUND_404
103 after(async function () {
104 await cleanupTests([ server ])