* 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>
113 lines
5.0 KiB
JavaScript
113 lines
5.0 KiB
JavaScript
import { describe, it, afterEach, expect, $, $$, click, sleep, closeAll, csrf } from './runner.js?v=2';
|
|
|
|
describe('Bucket Context Menu', () => {
|
|
afterEach(async () => {
|
|
document.getElementById('bucket-ctx')?.classList.add('hidden');
|
|
await closeAll();
|
|
});
|
|
|
|
it('right-click bucket opens context menu', async () => {
|
|
// Create a test bucket
|
|
const b = await fetch('api/buckets', {
|
|
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() },
|
|
body: JSON.stringify({ name: '__test_bctx__' }),
|
|
}).then(r => r.json());
|
|
await window._reloadAll?.();
|
|
await sleep(200);
|
|
|
|
const tab = document.querySelector(`#bucket-bar [data-bucket="${b.id}"]`);
|
|
if (!tab) return;
|
|
tab.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, clientX: 100, clientY: 50 }));
|
|
await sleep(150);
|
|
|
|
const ctx = document.getElementById('bucket-ctx');
|
|
expect(ctx).toExist();
|
|
expect(ctx.classList.contains('hidden')).toBe(false);
|
|
});
|
|
|
|
it('bucket context menu has rename action', async () => {
|
|
const b = await fetch('api/buckets', {
|
|
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() },
|
|
body: JSON.stringify({ name: '__test_bctx_rename__' }),
|
|
}).then(r => r.json());
|
|
await window._reloadAll?.();
|
|
await sleep(200);
|
|
|
|
const tab = document.querySelector(`#bucket-bar [data-bucket="${b.id}"]`);
|
|
if (!tab) return;
|
|
tab.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, clientX: 100, clientY: 50 }));
|
|
await sleep(150);
|
|
|
|
const renameBtn = document.querySelector('[data-baction="rename"]');
|
|
expect(renameBtn).toExist();
|
|
});
|
|
|
|
it('bucket context menu has color action', async () => {
|
|
const b = await fetch('api/buckets', {
|
|
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() },
|
|
body: JSON.stringify({ name: '__test_bctx_color__' }),
|
|
}).then(r => r.json());
|
|
await window._reloadAll?.();
|
|
await sleep(200);
|
|
|
|
const tab = document.querySelector(`#bucket-bar [data-bucket="${b.id}"]`);
|
|
if (!tab) return;
|
|
tab.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, clientX: 100, clientY: 50 }));
|
|
await sleep(150);
|
|
|
|
expect(document.querySelector('[data-baction="color"]')).toExist();
|
|
});
|
|
|
|
it('empty bucket shows single delete option', async () => {
|
|
const b = await fetch('api/buckets', {
|
|
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() },
|
|
body: JSON.stringify({ name: '__test_bctx_empty__' }),
|
|
}).then(r => r.json());
|
|
await window._reloadAll?.();
|
|
await sleep(200);
|
|
|
|
const tab = document.querySelector(`#bucket-bar [data-bucket="${b.id}"]`);
|
|
if (!tab) return;
|
|
tab.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, clientX: 100, clientY: 50 }));
|
|
await sleep(150);
|
|
|
|
// Empty bucket: only delete-keep, no delete-all
|
|
expect(document.querySelector('[data-baction="delete-keep"]')).toExist();
|
|
expect(document.querySelector('[data-baction="delete-all"]')).toBe(null);
|
|
});
|
|
|
|
it('bucket with cards shows both delete options', async () => {
|
|
const b = await fetch('api/buckets', {
|
|
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() },
|
|
body: JSON.stringify({ name: '__test_bctx_full__' }),
|
|
}).then(r => r.json());
|
|
await fetch('api/cards', {
|
|
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() },
|
|
body: JSON.stringify({ title: '__test_bctx_card__', body: '', color: '#38bdf8', bucket_id: b.id }),
|
|
});
|
|
await window._reloadAll?.();
|
|
await sleep(200);
|
|
|
|
const tab = document.querySelector(`#bucket-bar [data-bucket="${b.id}"]`);
|
|
if (!tab) return;
|
|
tab.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, clientX: 100, clientY: 50 }));
|
|
await sleep(150);
|
|
|
|
expect(document.querySelector('[data-baction="delete-keep"]')).toExist();
|
|
expect(document.querySelector('[data-baction="delete-all"]')).toExist();
|
|
});
|
|
|
|
it('move-left disabled on first bucket', async () => {
|
|
await window._reloadAll?.();
|
|
await sleep(200);
|
|
const tabs = $$('#bucket-bar [data-bucket]').filter(t => !['all', 'current', 'favorites', 'journal', 'none'].includes(t.dataset.bucket));
|
|
if (!tabs.length) return;
|
|
tabs[0].dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, clientX: 100, clientY: 50 }));
|
|
await sleep(150);
|
|
const moveLeft = document.querySelector('[data-baction="move-left"]');
|
|
if (moveLeft) {
|
|
expect(moveLeft.classList.contains('opacity-30') || moveLeft.classList.contains('pointer-events-none')).toBe(true);
|
|
}
|
|
});
|
|
});
|