diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-05 18:51:50 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-05 18:51:50 +0000 |
| commit | cf83444a9d341ae362e65a9f995100c69176887c (patch) | |
| tree | 0dc12aea9510d10d9e60e9c58473cbdb9db5db47 /web/test/task-actions.test.mjs | |
| parent | 680e5f668637248073c1f8f7e3547810ab1ada36 (diff) | |
Rescue work from claudomator-work: question/answer, ratelimit, start-next-task
Merges features developed in /site/doot.terst.org/claudomator-work (a
stale clone) into the canonical repo:
- executor: QuestionRegistry for human-in-the-loop answers, rate limit
detection and exponential backoff retry (ratelimit.go, question.go)
- executor/claude.go: process group isolation (SIGKILL orphans on cancel),
os.Pipe for reliable stdout drain, backoff retry on rate limits
- api/scripts.go: POST /api/scripts/start-next-task handler
- api/server.go: startNextTaskScript field, answer-question route,
BroadcastQuestion for WebSocket question events
- web: Cancel/Restart buttons, question banner UI, log viewer, validate
section, WebSocket auto-connect
All tests pass.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'web/test/task-actions.test.mjs')
| -rw-r--r-- | web/test/task-actions.test.mjs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/web/test/task-actions.test.mjs b/web/test/task-actions.test.mjs new file mode 100644 index 0000000..f2c21c4 --- /dev/null +++ b/web/test/task-actions.test.mjs @@ -0,0 +1,53 @@ +// task-actions.test.mjs — button visibility logic for Cancel/Restart actions +// +// Run with: node --test web/test/task-actions.test.mjs + +import { describe, it } from 'node:test'; +import assert from 'node:assert/strict'; + +// ── Logic under test ────────────────────────────────────────────────────────── + +const RESTART_STATES = new Set(['FAILED', 'TIMED_OUT', 'CANCELLED']); + +function getCardAction(state) { + if (state === 'PENDING') return 'run'; + if (state === 'RUNNING') return 'cancel'; + if (RESTART_STATES.has(state)) return 'restart'; + return null; +} + +// ── Tests ───────────────────────────────────────────────────────────────────── + +describe('task card action buttons', () => { + it('shows Run button for PENDING', () => { + assert.equal(getCardAction('PENDING'), 'run'); + }); + + it('shows Cancel button for RUNNING', () => { + assert.equal(getCardAction('RUNNING'), 'cancel'); + }); + + it('shows Restart button for FAILED', () => { + assert.equal(getCardAction('FAILED'), 'restart'); + }); + + it('shows Restart button for TIMED_OUT', () => { + assert.equal(getCardAction('TIMED_OUT'), 'restart'); + }); + + it('shows Restart button for CANCELLED', () => { + assert.equal(getCardAction('CANCELLED'), 'restart'); + }); + + it('shows no button for COMPLETED', () => { + assert.equal(getCardAction('COMPLETED'), null); + }); + + it('shows no button for QUEUED', () => { + assert.equal(getCardAction('QUEUED'), null); + }); + + it('shows no button for BUDGET_EXCEEDED', () => { + assert.equal(getCardAction('BUDGET_EXCEEDED'), null); + }); +}); |
