plugins.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
  2. import 'mocha'
  3. import { expect } from 'chai'
  4. import {
  5. cleanupTests,
  6. createSingleServer,
  7. killallServers,
  8. PeerTubeServer,
  9. PluginsCommand,
  10. setAccessTokensToServers
  11. } from '@shared/server-commands'
  12. describe('Test plugin scripts', function () {
  13. let server: PeerTubeServer
  14. before(async function () {
  15. this.timeout(30000)
  16. server = await createSingleServer(1)
  17. await setAccessTokensToServers([ server ])
  18. })
  19. it('Should install a plugin from stateless CLI', async function () {
  20. this.timeout(60000)
  21. const packagePath = PluginsCommand.getPluginTestPath()
  22. await server.cli.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`)
  23. })
  24. it('Should install a theme from stateless CLI', async function () {
  25. this.timeout(60000)
  26. await server.cli.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`)
  27. })
  28. it('Should have the theme and the plugin registered when we restart peertube', async function () {
  29. this.timeout(30000)
  30. await killallServers([ server ])
  31. await server.run()
  32. const config = await server.config.getConfig()
  33. const plugin = config.plugin.registered
  34. .find(p => p.name === 'test')
  35. expect(plugin).to.not.be.undefined
  36. const theme = config.theme.registered
  37. .find(t => t.name === 'background-red')
  38. expect(theme).to.not.be.undefined
  39. })
  40. it('Should uninstall a plugin from stateless CLI', async function () {
  41. this.timeout(60000)
  42. await server.cli.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
  43. })
  44. it('Should have removed the plugin on another peertube restart', async function () {
  45. this.timeout(30000)
  46. await killallServers([ server ])
  47. await server.run()
  48. const config = await server.config.getConfig()
  49. const plugin = config.plugin.registered
  50. .find(p => p.name === 'test')
  51. expect(plugin).to.be.undefined
  52. })
  53. after(async function () {
  54. await cleanupTests([ server ])
  55. })
  56. })