* card-interactions.test.js: group delete tests used `.dialog-ok` (class selector) but the button has `id="dialog-ok"`. querySelector returned null, the click was skipped, the dialog stayed open and blocked every downstream test. Fixed to getElementById. * runner.js closeAll(): added #dialog, #bucket-super-popover (remove), and #gitea-overlay to the cleanup list. A failed test that leaves any of these open no longer poisons the rest of the suite. * runner.js copy handler: when there are failures or flaky tests, the "copy" button now builds the clipboard text from lastResults — only failed + flaky lines (suite name, test name, timing, error, original error for retried). When everything passed, copies the full output as before. lastResults is set in renderResults(). * bucket-context.test.js: move-left test used `[data-bucket]` to find user bucket tabs, which misses super-bucket tiles (they carry `data-bucket-super`). Changed to `[data-bucket-drag]` which is on both regular and super-bucket tiles but not on fixed filters. * context-menu.test.js: make-ticket pre-fill assertion now polls up to 2s for the title input to be populated (async openCreateForm repo-fetch was racing against the immediate assertion). * card-join.test.js: clickJoin sleep bumped from 400ms → 800ms. joinSelectedCards does 3+ serial API calls (fetch bodies, PATCH winner, N×DELETE losers, _reloadAll) which sometimes exceeded the old 400ms window on slow runs. * Runner cache: RUNNER_V bumped from ?v=2 → ?v=3 in loader.js + all 42 test files so the browser picks up the new runner.js content (copy handler, closeAll, retry progress bar) without a hard reload. super-buckets: remember last selection per group * buckets.js: module-scope lastSuperSelection Map tracks the last active member per super-bucket parent. Updated in renderBar() whenever activeBucket matches a group member. tileFor() uses it as a fallback when the user is on a different bucket — the tile shows the last-picked child's name and color instead of reverting to the parent. The dropdown popover also highlights the last selection when no member is currently active. chore: bump version to 0.9.11 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
117 lines
5.2 KiB
JavaScript
117 lines
5.2 KiB
JavaScript
import { describe, it, afterEach, expect, $, $$, click, sleep, closeAll, csrf } from './runner.js?v=3';
|
|
|
|
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);
|
|
// data-bucket-drag is present on BOTH regular and super-bucket
|
|
// tiles but not on the fixed filters (all/current/favorites/…).
|
|
// Using it instead of [data-bucket] avoids missing super-bucket
|
|
// tiles which carry data-bucket-super instead.
|
|
const tabs = $$('#bucket-bar [data-bucket-drag]');
|
|
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);
|
|
}
|
|
});
|
|
});
|