Files
hyprcrd/public/plugins/tests/loader.js
T
thandClaude Opus 4.6 43c15b81a3 tests: rebind runner to Ctrl+Shift+Alt+T and cover recent fixes
Plugin loader + runner shortcut moves to Ctrl+Shift+Alt+T (the old
Ctrl+Shift+T conflicts with the browser "reopen closed tab"). Loader
now imports runner.js *without* the cache-busting query so it picks
up the same module instance the test files register their suites
into — previously the shortcut opened a fresh runner with an empty
suites array and reported 0/0 passed.

New / fixed coverage:
- card-interactions: favorite toggle assertion is now case-insensitive
  (context menu was capitalized to "Unfavorite"/"Favorite" earlier);
  done-badge test guards against state.hideDone / hideTagged that would
  filter the test card off the board; new test for the always-on
  Mark done / Unmark done toggle on a card without due_date.
- context-menu: copy-text action exists; copy-text strips fenced code
  blocks, image markdown and inline #tags. Mocks navigator.clipboard
  via Object.defineProperty so the assertion works without a focused
  / secure-context clipboard.
- export: round-trip preserves a custom bucket color (covers the import
  handler regression that was wiping bucket colors on every test run).
- theme: design preset selection persists in localStorage across
  settings open/close, refreshPresetSelect ignores unknown keys.
  afterEach restores both hyprcrd-design-active-preset and
  hyprcrd-design so a test run can't permanently swap the user's
  design.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 18:50:25 +02:00

41 lines
1.5 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+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',
});