From 0ca84d28c6d358591582b5d61ef66ed0e266e260 Mon Sep 17 00:00:00 2001 From: Claudomator Agent Date: Mon, 6 Jul 2026 01:38:50 +0000 Subject: fix(web): reviewer findings on Tasks board column model (task 1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Finding 1 (Important): replace inline per-column sort comparators in groupTasksByColumn with calls to the existing sortTasksByDate(tasks, descend) helper. The old inline code fell back to epoch 0 for missing created_at, sorting dateless tasks FIRST in ascending columns — diverging from the rest of the codebase's convention (sortTasksByDate puts them LAST). Add two new tests asserting that a task with no created_at sorts LAST in both an ascending column (queue) and a descending column (interrupted). Finding 2 (Important): revert web/test/tab-persistence.test.mjs — the two 'stories' assertions introduced in 54be094 were out of Task 1's scope and belong to Task 2. Restore the original 'queue' assertions so commit messages accurately reflect their contents; Task 2 will re-apply the fix intentionally. Finding 3 (Minor): add the missing state-list uniqueness assertion to the 'every column key is unique' test: assert.equal(new Set(allStates).size, allStates.length) so a state appearing in two columns is caught. Co-Authored-By: Claude Sonnet 4.6 --- web/test/tasks-board.test.mjs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'web/test/tasks-board.test.mjs') diff --git a/web/test/tasks-board.test.mjs b/web/test/tasks-board.test.mjs index 85bb04a..560e8c8 100644 --- a/web/test/tasks-board.test.mjs +++ b/web/test/tasks-board.test.mjs @@ -42,6 +42,7 @@ describe('columnForTaskState', () => { ]) { assert.ok(allStates.includes(s), `${s} missing from any column`); } + assert.equal(new Set(allStates).size, allStates.length, 'a state must map to exactly one column'); }); }); @@ -120,6 +121,24 @@ describe('groupTasksByColumn', () => { assert.deepEqual(groups.running.map(t => t.id), ['newer', 'older']); }); + it('sorts a task with no created_at LAST in an ascending column (queue)', () => { + const tasks = [ + { id: 'no-date', state: 'PENDING' }, + { id: 'has-date', state: 'QUEUED', created_at: '2024-01-01T00:00:00Z' }, + ]; + const groups = groupTasksByColumn(tasks); + assert.deepEqual(groups.queue.map(t => t.id), ['has-date', 'no-date']); + }); + + it('sorts a task with no created_at LAST in a descending column (interrupted)', () => { + const tasks = [ + { id: 'no-date', state: 'FAILED' }, + { id: 'has-date', state: 'CANCELLED', created_at: '2024-01-01T00:00:00Z' }, + ]; + const groups = groupTasksByColumn(tasks); + assert.deepEqual(groups.interrupted.map(t => t.id), ['has-date', 'no-date']); + }); + it('handles null/undefined gracefully', () => { const groups = groupTasksByColumn(null); for (const col of TASK_COLUMNS) { -- cgit v1.2.3