import assert from 'node:assert/strict' import { existsSync, readFileSync, readdirSync } from 'node:fs' import { test } from 'node:test' import { escapeHtml, htmlToText, loadTemplate, renderMail, templateIds } from '../server/services/mailTemplates.js' import { contractAttachmentFor, termsDocFor } from '../server/services/products.js' const DIR = new URL('../server/mail-templates/', import.meta.url) // K12, K14 und T12 (Wechsel ins Wartungs-Abo) aus Task 9, K13 und T13 (Zusatzspeicher) aus Task 8 (Fix 1); // Endfassung der Texte in Task 12 (T14 „Löschfristen“ kommt mit Task 21 dazu) const EXPECTED = [ ...Array.from({ length: 11 }, (_, i) => `K${String(i + 1).padStart(2, '0')}`), 'K12', 'K13', 'K14', ...Array.from({ length: 11 }, (_, i) => `T${String(i + 1).padStart(2, '0')}`), 'T12', 'T13', ] const sampleValues = (tpl) => Object.fromEntries(tpl.placeholders.map((p) => [p, `Wert-${p}`])) const allBlocks = (tpl, on) => Object.fromEntries(tpl.blocks.map((b) => [b, on])) test('alle Vorlagen sind da', () => { assert.deepEqual(templateIds(), EXPECTED) }) for (const id of EXPECTED) { test(`${id}: Kopfkommentar passt zur Vorlage`, () => { const tpl = loadTemplate(id) const source = readFileSync(new URL(tpl.file, DIR), 'utf8') const title = source.match(/