// ── Tests Plugin: conditional loader ── // // The test runner is heavy (40+ test files), so we only load it when: // - URL contains ?test query param → auto-run // - Ctrl+Shift+Alt+T pressed → manual open // // Tests are completely optional — without this plugin the app has no // test runner code loaded at all. const hyprcrd = window.hyprcrd; // Cache-bust the test modules so edits to test files are picked up without // a hard refresh. The browser treats each unique URL as a distinct module, // so a fresh query string on each page load forces re-import. const V = '?v=' + Date.now(); // Auto-load if ?test in query string if (new URLSearchParams(location.search).has('test')) { import('./tests.js' + V); } // Keyboard shortcut: Ctrl+Shift+Alt+T → open runner. // Import runner.js *without* the cache-busting query so we get the same // module instance that the test files register their suites into. With a // `?v=` suffix the browser treats it as a distinct module and we'd open // a fresh runner whose `suites` array is empty (→ "0/0 passed"). document.addEventListener('keydown', e => { if (e.ctrlKey && e.shiftKey && e.altKey && (e.key === 'T' || e.key === 't')) { e.preventDefault(); import('./tests.js' + V).then(() => import('./runner.js').then(m => m.open?.()) ); } }); hyprcrd?.registerPlugin?.({ name: 'tests', version: '1.0.0', description: 'UI + state test runner', });