]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/plugins/plugin-router.ts
shared/ typescript types dir server-commands
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / plugin-router.ts
index 24e6a1e834701c97c4d6b088a66135a8753871d1..58629adc7d6a3c38935308452f292fee32bee8a6 100644 (file)
@@ -1,19 +1,20 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import 'mocha'
-import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
+import { expect } from 'chai'
 import {
-  getPluginTestPath,
-  installPlugin,
+  cleanupTests,
+  createSingleServer,
   makeGetRequest,
   makePostBodyRequest,
-  setAccessTokensToServers, uninstallPlugin
-} from '../../../shared/extra-utils'
-import { expect } from 'chai'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+  PeerTubeServer,
+  PluginsCommand,
+  setAccessTokensToServers
+} 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/'
@@ -22,14 +23,10 @@ describe('Test plugin helpers', function () {
   before(async function () {
     this.timeout(30000)
 
-    server = await flushAndRunServer(1)
+    server = await createSingleServer(1)
     await setAccessTokensToServers([ server ])
 
-    await installPlugin({
-      url: server.url,
-      accessToken: server.accessToken,
-      path: getPluginTestPath('-five')
-    })
+    await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-five') })
   })
 
   it('Should answer "pong"', async function () {
@@ -37,7 +34,7 @@ describe('Test plugin helpers', 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')
@@ -50,7 +47,7 @@ describe('Test plugin helpers', function () {
         url: server.url,
         path: path + 'is-authenticated',
         token: server.accessToken,
-        statusCodeExpected: 200
+        expectedStatus: 200
       })
 
       expect(res.body.isAuthenticated).to.equal(true)
@@ -58,7 +55,7 @@ describe('Test plugin helpers', function () {
       const secRes = await makeGetRequest({
         url: server.url,
         path: path + 'is-authenticated',
-        statusCodeExpected: 200
+        expectedStatus: 200
       })
 
       expect(secRes.body.isAuthenticated).to.equal(false)
@@ -77,7 +74,7 @@ describe('Test plugin helpers', function () {
         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)
@@ -85,24 +82,20 @@ describe('Test plugin helpers', function () {
   })
 
   it('Should remove the plugin and remove the routes', async function () {
-    await uninstallPlugin({
-      url: server.url,
-      accessToken: server.accessToken,
-      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
       })
     }
   })