Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576/** E2e tests for `onLoadSetCssFromUrlParams`. Drives the test harness in `test/harness.html` via Playwright; `loadHarness` injects the built bundle inline so `globalThis.moduleDom` is available regardless of browser-specific `file://` module-script restrictions. @module */import { expect, test,} from '@playwright/test';
import { loadHarness, } from '../test-setup.ts';
test.describe('onLoadSetCssFromUrlParams', () => { test('applies every URL param when no allowlist is supplied', async ({ page, },) => { await loadHarness({ page, query: '--brand=red&font-size=16px', },);
const result = await page.evaluate(function callUnfiltered() { globalThis.moduleDom.onLoadSetCssFromUrlParams(); return { brand: document.documentElement.style.getPropertyValue('--brand',), fontSize: document.documentElement.style.getPropertyValue('font-size',), }; },);
expect(result.brand,).toBe('red',); expect(result.fontSize,).toBe('16px',); });
test('applies only allow-listed keys when an allowlist is supplied', async ({ page, },) => { await loadHarness({ page, query: '--brand=red&font-size=16px', },);
const result = await page.evaluate(function callFiltered() { globalThis.moduleDom.onLoadSetCssFromUrlParams(['--brand',],); return { brand: document.documentElement.style.getPropertyValue('--brand',), fontSize: document.documentElement.style.getPropertyValue('font-size',), }; },);
expect(result.brand,).toBe('red',); expect(result.fontSize,).toBe('',); });
test('is a no-op when the query string has no matching keys', async ({ page, },) => { await loadHarness({ page, query: '--brand=red', },);
const result = await page.evaluate(function callMismatch() { globalThis.moduleDom.onLoadSetCssFromUrlParams(['--nonexistent',],); return { brand: document.documentElement.style.getPropertyValue('--brand',), nonexistent: document.documentElement.style.getPropertyValue('--nonexistent',), }; },);
expect(result.brand,).toBe('',); expect(result.nonexistent,).toBe('',); });
test('silently drops unknown standard CSS keys via setProperty', async ({ page, },) => { await loadHarness({ page, query: 'notacssprop=anything', },);
const result = await page.evaluate(function callUnknown() { globalThis.moduleDom.onLoadSetCssFromUrlParams(); return { notacssprop: document.documentElement.style.getPropertyValue('notacssprop',), }; },);
expect(result.notacssprop,).toBe('',); });});