test(coverage): #60, #58, #57, #20, #17 - #229
Open
nastaso wants to merge 1 commit into
Open
Conversation
#20 shuffleAndMapQuestions, #17 selectExamQuestions Five independent test-only additions, no production code changed: - #60 maybeNotifyGoogleLink: dispatch-once, silent-repeat, silent-when-unlinked - #58 levelAccent.test.ts (new): cross-file drift guard against scripts/generate-og-images.mjs's LEVEL_ACCENT, key coverage, hex/RGB parity - #57 goToLogin: from-state composition, empty search/hash, call count/shape - #20 shuffleAndMapQuestions: keymap-per-question, content preservation, single- and multi-answer round trips via toOriginalAnswer - #17 selectExamQuestions: exact-quota, small-pool shortfall, no duplicates, domain isolation Mutation-tested by hand against all five (break the real behavior, confirm red, restore, confirm green). One real gap found and fixed in the process: the #20 single-answer round-trip test only caught a broken toOriginalAnswer ~40% of the time, because the random shuffle can leave the answer key at a fixed point by chance, silently missing the mutation the rest of the time. Rewrote it to loop 30 shuffle attempts per assertion instead of one, which drove the false-negative rate to negligible (5/5 mutation runs now catch it).
Deploying cloudcertprep with
|
| Latest commit: |
afd11ca
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c3f07376.cloudcertprep.pages.dev |
| Branch Preview URL: | https://test-coverage-batch.cloudcertprep.pages.dev |
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 does this PR do?
Closes #60, closes #58, closes #57, closes #20, closes #17.
Five test-only additions (one new file, four extended), no production code changed. Checked
gh pr listfor all five before starting - none had an existing open or merged PR (unlike #194/#111/#72/#51, already covered by contributor PRs #199/#200/#211/#201 and correctly excluded from this batch).account-link.test.ts:maybeNotifyGoogleLink- dispatches once on first merged-Google user, stays silent on repeat (ack flag set), stays silent for a non-linked user. Stubswindow/localStoragewithvi.stubGlobal(this repo's vitest environment isnode, no jsdom - per the issue's own instructions, no new dependency).levelAccent.test.ts(new): the load-bearing one readsscripts/generate-og-images.mjsas a string and asserts itsLEVEL_ACCENThex values equalLEVEL_ACCENT_HEX- an actual drift guard, not just a snapshot of today's values. Plus key-coverage and hex→RGB parity checks.navigation.test.ts:goToLogin- composespathname+search+hashintofrom, works when search/hash are empty, callsnavigateexactly once with the right shape.utils.test.ts:shuffleAndMapQuestions- one keyMap per question, option-value set preserved after shuffle, single- and multi-answer round trips throughtoOriginalAnswer.scoring.test.ts:selectExamQuestions- exact-quota pools hit the exact target counts, a below-quota domain returns everything it has (documents the existing.sliceshortfall behavior, doesn't change it), no duplicate ids across a full run, and each domain's selections never exceed its own quota / never pull from another domain.Testing
Implemented by codex
gpt-5.6-sol, audited by me (Claude sonnet) per this session's routing. Audit lens: "does each test fail if the behaviour is broken? A test that passes against a mutant is not a test."I hand-mutation-tested a sample covering the trickiest logic in three of the five: broke
generate-og-images.mjs's hex value (drift guard went red, restored, confirmed green), removed the domain filter inselectExamQuestions(3 of 4 new tests went red, restored, confirmed green), and madetoOriginalAnsweran identity no-op (multi-answer round trip caught it 8/8 runs; the single-answer round trip only caught it ~40% of runs because a random shuffle can coincidentally leave the answer key at a fixed point). Found and fixed one real gap in the process: rewrote the single-answer round-trip test to loop 30 shuffle attempts instead of relying on one, which took the false-negative rate to negligible (5/5 catches after the fix, re-verified against the same mutation).npm run check(typecheck + lint + unit tests): 0 errors, 0 warnings, 317/317 tests pass (27 new).git diff --name-onlyagainst the base.Checklist
npm run test/npm run checkpasses locallynpm run lintcleansrc/lib/levelAccent.test.ts)