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) // G01–G08 Gästemails des Terminplaners (Task 9, neutrales Layout im Auftrag eines Betriebs), K20 und K21 Hinweise an den Betrieb; // 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“ aus Task 21 (F39); T15 Push-Zeitmail; K15, K16, T16 Funktionen (News-Pinnwand); T17 Repo zuordnen; K17 Chat-Hinweis an Kunden; K18, K19 Website-Analyse; T18 Bankzugang erneuern (Finanzen) const ids = (prefix, count) => Array.from({ length: count }, (_, i) => `${prefix}${String(i + 1).padStart(2, '0')}`) const EXPECTED = [...ids('G', 8), ...ids('K', 21), ...ids('T', 18)] const GUEST = ids('G', 8) 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(/