Hero-module: hero beheren vanuit het CMS #17

Merged
Sluijsens merged 48 commits from feature/hero-module into master 2026-11-17 12:55:14 +01:00
Showing only changes of commit 28b1c6d013 - Show all commits
+4 -7
View File
@@ -1,12 +1,10 @@
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { describe, expect, it } from 'vitest';
import html from '../index.html?raw';
import themeScript from '../public/theme-init.js?raw';
// The host sends Content-Security-Policy "script-src 'self'": an inline script in the admin page is blocked there, so the
// page must have none (the theme is set by /theme-init.js, a file of its own).
describe('the admin page and the Content-Security-Policy', () => {
const html = readFileSync(resolve(__dirname, '../index.html'), 'utf-8');
it('has no inline script', () => {
const inline = [...html.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)].filter(([, attributes]) => !/\bsrc\s*=/.test(attributes));
@@ -16,9 +14,8 @@ describe('the admin page and the Content-Security-Policy', () => {
it('sets the theme from a file of its own, before the app', () => {
expect(html.indexOf('src="/theme-init.js"')).toBeGreaterThan(-1);
expect(html.indexOf('src="/theme-init.js"')).toBeLessThan(html.indexOf('src="/src/main.tsx"'));
const script = readFileSync(resolve(__dirname, '../public/theme-init.js'), 'utf-8');
expect(script).toContain("localStorage.getItem('cms-theme')");
expect(script).toContain('classList.add');
expect(themeScript).toContain("localStorage.getItem('cms-theme')");
expect(themeScript).toContain('classList.add');
});
it('has no inline event handlers or javascript: links either', () => {