gut brittle tests

This commit is contained in:
2026-06-26 11:24:17 +02:00
parent 40d431023a
commit 45d334a8fc
7 changed files with 35 additions and 20 deletions
+18 -7
View File
@@ -29,6 +29,13 @@ function assertExcludes(haystack, needle, message) {
);
}
function assertMatches(haystack, pattern, message) {
assert(
pattern.test(haystack),
message || `Expected file to match ${pattern}`
);
}
const header = read('templates/header.tpl');
const footer = read('templates/footer.tpl');
const topbar = read('templates/partials/header/topbar.tpl');
@@ -107,13 +114,17 @@ assertIncludes(topbar, '{{{ if allowRegistration }}}', 'Registration should rema
assertIncludes(topbar, '{{{ each navigation }}}', 'Topbar should render ACP Navigation items');
assertIncludes(topbar, '{./textClass}', 'Topbar should honor ACP Navigation text visibility classes');
assertExcludes(topbar, 'href="{relative_path}/admin"', 'Topbar should not hard-code the administrator link');
assertIncludes(topbar, 'SHADOWS OVER WESTGATE', 'Topbar brand should use the single required identity line');
assertExcludes(topbar, 'wg-topbar__brand-subtitle', 'Topbar should not repeat the site name as a subtitle');
assertExcludes(topbar, 'wg-topbar__forums', 'Topbar should not ship a separate desktop Forums dropdown');
assertExcludes(topbar, 'data-wg-menu="forums"', 'Forums should not use a custom topbar menu trigger');
assertIncludes(stylesheet, '$wg-topbar-panel-bg', 'Topbar menu surfaces should use an opaque local panel base');
assertExcludes(stylesheet, 'var(--wg-velvet-panel) !important;', 'Topbar menu surfaces should not inherit the translucent velvet panel token');
assertExcludes(stylesheet, 'text-overflow: ellipsis;', 'Topbar brand should not truncate in normal desktop layouts');
assertMatches(
topbar,
/<a\b(?=[^>]*class="[^"]*\bwg-topbar__brand\b[^"]*")(?=[^>]*aria-label="{config\.siteTitle}")/,
'Topbar brand link should use the configured site title as its accessible name'
);
assertMatches(
topbar,
/<span\b(?=[^>]*class="[^"]*\bwg-topbar__brand-name\b[^"]*")[^>]*>{config\.siteTitle}<\/span>/,
'Topbar brand text should render the configured site title'
);
assertExcludes(topbar, 'data-wg-menu', 'Topbar should rely on Bootstrap and NodeBB navigation instead of custom menu triggers');
assertMissing(
'templates/partials/header/brand.tpl',