test: cover the constraint checks, workspace store, and webmcp tools - #1
Open
usehoplite[bot] wants to merge 2 commits into
Open
test: cover the constraint checks, workspace store, and webmcp tools#1usehoplite[bot] wants to merge 2 commits into
usehoplite[bot] wants to merge 2 commits into
Conversation
Add node:test suites for the untested src modules, run through Node's native type stripping. Cover the four constraint heuristics, source analysis and draft generation, prompt-leak guards, store state transitions including Gemini and local-fallback paths, hydrate normalization of untrusted payloads, and the WebMCP tool handlers plus registration lifecycle. Fix the instruction-leak guard to catch plural 'questions' phrasing, and point cross-module imports at explicit .ts specifiers so Node can load them. Co-authored-by: Tim Apple <richerbran@gmail.com>
The source-control publishing helper invokes 'git lfs ls-files', which fails on fresh sandboxes where git-lfs is absent. Record the install in the effective setup path so future threads can publish pull requests. Co-authored-by: Tim Apple <richerbran@gmail.com>
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.
What
Adds the project's first tests for the untested
src/production modules, focused on the riskiest behavior. Everything runs throughnpm testvia Node's native TypeScript type stripping (no new test framework or dependency), andnpm run build/npm run lintstay clean.Coverage
src/worksheet.test.ts(58 tests) — the four constraint checks that the product's "4/4 — Ready for class" contract depends on (checkTimeEstimate,checkReadingLevel,checkQuestionMix,checkStandardCoverage,evaluateConstraints), source analysis (fraction/decimals parsing, comparison detection, GCD, transcript vs topic fallback), draft generation (math generator gating, standards intersection), and the prompt/instruction-leak guards (assertQuestionContent,normalizeQuestionChanges,generateReplacementQuestion).src/workspaceStore.test.ts(38 tests) — state transitions (addSourceMaterialremote-URL/image rejection,editQuestion, reorder/delete, constraints validation), the Gemini success path and the documented local-fallback path ofgenerateDraft/swapQuestion(fetch-stubbed),runAgentInstructionrouting, andhydratehardening against malformed or stale persisted payloads.src/webmcp.test.ts(17 tests) — agent-facing tool handlers: input rejection of untrusted payloads, fallback generation through the handler, the read-onlycheck_*tools over"current"and explicit worksheets, and theregisterClassworkToolslifecycle (nine tools, ready status, abort-on-dispose, unsupported browsers).server/index.test.mjs— unchanged;npm testnow runs both suites (120 tests total).Production changes (small, deliberate)
src/worksheet.ts):\bquestion\b→\bquestions?\bso leaked phrasing like "Create 3 questions..." no longer slips past the guard that is meant to fail closed. Verified against every prompt the app itself generates.src/workspaceStore.tsandsrc/webmcp.tsnow use explicit.tsextensions (already allowed bytsconfig.app.json) so the modules load under Node's native type stripping.tsconfig.app.jsonaddsnodetotypes(tests live insrc);package.jsontest script includessrc/*.test.ts;docs/TESTING.mddocuments the Node 23.6+ requirement.Verification