test: globale Navigation und Suche absichern
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
const root = process.cwd();
|
||||
const read = relative => fs.readFileSync(path.join(root, relative), 'utf8');
|
||||
const js = read('public/global-navigation-ux.js');
|
||||
const css = read('public/global-navigation-ux.css');
|
||||
const loader = read('public/module-extension-workspace.js');
|
||||
const html = read('public/index.html');
|
||||
const pkg = JSON.parse(read('package.json'));
|
||||
const failures = [];
|
||||
const expect = (condition, message) => { if (!condition) failures.push(message); };
|
||||
const includesAll = (source, values, label) => values.forEach(value => expect(source.includes(value), `${label}: ${value}`));
|
||||
|
||||
includesAll(html, ['id="topbar"','id="topbar-search-btn"','class="topbar-context"','.nav-item active','data-tab="dashboard"'], 'Bestehender Navigations-DOM-Vertrag fehlt');
|
||||
includesAll(loader, ['loadGlobalNavigationAssets','global-navigation-ux.css?v=1.44.0','global-navigation-ux.js?v=1.44.0','data-ux-global-navigation'], 'Asset-Loader fehlt');
|
||||
includesAll(js, ['uxGlobalNavigationReady','Ctrl','metaKey','ctrlKey','history.pushState','history.replaceState','history.back','history.forward','popstate','Alt + Pfeil links','ux-nav-back','ux-nav-forward','ux-global-search','aria-modal','role', 'Escape', 'ArrowDown', 'ArrowUp', 'Enter'], 'Globale Navigation unvollständig');
|
||||
includesAll(css, ['.ux-nav-history','.ux-nav-history-button','.ux-global-search','.ux-global-search-panel','.ux-global-search-result','@media(max-width:620px)','@media(prefers-reduced-motion:reduce)',':focus-visible','var(--'], 'Globale Navigation CSS unvollständig');
|
||||
expect(pkg.scripts?.['verify:global-navigation'] === 'node tools/verify-global-navigation-ux-1.44.0.mjs', 'verify:global-navigation fehlt');
|
||||
expect(pkg.scripts?.['verify:all']?.includes('npm run verify:global-navigation'), 'verify:all enthält Global-Navigation-Gate nicht');
|
||||
expect(!/\bfetch\s*\(/.test(js), 'Globale Suche darf keine Netzwerkaufrufe ausführen');
|
||||
expect(!/\b(?:POST|PUT|PATCH|DELETE)\b/.test(js), 'Globale Suche darf keine Schreiboperationen implementieren');
|
||||
expect(!/\.innerHTML\s*=/.test(js), 'Globale Suche darf innerHTML nicht setzen');
|
||||
expect(!/confirm\s*\(/.test(js), 'Globale Suche darf keine kritischen Aktionen bestätigen');
|
||||
expect(!/(publish|delete|remove|install|enable|disable)\s*\(/i.test(js), 'Globale Suche darf produktive Aktionen nicht direkt ausführen');
|
||||
expect(!/setInterval\s*\(/.test(js), 'Globale Navigation darf kein Polling starten');
|
||||
|
||||
if (failures.length) {
|
||||
console.error('Global Navigation UX Gate fehlgeschlagen:');
|
||||
failures.forEach(failure => console.error(`- ${failure}`));
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('Global Navigation UX Gate bestanden.');
|
||||
Reference in New Issue
Block a user