test: lock informal-log tenancy, convert, and request validation - #27
Draft
cursor[bot] wants to merge 1 commit into
Draft
test: lock informal-log tenancy, convert, and request validation#27cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Route handlers for the steward quick-log were only covered by the static auth-marker scan. A missed 403/404 or a convert that stamps the wrong union would not show up in smoke locators. Co-authored-by: Ryan Morris <ryan@ryanmorris.ca>
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
Adds unit coverage for Informal Log Hub routes, session filters, and Zod request guards. Prior coverage PRs (#25/#26) are still draft and focused on Officer Learning; this run covers the next high-risk gap — convert-to-grievance and cross-union isolation on
/api/informal-log.Production behavior is unchanged aside from a test-only memory-store reset helper.
Risky behavior now covered
local_exec(including dual steward+exec) cannot convert a log into a grievance.platform_admin.unionId/localIdin the body and stamps the session tenant.convertedToGrievanceId).unionIdlists__none__; stewards stay pinned to local/collection; cross-local admins drop those filters only whenlocalIdis empty.Test files added/updated
src/lib/informal-log/api-routes.test.ts(new)src/lib/informal-log/session.test.ts(new)src/lib/informal-log/access.test.ts(new)src/lib/validation/informal-log.test.ts(new)src/lib/informal-log/memory-adapter.ts—resetInformalLogMemoryForTests()onlyWhy this reduces regression risk
These paths are permissions, tenancy, and validation. A silent 403 miss, a convert that files into the wrong union, or a list that leaks another local would not show up in smoke locators. The previous coverage PRs never merged Informal Log route tests.
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/informal-log src/lib/validation/informal-log.test.ts src/lib/hub/demo-collection-seed.test.ts src/lib/grievance src/lib/validation— 7 files / 53 tests passed.