Files
hyprcrd/public/plugins/tests/loader.js
T
2026-04-11 01:45:36 +02:00

37 lines
1.1 KiB
JavaScript

// ── 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+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+T → open runner
document.addEventListener('keydown', e => {
if (e.ctrlKey && e.shiftKey && e.key === 'T') {
e.preventDefault();
import('./tests.js' + V).then(() =>
import('./runner.js' + V).then(m => m.open?.())
);
}
});
hyprcrd?.registerPlugin?.({
name: 'tests',
version: '1.0.0',
description: 'UI + state test runner',
});