1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
12 setAccessTokensToServers
13 } from '../../../shared/extra-utils'
14 import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
15 import { expect } from 'chai'
17 describe('Test plugins module unloading', function () {
18 let server: ServerInfo = null
19 const requestPath = '/plugins/test-unloading/router/get'
20 let value: string = null
22 before(async function () {
25 server = await flushAndRunServer(1)
26 await setAccessTokensToServers([ server ])
30 accessToken: server.accessToken,
31 path: getPluginTestPath('-unloading')
35 it('Should return a numeric value', async function () {
36 const res = await makeGetRequest({
39 statusCodeExpected: HttpStatusCode.OK_200
42 expect(res.body.message).to.match(/^\d+$/)
43 value = res.body.message
46 it('Should return the same value the second time', async function () {
47 const res = await makeGetRequest({
50 statusCodeExpected: HttpStatusCode.OK_200
53 expect(res.body.message).to.be.equal(value)
56 it('Should uninstall the plugin and free the route', async function () {
57 await uninstallPlugin({
59 accessToken: server.accessToken,
60 npmName: 'peertube-plugin-test-unloading'
63 await makeGetRequest({
66 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
70 it('Should return a different numeric value', async function () {
73 accessToken: server.accessToken,
74 path: getPluginTestPath('-unloading')
76 const res = await makeGetRequest({
79 statusCodeExpected: HttpStatusCode.OK_200
82 expect(res.body.message).to.match(/^\d+$/)
83 expect(res.body.message).to.be.not.equal(value)
86 after(async function () {
87 await cleanupTests([ server ])