1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import { expect } from 'chai'
5 import { HttpStatusCode } from '@shared/core-utils'
6 import { cleanupTests, flushAndRunServer, makeGetRequest, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils'
8 describe('Test plugins module unloading', function () {
9 let server: ServerInfo = null
10 const requestPath = '/plugins/test-unloading/router/get'
11 let value: string = null
13 before(async function () {
16 server = await flushAndRunServer(1)
17 await setAccessTokensToServers([ server ])
19 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
22 it('Should return a numeric value', async function () {
23 const res = await makeGetRequest({
26 statusCodeExpected: HttpStatusCode.OK_200
29 expect(res.body.message).to.match(/^\d+$/)
30 value = res.body.message
33 it('Should return the same value the second time', async function () {
34 const res = await makeGetRequest({
37 statusCodeExpected: HttpStatusCode.OK_200
40 expect(res.body.message).to.be.equal(value)
43 it('Should uninstall the plugin and free the route', async function () {
44 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-unloading' })
46 await makeGetRequest({
49 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
53 it('Should return a different numeric value', async function () {
54 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
56 const res = await makeGetRequest({
59 statusCodeExpected: HttpStatusCode.OK_200
62 expect(res.body.message).to.match(/^\d+$/)
63 expect(res.body.message).to.be.not.equal(value)
66 after(async function () {
67 await cleanupTests([ server ])