1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import { expect } from 'chai'
11 setAccessTokensToServers
12 } from '@shared/server-commands'
13 import { HttpStatusCode } from '@shared/models'
15 describe('Test plugin helpers', function () {
16 let server: PeerTubeServer
18 '/plugins/test-five/router/',
19 '/plugins/test-five/0.0.1/router/'
22 before(async function () {
25 server = await createSingleServer(1)
26 await setAccessTokensToServers([ server ])
28 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-five') })
31 it('Should answer "pong"', async function () {
32 for (const path of basePaths) {
33 const res = await makeGetRequest({
36 expectedStatus: HttpStatusCode.OK_200
39 expect(res.body.message).to.equal('pong')
43 it('Should check if authenticated', async function () {
44 for (const path of basePaths) {
45 const res = await makeGetRequest({
47 path: path + 'is-authenticated',
48 token: server.accessToken,
52 expect(res.body.isAuthenticated).to.equal(true)
54 const secRes = await makeGetRequest({
56 path: path + 'is-authenticated',
60 expect(secRes.body.isAuthenticated).to.equal(false)
64 it('Should mirror post body', async function () {
71 for (const path of basePaths) {
72 const res = await makePostBodyRequest({
74 path: path + 'form/post/mirror',
76 expectedStatus: HttpStatusCode.OK_200
79 expect(res.body).to.deep.equal(body)
83 it('Should remove the plugin and remove the routes', async function () {
84 await server.plugins.uninstall({ npmName: 'peertube-plugin-test-five' })
86 for (const path of basePaths) {
87 await makeGetRequest({
90 expectedStatus: HttpStatusCode.NOT_FOUND_404
93 await makePostBodyRequest({
97 expectedStatus: HttpStatusCode.NOT_FOUND_404
102 after(async function () {
103 await cleanupTests([ server ])