Files
cesnimda 033c9ec315 test: vitest unit + playwright e2e suites; fix a11y, contrast, no-JS reveal
- vitest: dictionary parity, slug-map bijection, content-schema validation, JSON-LD (23)
- playwright: both locales, language-switch mapping (incl. no-JS), CV downloads,
  form happy-path + honeypot, axe a11y on 5 templates x 2 themes (23)
- fix: raise ink-faint + light accent to meet WCAG AA 4.5:1 (axe-verified)
- fix: gate reveal animations behind html.js so content is visible without JS
  (progressive enhancement - was hidden at opacity 0); scan reduced-motion path
- fix: validate contact form before the anti-bot time-trap (no false success)
- chore: ESLint node globals, typed diagram props, resvg fontFiles, prettier pass

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-04 06:14:18 +02:00

46 lines
1.5 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { en } from '@i18n/dictionary.en';
import { no } from '@i18n/dictionary.no';
import { interpolate } from '@i18n/t';
/** Collect all leaf key paths of a nested object. */
function keyPaths(obj: unknown, prefix = ''): string[] {
if (obj === null || typeof obj !== 'object') return [prefix];
return Object.entries(obj as Record<string, unknown>).flatMap(([k, v]) =>
keyPaths(v, prefix ? `${prefix}.${k}` : k),
);
}
describe('dictionary parity (I18N_SPEC §4.1)', () => {
it('EN and NO expose exactly the same key paths', () => {
const enKeys = keyPaths(en).sort();
const noKeys = keyPaths(no).sort();
expect(noKeys).toEqual(enKeys);
});
it('no dictionary value is empty', () => {
for (const [dict, name] of [
[en, 'en'],
[no, 'no'],
] as const) {
for (const path of keyPaths(dict)) {
const value = path
.split('.')
.reduce<unknown>((acc, k) => (acc as Record<string, unknown>)[k], dict);
expect(typeof value, `${name}.${path}`).toBe('string');
expect((value as string).length, `${name}.${path}`).toBeGreaterThan(0);
}
}
});
});
describe('interpolate', () => {
it('replaces named tokens', () => {
expect(interpolate('© {year} X', { year: 2026 })).toBe('© 2026 X');
expect(interpolate('pdf · {size} kB', { size: 132 })).toBe('pdf · 132 kB');
});
it('leaves unknown tokens untouched', () => {
expect(interpolate('{a} {b}', { a: '1' })).toBe('1 {b}');
});
});