* 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>
89 lines
3.3 KiB
JavaScript
89 lines
3.3 KiB
JavaScript
import { describe, it, afterEach, expect, $, $$, click, sleep, closeAll, csrf } from './runner.js?v=2';
|
|
import { state } from '../../js/modules/state.js';
|
|
|
|
describe('Bucket Bar', () => {
|
|
afterEach(() => closeAll());
|
|
|
|
it('renders bucket tabs', () => {
|
|
const tabs = $$('#bucket-bar [data-bucket]');
|
|
expect(tabs.length).toBeGreaterThan(0); // at least "all"
|
|
});
|
|
|
|
it('has "all" bucket', () => {
|
|
const all = document.querySelector('#bucket-bar [data-bucket="all"]');
|
|
expect(all).toExist();
|
|
});
|
|
|
|
it('clicking bucket filters cards', async () => {
|
|
const tabs = $$('#bucket-bar [data-bucket]');
|
|
const bucketTab = tabs.find(t => t.dataset.bucket !== 'all' && t.dataset.bucket !== 'current' && t.dataset.bucket !== 'favorites' && t.dataset.bucket !== 'journal' && t.dataset.bucket !== 'none');
|
|
if (!bucketTab) return;
|
|
click(bucketTab);
|
|
await sleep(200);
|
|
expect(state.activeBucket).toBe(bucketTab.dataset.bucket);
|
|
// Reset
|
|
click(document.querySelector('#bucket-bar [data-bucket="all"]'));
|
|
await sleep(100);
|
|
});
|
|
|
|
it('"current" bucket works', async () => {
|
|
const cur = document.querySelector('#bucket-bar [data-bucket="current"]');
|
|
if (!cur) return;
|
|
click(cur);
|
|
await sleep(200);
|
|
expect(state.activeBucket).toBe('current');
|
|
click(document.querySelector('#bucket-bar [data-bucket="all"]'));
|
|
await sleep(100);
|
|
});
|
|
|
|
it('"journal" bucket works', async () => {
|
|
const jour = document.querySelector('#bucket-bar [data-bucket="journal"]');
|
|
if (!jour) return;
|
|
click(jour);
|
|
await sleep(200);
|
|
expect(state.activeBucket).toBe('journal');
|
|
click(document.querySelector('#bucket-bar [data-bucket="all"]'));
|
|
await sleep(100);
|
|
});
|
|
|
|
it('"unsorted" bucket works', async () => {
|
|
const none = document.querySelector('#bucket-bar [data-bucket="none"]');
|
|
if (!none) return;
|
|
click(none);
|
|
await sleep(200);
|
|
expect(state.activeBucket).toBe('none');
|
|
click(document.querySelector('#bucket-bar [data-bucket="all"]'));
|
|
await sleep(100);
|
|
});
|
|
});
|
|
|
|
describe('Bucket: Create & Delete via API', () => {
|
|
it('new bucket appears in bucket bar', async () => {
|
|
const b = await fetch('api/buckets', {
|
|
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() },
|
|
body: JSON.stringify({ name: '__test_bkt_bar__' }),
|
|
}).then(r => r.json());
|
|
|
|
await window._reloadAll?.();
|
|
await sleep(200);
|
|
|
|
const tab = document.querySelector(`#bucket-bar [data-bucket="${b.id}"]`);
|
|
expect(tab).toExist();
|
|
});
|
|
|
|
it('deleted bucket disappears from bar', async () => {
|
|
const b = await fetch('api/buckets', {
|
|
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() },
|
|
body: JSON.stringify({ name: '__test_bkt_del__' }),
|
|
}).then(r => r.json());
|
|
await window._reloadAll?.();
|
|
await sleep(100);
|
|
|
|
await fetch(`api/buckets/${b.id}`, { method: 'DELETE', headers: { 'X-CSRF-Token': csrf() } });
|
|
await window._reloadAll?.();
|
|
await sleep(200);
|
|
|
|
expect(document.querySelector(`#bucket-bar [data-bucket="${b.id}"]`)).toBe(null);
|
|
});
|
|
});
|