2020-08-24 06:37:49 -05:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
|
|
|
|
|
|
|
import 'mocha'
|
|
|
|
import * as chai from 'chai'
|
|
|
|
import {
|
|
|
|
cleanupTests,
|
|
|
|
flushAndRunServer,
|
|
|
|
makeHTMLRequest,
|
2021-07-07 03:33:49 -05:00
|
|
|
PluginsCommand,
|
2020-08-24 06:37:49 -05:00
|
|
|
ServerInfo,
|
2021-07-07 03:33:49 -05:00
|
|
|
setAccessTokensToServers
|
2020-08-24 06:37:49 -05:00
|
|
|
} from '../../../shared/extra-utils'
|
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
2021-06-17 03:43:34 -05:00
|
|
|
describe('Test plugins HTML injection', function () {
|
2020-08-24 06:37:49 -05:00
|
|
|
let server: ServerInfo = null
|
2021-07-07 03:33:49 -05:00
|
|
|
let command: PluginsCommand
|
2020-08-24 06:37:49 -05:00
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
this.timeout(30000)
|
|
|
|
|
|
|
|
server = await flushAndRunServer(1)
|
|
|
|
await setAccessTokensToServers([ server ])
|
2021-07-07 03:33:49 -05:00
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
command = server.plugins
|
2020-08-24 06:37:49 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not inject global css file in HTML', async function () {
|
|
|
|
{
|
2021-07-07 03:33:49 -05:00
|
|
|
const text = await command.getCSS()
|
|
|
|
expect(text).to.be.empty
|
2020-08-24 06:37:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) {
|
|
|
|
const res = await makeHTMLRequest(server.url, path)
|
|
|
|
expect(res.text).to.not.include('link rel="stylesheet" href="/plugins/global.css')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should install a plugin and a theme', async function () {
|
|
|
|
this.timeout(30000)
|
|
|
|
|
2021-07-07 03:33:49 -05:00
|
|
|
await command.install({ npmName: 'peertube-plugin-hello-world' })
|
2020-08-24 06:37:49 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should have the correct global css', async function () {
|
|
|
|
{
|
2021-07-07 03:33:49 -05:00
|
|
|
const text = await command.getCSS()
|
|
|
|
expect(text).to.contain('background-color: red')
|
2020-08-24 06:37:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) {
|
|
|
|
const res = await makeHTMLRequest(server.url, path)
|
|
|
|
expect(res.text).to.include('link rel="stylesheet" href="/plugins/global.css')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should have an empty global css on uninstall', async function () {
|
2021-07-07 03:33:49 -05:00
|
|
|
await command.uninstall({ npmName: 'peertube-plugin-hello-world' })
|
2020-08-24 06:37:49 -05:00
|
|
|
|
|
|
|
{
|
2021-07-07 03:33:49 -05:00
|
|
|
const text = await command.getCSS()
|
|
|
|
expect(text).to.be.empty
|
2020-08-24 06:37:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) {
|
|
|
|
const res = await makeHTMLRequest(server.url, path)
|
|
|
|
expect(res.text).to.not.include('link rel="stylesheet" href="/plugins/global.css')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
after(async function () {
|
|
|
|
await cleanupTests([ server ])
|
|
|
|
})
|
|
|
|
})
|