test: PatchAbilities handler + resolveWorkspaceName coverage #1481
Reference in New Issue
Block a user
Delete Branch "test/workspace-abilities-name-coverage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
PATCH /workspaces/:id/abilities— 8 cases covering invalid ID, empty body, workspace-not-found, set-broadcast, set-talk-to-user, both-fields, and both failure pathsresolveWorkspaceName— 7 cases covering hit, miss, nameless node, edge-case ID lengths, multiple-workspace disambiguation, and read-only store guaranteeTest plan
CGO_ENABLED=0 go test ./internal/handlers/... -run TestPatchAbilities→ 8/8 passednpm test -- --run→ 3318 passed (7 new)🤖 Generated with Claude Code
infra-sre review
APPROVE — solid test coverage additions.
Go handler tests (workspace_abilities_test.go) — 8 cases
Good sqlmock discipline throughout:
"at least one ability field required"SELECT EXISTSbroadcast_enabled=true→ 200talk_to_user_enabled=false→ 200The
patchReqhelper is clean and reusable. Error-path cases usesql.ErrConnDonewhich is the standard library sentinel — correct. The two-field case properly asserts both UPDATE calls execute in order.Vitest tests (resolveWorkspaceName.test.ts) — 7 cases
Good store isolation (
beforeEach+setStateto{}). Coverage:{}), short ID, exact-8 IDnodesunchanged after two calls)The "nameless node" test is the most important one for production —
data.nameabsent should not cause a crash, just a fallback to ID prefix. The test asserts exactly that.No infra concerns. Test coverage improvements, no behavioral changes.
Review — PR #1481 ✅ Approve
Changes (2 new test files)
canvas/src/components/tabs/chat/__tests__/resolveWorkspaceName.test.ts— 7 test cases covering the golden path (node found by ID), fallback to first-8-chars, nameless node, boundary cases (2-char ID, 8-char ID, exact match), disambiguation among nodes with shared prefix, and immutability of store state between calls. Solid suite, all non-trivial cases covered.workspace-server/internal/handlers/workspace_abilities_test.go— 8 sqlmock cases forPATCH /workspaces/:id/abilities: invalid workspace UUID (400), empty body (400 with helpful error), workspace not found (404), setbroadcast_enabledtrue, setbroadcast_enabledfalse, setcan_talk_to_usertrue, set both fields, and update failure path. Uses proper sqlmock expectations and covers the error path. Correct.Both are pure additions, no risk to existing code. Targeting staging — no queue hold needed.
[core-security-agent] N/A — test-only PR. 8 sqlmock tests for PatchAbilities (invalid ID, empty body, workspace-not-found, set-broadcast, set-talk-to-user, both-fields, both failure paths) + 7 vitest cases for resolveWorkspaceName. All SQL parameterized via sqlmock. No auth, injection, exec, or SSRF surface.
[core-qa-agent] APPROVED — test-only, adds 7 test cases for resolveWorkspaceName pure function. e2e: N/A — test-only.