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,
|
2021-07-16 02:47:51 -05:00
|
|
|
createSingleServer,
|
2020-08-24 06:37:49 -05:00
|
|
|
makeHTMLRequest,
|
2021-07-16 02:47:51 -05:00
|
|
|
PeerTubeServer,
|
2021-07-16 07:27:30 -05:00
|
|
|
PluginsCommand,
|
2021-07-07 03:33:49 -05:00
|
|
|
setAccessTokensToServers
|
2021-12-17 04:58:15 -06:00
|
|
|
} from '@shared/server-commands'
|
2020-08-24 06:37:49 -05:00
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
2021-06-17 03:43:34 -05:00
|
|
|
describe('Test plugins HTML injection', function () {
|
2021-07-16 02:47:51 -05:00
|
|
|
let server: PeerTubeServer = 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)
|
|
|
|
|
2021-07-16 02:47:51 -05:00
|
|
|
server = await createSingleServer(1)
|
2020-08-24 06:37:49 -05:00
|
|
|
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 ])
|
|
|
|
})
|
|
|
|
})
|