diff options
Diffstat (limited to 'web/test/task-actions.test.mjs')
| -rw-r--r-- | web/test/task-actions.test.mjs | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/web/test/task-actions.test.mjs b/web/test/task-actions.test.mjs index 2df6523..36c0e8b 100644 --- a/web/test/task-actions.test.mjs +++ b/web/test/task-actions.test.mjs @@ -1,4 +1,4 @@ -// task-actions.test.mjs — button visibility logic for Cancel/Restart actions +// task-actions.test.mjs — button visibility logic for Cancel/Restart/Resume actions // // Run with: node --test web/test/task-actions.test.mjs @@ -7,16 +7,23 @@ import assert from 'node:assert/strict'; // ── Logic under test ────────────────────────────────────────────────────────── -const RESTART_STATES = new Set(['FAILED', 'TIMED_OUT', 'CANCELLED']); +const RESTART_STATES = new Set(['FAILED', 'CANCELLED']); function getCardAction(state) { if (state === 'PENDING') return 'run'; if (state === 'RUNNING') return 'cancel'; if (state === 'READY') return 'approve'; + if (state === 'TIMED_OUT') return 'resume'; if (RESTART_STATES.has(state)) return 'restart'; return null; } +function getApiEndpoint(state) { + if (state === 'TIMED_OUT') return '/resume'; + if (RESTART_STATES.has(state)) return '/run'; + return null; +} + // ── Tests ───────────────────────────────────────────────────────────────────── describe('task card action buttons', () => { @@ -32,8 +39,8 @@ describe('task card action buttons', () => { assert.equal(getCardAction('FAILED'), 'restart'); }); - it('shows Restart button for TIMED_OUT', () => { - assert.equal(getCardAction('TIMED_OUT'), 'restart'); + it('shows Resume button for TIMED_OUT', () => { + assert.equal(getCardAction('TIMED_OUT'), 'resume'); }); it('shows Restart button for CANCELLED', () => { @@ -56,3 +63,17 @@ describe('task card action buttons', () => { assert.equal(getCardAction('BUDGET_EXCEEDED'), null); }); }); + +describe('task action API endpoints', () => { + it('TIMED_OUT uses /resume endpoint', () => { + assert.equal(getApiEndpoint('TIMED_OUT'), '/resume'); + }); + + it('FAILED uses /run endpoint', () => { + assert.equal(getApiEndpoint('FAILED'), '/run'); + }); + + it('CANCELLED uses /run endpoint', () => { + assert.equal(getApiEndpoint('CANCELLED'), '/run'); + }); +}); |
