test(email): add structural guard for shared email partials

This commit is contained in:
2026-06-26 23:28:43 +02:00
parent bf5c710c2b
commit 7f2f7810fe
3 changed files with 33 additions and 3 deletions
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env node
// ponytail: 30-line structural guard, not a render test. Catches drift, not pixels.
const fs = require('fs');
const path = require('path');
const dir = path.join(__dirname, '..', 'email');
const files = fs.readdirSync(dir).filter((f) => f.endsWith('.html'));
const failures = [];
for (const f of files) {
const src = fs.readFileSync(path.join(dir, f), 'utf8');
const checks = [
[/IMPORT emails\/partials\/header\.(html|tpl)/, 'missing header IMPORT'],
[/IMPORT emails\/partials\/footer\.(html|tpl)/, 'missing footer IMPORT'],
[/<!-- preheader -->/, 'missing preheader marker'],
];
for (const [re, msg] of checks) {
if (!re.test(src)) failures.push(`${f}: ${msg}`);
}
}
if (failures.length) {
console.error('Email template check FAILED:\n' + failures.join('\n'));
process.exit(1);
}
console.log(`Email template check passed (${files.length} templates).`);