/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import 'mocha'
import { expect } from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
import {
cleanupTests,
- flushAndRunServer,
+ createSingleServer,
makeGetRequest,
makePostBodyRequest,
+ PeerTubeServer,
PluginsCommand,
- ServerInfo,
setAccessTokensToServers
-} from '@shared/extra-utils'
+} from '@shared/server-commands'
+import { HttpStatusCode } from '@shared/models'
describe('Test plugin helpers', function () {
- let server: ServerInfo
+ let server: PeerTubeServer
const basePaths = [
'/plugins/test-five/router/',
'/plugins/test-five/0.0.1/router/'
before(async function () {
this.timeout(30000)
- server = await flushAndRunServer(1)
+ server = await createSingleServer(1)
await setAccessTokensToServers([ server ])
- await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-five') })
+ await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-five') })
})
it('Should answer "pong"', async function () {
const res = await makeGetRequest({
url: server.url,
path: path + 'ping',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body.message).to.equal('pong')
url: server.url,
path: path + 'is-authenticated',
token: server.accessToken,
- statusCodeExpected: 200
+ expectedStatus: 200
})
expect(res.body.isAuthenticated).to.equal(true)
const secRes = await makeGetRequest({
url: server.url,
path: path + 'is-authenticated',
- statusCodeExpected: 200
+ expectedStatus: 200
})
expect(secRes.body.isAuthenticated).to.equal(false)
url: server.url,
path: path + 'form/post/mirror',
fields: body,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body).to.deep.equal(body)
})
it('Should remove the plugin and remove the routes', async function () {
- await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-five' })
+ await server.plugins.uninstall({ npmName: 'peertube-plugin-test-five' })
for (const path of basePaths) {
await makeGetRequest({
url: server.url,
path: path + 'ping',
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
await makePostBodyRequest({
url: server.url,
path: path + 'ping',
fields: {},
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
}
})