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>
This commit is contained in:
1 parent
ccd0477841
commit
43c15b81a3
8 files changed
+241
-13
No files matched your search
@@ -70,6 +70,7 @@ describe('Card: Due Date & Done', () => {
|
||||
|
||||
it('card with #done tag shows done badge', async () => {
|
||||
if (localStorage.getItem('hyprcrd-show-done-badge') === '0') return;
|
||||
if (state.hideDone || state.hideTagged) return;
|
||||
const res = await fetch('api/cards', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() },
|
||||
body: JSON.stringify({ title: '__test_done_badge__', body: '#done', color: '#38bdf8' }),
|
||||
@@ -110,7 +111,7 @@ describe('Card: Context Menu Actions', () => {
|
||||
rightClick(card);
|
||||
await sleep(150);
|
||||
const favBtn = $$('#ctx-items [data-action="favorite"]')[0];
|
||||
const wasFav = favBtn?.textContent.includes('unfavorite');
|
||||
const wasFav = favBtn?.textContent.toLowerCase().includes('unfavorite');
|
||||
click(favBtn);
|
||||
await sleep(200);
|
||||
|
||||
@@ -118,13 +119,53 @@ describe('Card: Context Menu Actions', () => {
|
||||
rightClick(card);
|
||||
await sleep(150);
|
||||
const favBtn2 = $$('#ctx-items [data-action="favorite"]')[0];
|
||||
const isFav = favBtn2?.textContent.includes('unfavorite');
|
||||
const isFav = favBtn2?.textContent.toLowerCase().includes('unfavorite');
|
||||
expect(isFav).toBe(!wasFav);
|
||||
// Toggle back
|
||||
click(favBtn2);
|
||||
await sleep(100);
|
||||
});
|
||||
|
||||
it('mark done toggles #done on cards without due_date', async () => {
|
||||
// After clicking, the card has #done — if either filter is on it would
|
||||
// disappear from the board before the second right-click can find it.
|
||||
if (state.hideDone || state.hideTagged) return;
|
||||
// Create a card with no due_date — Mark done used to be hidden in this case
|
||||
const res = await fetch('api/cards', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() },
|
||||
body: JSON.stringify({ title: '__test_mark_done__', body: 'plain text', color: '#38bdf8' }),
|
||||
}).then(r => r.json());
|
||||
await window._reloadAll?.();
|
||||
await sleep(200);
|
||||
|
||||
const cardEl = document.querySelector(`[data-id="${res.id}"]`);
|
||||
if (!cardEl) return;
|
||||
rightClick(cardEl);
|
||||
await sleep(150);
|
||||
|
||||
// The action must always be present, even with no due_date
|
||||
const doneBtn = $$('#ctx-items [data-action="due-done"]')[0];
|
||||
expect(doneBtn).toExist();
|
||||
expect(doneBtn.textContent.toLowerCase()).toContain('mark done');
|
||||
|
||||
click(doneBtn);
|
||||
await sleep(300);
|
||||
let updated = await fetch(`api/cards?ids=${res.id}`).then(r => r.json());
|
||||
expect((updated[0].body || '').toLowerCase()).toContain('#done');
|
||||
expect(updated[0].tags || '').toContain('done');
|
||||
|
||||
// Re-open menu — the entry should now flip to "Unmark done"
|
||||
rightClick(document.querySelector(`[data-id="${res.id}"]`));
|
||||
await sleep(150);
|
||||
const doneBtn2 = $$('#ctx-items [data-action="due-done"]')[0];
|
||||
expect(doneBtn2.textContent.toLowerCase()).toContain('unmark');
|
||||
|
||||
click(doneBtn2);
|
||||
await sleep(300);
|
||||
updated = await fetch(`api/cards?ids=${res.id}`).then(r => r.json());
|
||||
expect((updated[0].body || '').toLowerCase().includes('#done')).toBe(false);
|
||||
});
|
||||
|
||||
it('color submenu changes card color', async () => {
|
||||
const res = await fetch('api/cards', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() },
|
||||
|
||||
Reference in new issue
Block a user