Taalbestanden: indeling gelijk aan ASF (common, site, home, era), baseline-check van de prerender en lint-waarschuwingen voor losse tekst, docs/translations.md

Prerender-uitvoer blijft byte-identiek.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 20:40:51 +01:00
co-authored by Claude Sonnet 5.5
parent 6c6fd771dd
commit 2f614151df
32 changed files with 1405 additions and 104 deletions
+69
View File
@@ -0,0 +1,69 @@
import { describe, expect, it } from 'vitest';
import { firstDifferences, normalizeHtml } from './htmlBaseline.mjs';
describe('normalizeHtml', () => {
it('keeps text, links, labels, meta, structured data and the data block', () => {
const html =
'<html><head><title>Titel</title><meta name="description" content="Tekst"/>' +
'<link rel="canonical" href="https://a.nl/"/></head><body>' +
'<a href="/over-mij" aria-label="Naar over mij">Over mij</a>' +
'<script type="application/ld+json">{"a":1}</script>' +
'<script type="application/json" id="cms">{"b":2}</script></body></html>';
const out = normalizeHtml(html);
for (const part of [
'<title>Titel</title>',
'content="Tekst"',
'rel="canonical"',
'aria-label="Naar over mij"',
'Over mij',
'{"a":1}',
'{"b":2}',
]) {
expect(out).toContain(part);
}
});
it('leaves out look and build details', () => {
const html =
'<style>.a{}</style><script type="module" src="/assets/x-AbCd1234.js"></script>' +
'<link rel="stylesheet" href="/assets/y-AbCd1234.css"/><!-- opmerking -->' +
'<div class="css-1abc" style="color:red" id="x">tekst</div>' +
'<img src="/assets/foto-AbCd1234.jpg"/><noscript><style>.b{}</style></noscript>';
const out = normalizeHtml(html);
expect(out).not.toMatch(/css-1abc|color:red|opmerking|\.a\{|stylesheet|AbCd1234\.js/);
expect(out).toContain('<div id="x">');
expect(out).toContain('/assets/foto.jpg');
expect(out).toContain('<noscript>\n</noscript>');
});
it('ignores formatting but notices a changed text', () => {
const a = normalizeHtml('<p>Hallo</p>\n\n <p>wereld</p>');
const b = normalizeHtml('<p>Hallo</p><p>wereld</p>');
expect(a).toBe(b);
expect(normalizeHtml('<p>Hallo</p><p>werelden</p>')).not.toBe(a);
});
});
describe('firstDifferences', () => {
it('reports the lines that differ and nothing for equal input', () => {
expect(firstDifferences('a\nb', 'a\nb')).toEqual([]);
const out = firstDifferences('a\nb\nc', 'a\nx\nc').join('\n');
expect(out).toContain('regel 2');
expect(out).toContain('basislijn: b');
expect(out).toContain('nu: x');
});
it('limits the number of reported differences', () => {
const many = Array.from({ length: 20 }, (_, i) => `r${i}`).join('\n');
const other = Array.from({ length: 20 }, (_, i) => `s${i}`).join('\n');
expect(firstDifferences(many, other, 2)).toHaveLength(6);
});
});
describe('normalizeHtml tags', () => {
it('ignores line breaks and indentation inside a tag', () => {
expect(normalizeHtml('<meta\n property="a"\n content="b"\n />')).toBe(
normalizeHtml('<meta property="a" content="b"/>'),
);
});
});