2020-08-24 13:37:49 +02:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
|
|
|
|
|
|
|
import 'mocha'
|
|
|
|
import * as chai from 'chai'
|
|
|
|
import {
|
|
|
|
cleanupTests,
|
2021-07-16 09:47:51 +02:00
|
|
|
createSingleServer,
|
2020-08-24 13:37:49 +02:00
|
|
|
makeHTMLRequest,
|
2021-07-16 09:47:51 +02:00
|
|
|
PeerTubeServer,
|
2021-07-16 14:27:30 +02:00
|
|
|
PluginsCommand,
|
2021-07-07 10:33:49 +02:00
|
|
|
setAccessTokensToServers
|
2020-08-24 13:37:49 +02:00
|
|
|
} from '../../../shared/extra-utils'
|
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
2021-06-17 10:43:34 +02:00
|
|
|
describe('Test plugins HTML injection', function () {
|
2021-07-16 09:47:51 +02:00
|
|
|
let server: PeerTubeServer = null
|
2021-07-07 10:33:49 +02:00
|
|
|
let command: PluginsCommand
|
2020-08-24 13:37:49 +02:00
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
this.timeout(30000)
|
|
|
|
|
2021-07-16 09:47:51 +02:00
|
|
|
server = await createSingleServer(1)
|
2020-08-24 13:37:49 +02:00
|
|
|
await setAccessTokensToServers([ server ])
|
2021-07-07 10:33:49 +02:00
|
|
|
|
2021-07-16 09:04:35 +02:00
|
|
|
command = server.plugins
|
2020-08-24 13:37:49 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not inject global css file in HTML', async function () {
|
|
|
|
{
|
2021-07-07 10:33:49 +02:00
|
|
|
const text = await command.getCSS()
|
|
|
|
expect(text).to.be.empty
|
2020-08-24 13:37:49 +02: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 10:33:49 +02:00
|
|
|
await command.install({ npmName: 'peertube-plugin-hello-world' })
|
2020-08-24 13:37:49 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should have the correct global css', async function () {
|
|
|
|
{
|
2021-07-07 10:33:49 +02:00
|
|
|
const text = await command.getCSS()
|
|
|
|
expect(text).to.contain('background-color: red')
|
2020-08-24 13:37:49 +02: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 10:33:49 +02:00
|
|
|
await command.uninstall({ npmName: 'peertube-plugin-hello-world' })
|
2020-08-24 13:37:49 +02:00
|
|
|
|
|
|
|
{
|
2021-07-07 10:33:49 +02:00
|
|
|
const text = await command.getCSS()
|
|
|
|
expect(text).to.be.empty
|
2020-08-24 13:37:49 +02: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 ])
|
|
|
|
})
|
|
|
|
})
|