test: lock polls, check-ins, and discussions tenancy - #68
Draft
cursor[bot] wants to merge 1 commit into
Draft
Conversation
Pulse polls, check-in answers, and discussion posts were only covered by the static require*Session scan. Route tests now pin cross-union 404/403, session-stamped creates, public poll consent/rate-limit, and reaction writes so a tenancy or Zod regression cannot ship unnoticed. Co-authored-by: Ryan Morris <ryan@ryanmorris.ca>
This was referenced Sep 5, 2026
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 #44/#45, Hub route tests still skipped pulse polls, check-in answers, and discussion posts — those mutating paths only had the static
require*Sessionmarker scan. This run locks those Officer Hub surfaces so a tenancy, Zod, or anonymous-submit regression cannot ship unnoticed.PR #57 (expense/elections/documents list-create) is still open and is not duplicated here. Recent land-acknowledgement PDF and
/build/reviewchanges already ship with tests.Risky behavior now covered
platform_admin) with no write; public submit treats missing and closed polls as 404; consent and invalid options 400; success returnsresponseIdonly (no IP); hashed IP is stored, not the raw address; 429 after eight submits from the same forwarded IP.Test files added/updated
src/lib/polls/api-routes.test.tssrc/lib/polls/rate-limit.test.tssrc/lib/validation/polls.test.tssrc/lib/checkins/api-routes.test.tssrc/lib/checkins/memory-adapter.ts(test reset helper only)src/lib/discussions/api-routes.test.tssrc/lib/discussions/memory-adapter.ts(seed restore on reset)Why this reduces regression risk
These are anonymous member-facing poll submits plus confidential officer check-in and discussion writes. A missed
unionIdfilter, a spread of tenant keys onto create, or a public submit that skipped consent/rate-limit would leak or write across tenants. The new tests exercise the real route handlers (not just access helpers) so session gating, Zod.strict(), and adapter writes stay aligned.No production behavior changed.
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/polls/api-routes.test.ts src/lib/polls/rate-limit.test.ts src/lib/validation/polls.test.ts src/lib/checkins/api-routes.test.ts src/lib/discussions/api-routes.test.ts(31 passed)src/lib/checkins src/lib/discussions src/lib/polls(50 passed)npx eslinton the seven touched files (clean)