]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/plugins.ts
Merge branch 'master' into release/3.3.0
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / plugins.ts
index 1c6eabe6d6cb5f0f4910377b29562e3771137dfd..6b61c7c33705384733584872d4fe6d7d7daa62f0 100644 (file)
@@ -2,6 +2,7 @@
 
 import 'mocha'
 import * as chai from 'chai'
+import { HttpStatusCode } from '@shared/core-utils'
 import {
   cleanupTests,
   closeAllSequelize,
@@ -10,6 +11,7 @@ import {
   getMyUserInformation,
   getPlugin,
   getPluginPackageJSON,
+  getPluginTestPath,
   getPublicSettings,
   installPlugin,
   killallServers,
@@ -28,14 +30,8 @@ import {
   updatePluginSettings,
   wait,
   waitUntilLog
-} from '../../../../shared/extra-utils'
-import { PeerTubePluginIndex } from '../../../../shared/models/plugins/peertube-plugin-index.model'
-import { PeerTubePlugin } from '../../../../shared/models/plugins/peertube-plugin.model'
-import { PluginPackageJson } from '../../../../shared/models/plugins/plugin-package-json.model'
-import { PluginType } from '../../../../shared/models/plugins/plugin.type'
-import { PublicServerSetting } from '../../../../shared/models/plugins/public-server.setting'
-import { ServerConfig } from '../../../../shared/models/server'
-import { User } from '../../../../shared/models/users'
+} from '@shared/extra-utils'
+import { PeerTubePlugin, PeerTubePluginIndex, PluginPackageJson, PluginType, PublicServerSetting, ServerConfig, User } from '@shared/models'
 
 const expect = chai.expect
 
@@ -290,7 +286,7 @@ describe('Test plugins', function () {
   })
 
   it('Should update the plugin and the theme', async function () {
-    this.timeout(30000)
+    this.timeout(90000)
 
     // Wait the scheduler that get the latest plugins versions
     await wait(6000)
@@ -406,6 +402,36 @@ describe('Test plugins', function () {
     expect((res.body as User).theme).to.equal('instance-default')
   })
 
+  it('Should not install a broken plugin', async function () {
+    this.timeout(60000)
+
+    async function check () {
+      const res = await listPlugins({
+        url: server.url,
+        accessToken: server.accessToken,
+        pluginType: PluginType.PLUGIN
+      })
+
+      const plugins: PeerTubePlugin[] = res.body.data
+
+      expect(plugins.find(p => p.name === 'test-broken')).to.not.exist
+    }
+
+    await installPlugin({
+      url: server.url,
+      accessToken: server.accessToken,
+      path: getPluginTestPath('-broken'),
+      expectedStatus: HttpStatusCode.BAD_REQUEST_400
+    })
+
+    await check()
+
+    killallServers([ server ])
+    await reRunServer(server)
+
+    await check()
+  })
+
   after(async function () {
     await closeAllSequelize([ server ])
     await cleanupTests([ server ])