2020-01-31 10:56:52 -05:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
2019-07-19 04:37:35 -04:00
|
|
|
|
2021-07-05 10:37:50 -04:00
|
|
|
import { expect } from 'chai'
|
2019-07-19 04:37:35 -04:00
|
|
|
import {
|
|
|
|
cleanupTests,
|
2021-07-16 03:47:51 -04:00
|
|
|
createSingleServer,
|
2019-07-19 11:30:41 -04:00
|
|
|
killallServers,
|
2021-07-16 03:47:51 -04:00
|
|
|
PeerTubeServer,
|
2021-07-16 08:27:30 -04:00
|
|
|
PluginsCommand,
|
2019-07-19 04:37:35 -04:00
|
|
|
setAccessTokensToServers
|
2021-12-17 05:58:15 -05:00
|
|
|
} from '@shared/server-commands'
|
2019-07-19 04:37:35 -04:00
|
|
|
|
|
|
|
describe('Test plugin scripts', function () {
|
2021-07-16 03:47:51 -04:00
|
|
|
let server: PeerTubeServer
|
2019-07-19 04:37:35 -04:00
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
this.timeout(30000)
|
|
|
|
|
2021-07-16 03:47:51 -04:00
|
|
|
server = await createSingleServer(1)
|
2019-07-19 04:37:35 -04:00
|
|
|
await setAccessTokensToServers([ server ])
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should install a plugin from stateless CLI', async function () {
|
|
|
|
this.timeout(60000)
|
|
|
|
|
2021-07-07 04:33:49 -04:00
|
|
|
const packagePath = PluginsCommand.getPluginTestPath()
|
2019-07-19 04:37:35 -04:00
|
|
|
|
2021-07-16 03:04:35 -04:00
|
|
|
await server.cli.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`)
|
2019-07-19 04:37:35 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should install a theme from stateless CLI', async function () {
|
|
|
|
this.timeout(60000)
|
|
|
|
|
2021-07-16 03:04:35 -04:00
|
|
|
await server.cli.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`)
|
2019-07-19 04:37:35 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should have the theme and the plugin registered when we restart peertube', async function () {
|
|
|
|
this.timeout(30000)
|
|
|
|
|
2021-07-09 09:37:43 -04:00
|
|
|
await killallServers([ server ])
|
2021-07-16 03:47:51 -04:00
|
|
|
await server.run()
|
2019-07-19 04:37:35 -04:00
|
|
|
|
2021-07-16 03:04:35 -04:00
|
|
|
const config = await server.config.getConfig()
|
2019-07-19 04:37:35 -04:00
|
|
|
|
|
|
|
const plugin = config.plugin.registered
|
|
|
|
.find(p => p.name === 'test')
|
|
|
|
expect(plugin).to.not.be.undefined
|
|
|
|
|
|
|
|
const theme = config.theme.registered
|
|
|
|
.find(t => t.name === 'background-red')
|
|
|
|
expect(theme).to.not.be.undefined
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should uninstall a plugin from stateless CLI', async function () {
|
|
|
|
this.timeout(60000)
|
|
|
|
|
2021-07-16 03:04:35 -04:00
|
|
|
await server.cli.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
|
2019-07-19 04:37:35 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should have removed the plugin on another peertube restart', async function () {
|
|
|
|
this.timeout(30000)
|
|
|
|
|
2021-07-09 09:37:43 -04:00
|
|
|
await killallServers([ server ])
|
2021-07-16 03:47:51 -04:00
|
|
|
await server.run()
|
2019-07-19 04:37:35 -04:00
|
|
|
|
2021-07-16 03:04:35 -04:00
|
|
|
const config = await server.config.getConfig()
|
2019-07-19 04:37:35 -04:00
|
|
|
|
|
|
|
const plugin = config.plugin.registered
|
|
|
|
.find(p => p.name === 'test')
|
|
|
|
expect(plugin).to.be.undefined
|
|
|
|
})
|
|
|
|
|
|
|
|
after(async function () {
|
|
|
|
await cleanupTests([ server ])
|
|
|
|
})
|
|
|
|
})
|