diff options
Diffstat (limited to 'web/test/tasks-board.test.mjs')
| -rw-r--r-- | web/test/tasks-board.test.mjs | 19 |
1 files changed, 19 insertions, 0 deletions
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) { |
