Files
hyprcrd/public/plugins/tests/multiselect.test.js
T
thandClaude Opus 4.6 fe3399a44b tests: in-run progress strip + cache-bust runner.js across files
* runner.js: shows a 30px fixed-top progress strip during runs (label
  "test x/total:", current suite/test name with ellipsis on the left,
  fixed 50%-wide progress fill on the right that turns danger-red on
  the first failure). The DOM node is created in loader.js so it appears
  immediately on shortcut press; runner.js only updates it. The fill
  width is fixed at flex:0 0 50% so it doesn't jiggle as the test name
  changes length. Suites now live on window._testSuites as a defensive
  fallback so two runner instances stay in sync.

* Cache invalidation: every test file's `from './runner.js'` is now
  `from './runner.js?v=2'`, and loader.js imports the runner with the
  same RUNNER_V suffix. Same URL → one module instance → suite
  registration and runAll see the same array. Bumping RUNNER_V (in
  loader.js + every test file in lock-step) is the way to force a
  re-fetch when runner.js changes.

* loader.js: ensureProgressBar() draws the strip via setProperty(...,
  'important') with z-index 2147483647 attached to documentElement so
  nothing in user CSS, scanline overlay (z 9999) or modals can occlude
  it. Auto-run path (?test=1) also pre-renders the strip.

chore: bump version to 0.9.1

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

68 lines
2.7 KiB
JavaScript

import { describe, it, afterEach, expect, $, sleep, closeAll } from './runner.js?v=2';
import { state } from '../../js/modules/state.js';
describe('Multi-Select', () => {
afterEach(() => closeAll());
it('select bar hidden by default', () => {
expect($('#select-bar').classList.contains('hidden')).toBe(true);
});
it('has all action buttons', () => {
for (const id of ['select-group', 'select-bucket', 'select-unbucket', 'select-color', 'select-tag', 'select-export', 'select-delete', 'select-clear']) {
expect($(`#${id}`)).toExist();
}
});
it('Ctrl+click selects card and shows bar', async () => {
await sleep(150);
const card = $('#board [data-id]');
if (!card) return;
card.dispatchEvent(new MouseEvent('click', { bubbles: true, ctrlKey: true }));
await sleep(150);
expect(state.selectedIds.has(card.dataset.id)).toBe(true);
expect($('#select-bar').classList.contains('hidden')).toBe(false);
});
it('Ctrl+click toggle: select then deselect', async () => {
await sleep(150);
// Ensure clean state
state.selectedIds.clear();
await sleep(50);
const card = $('#board [data-id]');
if (!card) return;
const id = card.dataset.id;
card.dispatchEvent(new MouseEvent('click', { bubbles: true, ctrlKey: true }));
await sleep(200);
expect(state.selectedIds.has(id)).toBe(true);
card.dispatchEvent(new MouseEvent('click', { bubbles: true, ctrlKey: true }));
await sleep(200);
expect(state.selectedIds.has(id)).toBe(false);
});
it('multiple cards selectable', async () => {
await sleep(150);
const cards = [...document.querySelectorAll('#board [data-id]')];
if (cards.length < 2) return;
cards[0].dispatchEvent(new MouseEvent('click', { bubbles: true, ctrlKey: true }));
await sleep(100);
cards[1].dispatchEvent(new MouseEvent('click', { bubbles: true, ctrlKey: true }));
await sleep(150);
expect(state.selectedIds.has(cards[0].dataset.id)).toBe(true);
expect(state.selectedIds.has(cards[1].dataset.id)).toBe(true);
expect(state.selectedIds.size).toBe(2);
});
it('click outside board clears selection', async () => {
await sleep(150);
const card = $('#board [data-id]');
if (!card) return;
card.dispatchEvent(new MouseEvent('click', { bubbles: true, ctrlKey: true }));
await sleep(150);
expect(state.selectedIds.size).toBeGreaterThan(0);
document.querySelector('header').dispatchEvent(new MouseEvent('click', { bubbles: true }));
await sleep(150);
expect(state.selectedIds.size).toBe(0);
});
});