]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/plugins.ts
Reorganize imports
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / plugins.ts
index a81ac961a64131ac109fad3ed80c58c9cdf45145..5f9f4ffddf99bd8f27036e1208a4448aa9dda020 100644 (file)
@@ -2,26 +2,22 @@
 
 import 'mocha'
 import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
 import {
   cleanupTests,
-  flushAndRunServer,
-  getMyUserInformation,
+  createSingleServer,
   killallServers,
+  PeerTubeServer,
   PluginsCommand,
-  reRunServer,
-  ServerInfo,
   setAccessTokensToServers,
   testHelloWorldRegisteredSettings,
-  updateMyUser,
   wait
 } from '@shared/extra-utils'
-import { PluginType, User } from '@shared/models'
+import { HttpStatusCode, PluginType } from '@shared/models'
 
 const expect = chai.expect
 
 describe('Test plugins', function () {
-  let server: ServerInfo = null
+  let server: PeerTubeServer = null
   let command: PluginsCommand
 
   before(async function () {
@@ -32,10 +28,10 @@ describe('Test plugins', function () {
         index: { check_latest_versions_interval: '5 seconds' }
       }
     }
-    server = await flushAndRunServer(1, configOverride)
+    server = await createSingleServer(1, configOverride)
     await setAccessTokensToServers([ server ])
 
-    command = server.pluginsCommand
+    command = server.plugins
   })
 
   it('Should list and search available plugins and themes', async function () {
@@ -99,7 +95,7 @@ describe('Test plugins', function () {
   })
 
   it('Should have the plugin loaded in the configuration', async function () {
-    const config = await server.configCommand.getConfig()
+    const config = await server.config.getConfig()
 
     const theme = config.theme.registered.find(r => r.name === 'background-red')
     expect(theme).to.not.be.undefined
@@ -109,25 +105,21 @@ describe('Test plugins', function () {
   })
 
   it('Should update the default theme in the configuration', async function () {
-    await server.configCommand.updateCustomSubConfig({
+    await server.config.updateCustomSubConfig({
       newConfig: {
         theme: { default: 'background-red' }
       }
     })
 
-    const config = await server.configCommand.getConfig()
+    const config = await server.config.getConfig()
     expect(config.theme.default).to.equal('background-red')
   })
 
   it('Should update my default theme', async function () {
-    await updateMyUser({
-      url: server.url,
-      accessToken: server.accessToken,
-      theme: 'background-red'
-    })
+    await server.users.updateMe({ theme: 'background-red' })
 
-    const res = await getMyUserInformation(server.url, server.accessToken)
-    expect((res.body as User).theme).to.equal('background-red')
+    const user = await server.users.getMyInfo()
+    expect(user.theme).to.equal('background-red')
   })
 
   it('Should list plugins and themes', async function () {
@@ -193,7 +185,7 @@ describe('Test plugins', function () {
   it('Should have watched settings changes', async function () {
     this.timeout(10000)
 
-    await server.serversCommand.waitUntilLog('Settings changed!')
+    await server.servers.waitUntilLog('Settings changed!')
   })
 
   it('Should get a plugin and a theme', async function () {
@@ -240,7 +232,7 @@ describe('Test plugins', function () {
     await wait(6000)
 
     // Fake update our plugin version
-    await server.sqlCommand.setPluginVersion('hello-world', '0.0.1')
+    await server.sql.setPluginVersion('hello-world', '0.0.1')
 
     // Fake update package.json
     const packageJSON = await command.getPackageJSON('peertube-plugin-hello-world')
@@ -251,7 +243,7 @@ describe('Test plugins', function () {
 
     // Restart the server to take into account this change
     await killallServers([ server ])
-    await reRunServer(server)
+    await server.run()
 
     {
       const body = await command.list({ pluginType: PluginType.PLUGIN })
@@ -299,7 +291,7 @@ describe('Test plugins', function () {
   })
 
   it('Should have updated the configuration', async function () {
-    const config = await server.configCommand.getConfig()
+    const config = await server.config.getConfig()
 
     expect(config.theme.default).to.equal('default')
 
@@ -311,8 +303,8 @@ describe('Test plugins', function () {
   })
 
   it('Should have updated the user theme', async function () {
-    const res = await getMyUserInformation(server.url, server.accessToken)
-    expect((res.body as User).theme).to.equal('instance-default')
+    const user = await server.users.getMyInfo()
+    expect(user.theme).to.equal('instance-default')
   })
 
   it('Should not install a broken plugin', async function () {
@@ -332,7 +324,7 @@ describe('Test plugins', function () {
     await check()
 
     await killallServers([ server ])
-    await reRunServer(server)
+    await server.run()
 
     await check()
   })