1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import { expect } from 'chai'
11 setAccessTokensToServers
12 } from '@shared/extra-utils'
13 import { HttpStatusCode } from '@shared/models'
15 describe('Test plugins module unloading', function () {
16 let server: PeerTubeServer = null
17 const requestPath = '/plugins/test-unloading/router/get'
18 let value: string = null
20 before(async function () {
23 server = await createSingleServer(1)
24 await setAccessTokensToServers([ server ])
26 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
29 it('Should return a numeric value', async function () {
30 const res = await makeGetRequest({
33 expectedStatus: HttpStatusCode.OK_200
36 expect(res.body.message).to.match(/^\d+$/)
37 value = res.body.message
40 it('Should return the same value the second time', async function () {
41 const res = await makeGetRequest({
44 expectedStatus: HttpStatusCode.OK_200
47 expect(res.body.message).to.be.equal(value)
50 it('Should uninstall the plugin and free the route', async function () {
51 await server.plugins.uninstall({ npmName: 'peertube-plugin-test-unloading' })
53 await makeGetRequest({
56 expectedStatus: HttpStatusCode.NOT_FOUND_404
60 it('Should return a different numeric value', async function () {
61 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
63 const res = await makeGetRequest({
66 expectedStatus: HttpStatusCode.OK_200
69 expect(res.body.message).to.match(/^\d+$/)
70 expect(res.body.message).to.be.not.equal(value)
73 after(async function () {
74 await cleanupTests([ server ])