1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import { expect } from 'chai'
10 setAccessTokensToServers
11 } from '@shared/server-commands'
12 import { HttpStatusCode } from '@shared/models'
14 describe('Test plugins module unloading', function () {
15 let server: PeerTubeServer = null
16 const requestPath = '/plugins/test-unloading/router/get'
17 let value: string = null
19 before(async function () {
22 server = await createSingleServer(1)
23 await setAccessTokensToServers([ server ])
25 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
28 it('Should return a numeric value', async function () {
29 const res = await makeGetRequest({
32 expectedStatus: HttpStatusCode.OK_200
35 expect(res.body.message).to.match(/^\d+$/)
36 value = res.body.message
39 it('Should return the same value the second time', async function () {
40 const res = await makeGetRequest({
43 expectedStatus: HttpStatusCode.OK_200
46 expect(res.body.message).to.be.equal(value)
49 it('Should uninstall the plugin and free the route', async function () {
50 await server.plugins.uninstall({ npmName: 'peertube-plugin-test-unloading' })
52 await makeGetRequest({
55 expectedStatus: HttpStatusCode.NOT_FOUND_404
59 it('Should return a different numeric value', async function () {
60 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
62 const res = await makeGetRequest({
65 expectedStatus: HttpStatusCode.OK_200
68 expect(res.body.message).to.match(/^\d+$/)
69 expect(res.body.message).to.be.not.equal(value)
72 after(async function () {
73 await cleanupTests([ server ])