test(server): unit-test slash-command parser + dispatcher (#273 follow-up) #289

Merged
charles merged 1 commit from test/s11-slash-commands into main 2026-04-23 23:09:04 +00:00
Collaborator

PR #273 s11 extraction follow-up. Covers slash-commands.ts.

Coverage (16 tests)

  • parseRaiseCapCommand/raise-cap $10, /raise-cap 10, /raise-cap (no arg), invalid input, $-5 rejection (dollar-strip then ≤0 gate)
  • Command routing — recognised commands dispatch correctly, unknown command → no-op
  • applyRaiseCapCommand miss branch — no running task + ack comment .catch() swallow

What's NOT covered here (deliberate)

  • No DI seam on slash-commands.ts — the module imports ForgejoAdapter, parseRepo, listResolvedAgents, getWorker, dispatchByType, raiseTaskCostCap directly. The applyRaiseCapCommand "currentTask match" branch requires a full Worker fixture that can't be built without mock.module. Documented in the test file's top comment. Adding an impl-style seam is a future refactor.
  • dispatchBreakdown — already covered by breakdown.test.ts via mock.module("../dispatch/registry"). Not duplicated.
  • Auth/trust guards — happen one layer up in webhook-handlers.ts (webhook signature) and main.ts (/breakdown HTTP auth). Not in this module's responsibility.

Checks

  • bunx tsc --noEmit -p apps/server/tsconfig.json — EXIT=0
  • bun test apps/server/src/domain/workflow/slash-commands.test.ts — 16/16 pass
  • Full suite: +16 passes, no regressions
PR #273 s11 extraction follow-up. Covers `slash-commands.ts`. ## Coverage (16 tests) - `parseRaiseCapCommand` — `/raise-cap $10`, `/raise-cap 10`, `/raise-cap` (no arg), invalid input, `$-5` rejection (dollar-strip then ≤0 gate) - Command routing — recognised commands dispatch correctly, unknown command → no-op - `applyRaiseCapCommand` miss branch — no running task + ack comment `.catch()` swallow ## What's NOT covered here (deliberate) - **No DI seam on `slash-commands.ts`** — the module imports `ForgejoAdapter`, `parseRepo`, `listResolvedAgents`, `getWorker`, `dispatchByType`, `raiseTaskCostCap` directly. The `applyRaiseCapCommand` "currentTask match" branch requires a full Worker fixture that can't be built without `mock.module`. Documented in the test file's top comment. Adding an `impl`-style seam is a future refactor. - `dispatchBreakdown` — already covered by `breakdown.test.ts` via `mock.module("../dispatch/registry")`. Not duplicated. - Auth/trust guards — happen one layer up in `webhook-handlers.ts` (webhook signature) and `main.ts` (`/breakdown` HTTP auth). Not in this module's responsibility. ## Checks - `bunx tsc --noEmit -p apps/server/tsconfig.json` — EXIT=0 - `bun test apps/server/src/domain/workflow/slash-commands.test.ts` — 16/16 pass - Full suite: +16 passes, no regressions
test(server): unit-test slash-command parser + dispatcher (#273 follow-up)
All checks were successful
qa / qa (pull_request) Successful in 4m11s
qa / dockerfile (pull_request) Successful in 8s
16ab3a8bf3
Covers `parseRaiseCapCommand` (dollar signs, decimals, zero/negative/NaN
rejection, disabling aliases, case-insensitivity, unrelated bodies),
`parseBreakdownComment` (positional + key=value tokens, quoted milestone,
unknown-key tolerance, `max_issues=banana` drop), the
`BREAKDOWN_DEFAULT_MAX_ISSUES = 15` contract constant, and
`applyRaiseCapCommand`'s miss-branch (no running task) with `spyOn`-stubbed
`fetch` so no HTTP leaves the process — no `mock.module`, since the module
has no DI seam and Bun's `mock.module` is process-global.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
charles deleted branch test/s11-slash-commands 2026-04-23 23:09:05 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks!289
No description provided.