test(web): cover workspace role permission helpers - #149
Conversation
Add node:test coverage for apps/web/src/lib/permissions.ts (isWorkspaceManager, currentRole), which had no colocated test. Covers manager/non-manager/missing roles and id/route_id/blank/unmatched workspace lookups.
|
Codex review: needs maintainer review before merge. Reviewed August 4, 2026, 9:22 AM ET / 13:22 UTC. ClawSweeper reviewWhat this changesAdds five node:test cases for workspace-role lookup and manager-only UI gating in the web client. Merge readiness✅ Ready for maintainer review This is a correct, focused test-only PR with sufficient terminal proof and no actionable review findings; it is still needed as regression coverage and awaits ordinary maintainer review. Likely related people: Shakker, high confidence. Priority: P3 Review scores
Verification
How this fits togetherThe web client receives workspace records and uses role helpers to resolve the active workspace’s role and hide manager-only controls. These UI gates are advisory; the backend remains responsible for authorization. flowchart LR
A[Workspace API records] --> B[Active workspace identifier]
B --> C[Role lookup]
A --> C
C --> D[Manager role check]
D --> E[Web settings controls]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep the helper contract unchanged and land this colocated suite to preserve its role and route-identifier behavior against future regressions. Do we have a high-confidence way to reproduce the issue? Not applicable: this is proactive coverage for existing behavior, not a report of a current failure. Is this the best way to solve the issue? Yes. A colocated node:test suite follows the existing web-library test runner and exercises the real helpers without adding a competing implementation. AGENTS.md: found, but no applicable review policy affected this item. Codex review notes: model internal, reasoning high; reviewed against 601224ddee75. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Related: N/A (proactive test coverage; no linked issue)
What Problem This Solves
apps/web/src/lib/permissions.ts— the workspace-role UI gating helpersisWorkspaceManagerandcurrentRole— had no colocated test. These helpers decide whether the web client shows manager-only UI and which role applies for the active workspace. A silent regression in them (a role dropped from the manager set, the missing-role fallthrough flipping, or theid/route_idworkspace lookup breaking) would mis-gate the client UI with nothing to catch it.Why This Change Was Made
Adds a
node:testsuite (permissions.test.ts) alongside the module, matching the existingapps/web/src/lib/*.test.tsconvention (node --test,node:assert/strict, type-only imports). It pins the current shipped behavior of both exported helpers across their branches. Non-goal: this is coverage only.What did NOT change (scope boundary): no change to
permissions.tsor any runtime module — the only file added is the test. The tests import the real helpers and assert existing behavior, so they lock it in without altering it.User Impact
No user-visible change. Developers gain regression protection on the role-gating helpers: the suite fails if the manager role set, the missing-role handling, or the workspace
id/route_idlookup regress.Evidence
Ran the web lib test runner against the new file, then the whole
src/libsuite, on freshmain(601224d):Non-vacuous — each assertion pins a real branch. Verified by temporarily mutating
permissions.tsone edit at a time (dropmoderatorfrom the manager set; invert the!roleguard; forceMANAGER_ROLES.has()→true; drop theroute_idarm of the workspace lookup; return a fixed role fromcurrentRole) — every mutation turned at least one test red; source restored byte-identical, suite back to 5/5.oxfmt --checkandoxlintboth clean on the new file (+51/−0, test-only).Opened from an org-owned fork via the API; if GitHub's Allow edits from maintainers toggle isn't set on this PR, a maintainer can still push to the branch or supersede-and-land.
Generated by Claude Code