test: lock marketplace and grievance QOL tenancy - #80
Draft
cursor[bot] wants to merge 1 commit into
Draft
Conversation
Those Hub routes only had adapter and access-helper coverage. Route tests now prove union isolation, assignment gates, and session-stamped writes so a forged tenant key or unassigned steward write cannot ship unnoticed. Co-authored-by: Ryan Morris <ryan@ryanmorris.ca>
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After #79 (tasks/snippets), Hub route tests still skipped the within-union marketplace and grievance communications, meetings, notes, and outcomes — those mutating paths only had adapter and access-helper coverage. This run locks those Officer Hub surfaces so a tenancy, assignment, or forged-author regression cannot ship unnoticed.
PRs #57 (expense/elections/documents list-create), #68 (polls/check-ins/discussions), and #79 (tasks/snippets) are still open and are not duplicated here. Today's public Guides catalog and nav IA already ship with registry and smoke coverage.
Risky behavior now covered
kindandqfilters work; create rejects missing fields and stamps session union/local/author even when the body forges tenant keys; steward can publish; local_exec and members cannot; GET 404 missing / 403 another union (includingplatform_admin) with no write; sister-local download allowed; steward can delete own template but not another officer's; president can delete another's.Test files added/updated
src/lib/marketplace/api-routes.test.tssrc/lib/grievance/api-routes.test.tssrc/lib/marketplace/memory-adapter.ts(test reset helper only)Why this reduces regression risk
Marketplace templates and grievance comms/meetings/notes/outcomes are confidential officer writes. A missed
unionIdcheck, a steward logging on someone else's case, or a POST that copiedunionId/recordedByIdfrom the body would leak or re-home records across tenants. The new tests exercise the real route handlers (not just access helpers) so session gating and session-stamped writes stay aligned.Checklist
.env, keys, or real member/PII datamessages/en.jsonandmessages/fr.json(if applicable)unionIdscoping; no cross-union access)npm run lintandnpm run test:unitpassnpm run test:smoke)Test plan
npx vitest run src/lib/marketplace/api-routes.test.ts src/lib/grievance/api-routes.test.ts src/lib/qol/adapters.test.ts src/lib/validation/validation.test.ts src/lib/hybrid/api-routes.test.ts src/lib/handoff/api-routes.test.ts(56 passed)npx eslinton the three touched files (clean)