test: lock Officer Learning API auth and draft persistence - #26
Draft
cursor[bot] wants to merge 2 commits into
Draft
test: lock Officer Learning API auth and draft persistence#26cursor[bot] wants to merge 2 commits into
cursor[bot] wants to merge 2 commits into
Conversation
Recent quiz navigation and Hub sync QOL changed production paths with little unit coverage. Lock the device progress state machine, tenancy/sync guards, and on-device proposal draft validation so those regressions fail in CI instead of on the floor. Co-authored-by: Ryan Morris <ryan@ryanmorris.ca>
Route handlers for Hub learning sync/report had no unit coverage, so a 401/403/tenancy regression would only show up on the floor. Shared draft storage and informal-log convert/delete/view rules have the same blast radius. 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
Yesterday's coverage commit never landed on main. This run re-applies it and adds the next high-risk gaps: Officer Learning Hub API auth/tenancy, shared on-device draft storage, and informal-log permission edges.
Production behavior is unchanged. Tests only.
Risky behavior now covered
/api/officer-learning/merejects missing session / incomplete tenant identity (401), invalid JSON andshareWithLocalwithout Hub sync (400), and writes only under the sessionunionId/localId(forged body tenant keys cannot create a row in another union).localIdin another union and for another local in the same union.loadJsonDraft/saveJsonDraftreject corrupt or schema-invalid localStorage and return false on quota/private-mode throws (TOOL-001).local_execcannot convert to a grievance (including dual steward+exec roles); delete is author-or-elevated; view never crosses unions, even forplatform_admin.Test files added/updated
src/lib/officer-learning/api-routes.test.ts(new)src/lib/officer-learning/hub-store.test.tssrc/lib/officer-learning/hub-sync-client.test.ts(new)src/lib/officer-learning/modules.test.ts(new)src/lib/officer-learning/progress.test.ts(new)src/lib/officer-learning/parse-module.test.tssrc/lib/officer-learning/quiz-scroll.test.tssrc/lib/officer-learning/related-resources.test.tssrc/lib/proposal-tracker/draft.test.ts(new)src/lib/validation/officer-learning.test.ts(new)src/lib/rules-of-order/actions.test.tssrc/lib/steward-guides/storage.test.ts(new)src/lib/informal-log/access.test.ts(new)Why this reduces regression risk
These paths are permissions, tenancy, validation, and persistence — a silent 403/401 miss or a cross-union leak would not show up in smoke locators. The previous coverage PR (
cursor/missing-test-coverage-f6b4) never merged; quiz navigation / Hub sync QOL from 2026-08-28 was still untested on main.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
npm run test:unit -- src/lib/officer-learning src/lib/steward-guides/storage.test.ts src/lib/informal-log/access.test.ts src/lib/proposal-tracker src/lib/validation/officer-learning.test.ts src/lib/rules-of-order/actions.test.ts— 19 files / 91 tests passed.