All checks were successful
CI / Unit & Component Tests (pull_request) Successful in 3m49s
CI / OCR Service Tests (pull_request) Successful in 25s
CI / Backend Unit Tests (pull_request) Successful in 4m7s
CI / fail2ban Regex (pull_request) Successful in 49s
CI / Semgrep Security Scan (pull_request) Successful in 24s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m10s
Intro, letter titles, curator annotations, and interludes rendered at 12-14px — copied from the scaled mockup sizes in LR-2. Narrative text is now 16-18px, meta lines and links 14px; the LR-2 impl-ref table is updated to match. Closes #800 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
import { describe, it, expect, afterEach } from 'vitest';
|
|
import { cleanup, render } from 'vitest-browser-svelte';
|
|
import { page } from 'vitest/browser';
|
|
import { m } from '$lib/paraglide/messages.js';
|
|
|
|
const { default: JourneyInterlude } = await import('./JourneyInterlude.svelte');
|
|
|
|
afterEach(cleanup);
|
|
|
|
declare global {
|
|
interface Window {
|
|
__xss_interlude?: number;
|
|
}
|
|
}
|
|
|
|
describe('JourneyInterlude', () => {
|
|
it('renders the note text as plaintext', async () => {
|
|
render(JourneyInterlude, { props: { note: 'Eine kurze Pause auf der Reise.' } });
|
|
|
|
await expect.element(page.getByText('Eine kurze Pause auf der Reise.')).toBeVisible();
|
|
});
|
|
|
|
it('has aria-label from i18n (journey_interlude_aria_label)', async () => {
|
|
render(JourneyInterlude, { props: { note: 'Notiz' } });
|
|
|
|
const el = document.querySelector(`[aria-label="${m.journey_interlude_aria_label()}"]`);
|
|
expect(el).not.toBeNull();
|
|
});
|
|
|
|
it('has role="note" so the aria-label is announced by screen readers', async () => {
|
|
render(JourneyInterlude, { props: { note: 'Notiz' } });
|
|
|
|
const el = document.querySelector('[role="note"]');
|
|
expect(el).not.toBeNull();
|
|
expect(el?.getAttribute('aria-label')).toBe(m.journey_interlude_aria_label());
|
|
});
|
|
|
|
it('note text uses readable body size (text-base, #800)', async () => {
|
|
render(JourneyInterlude, { props: { note: 'Notiz' } });
|
|
|
|
const text = document.querySelector('[role="note"] p');
|
|
expect(text!.className).toContain('text-base');
|
|
expect(text!.className).not.toContain('text-xs');
|
|
});
|
|
|
|
it('XSS: note is rendered as plaintext — injected payload does not execute', async () => {
|
|
// Interlude uses Svelte text interpolation ({note}), NOT {@html}.
|
|
render(JourneyInterlude, {
|
|
props: { note: '<img src=x onerror="window.__xss_interlude=1">' }
|
|
});
|
|
|
|
expect(window.__xss_interlude).toBeUndefined();
|
|
expect(document.body.textContent).toContain('<img src=x onerror=');
|
|
});
|
|
});
|