Fix crash on advancing to lower-option question in quiz - #173
Merged
Conversation
…uestion Advancing from a higher-option question to a lower-option one threw "undefined is not an object (question.answers[i].correct)" during render (react-router's error screen since the RR7 upgrade). The `answers` reset moved from the synchronous submit handler into useEffect([run.counter]) (47bef5d/2f38b35, quiz-counter family), so stale `answers` — sized to the previous, larger question — survived one render past the counter change and isMultiChoiceAnsweredCorrectly indexed question.answers out of bounds. Two layers, neither reintroducing the synchronous reset removed in 47bef5d (which reopens the repetition-glitch double submission): - Guard isMultiChoiceAnsweredCorrectly: return false when the selection is longer than the current question's options instead of indexing OOB. - Reset per-question local state during render on questionId change, so it fires in step with currentQuestion (only after the counter round-trip). Add src/utils.test.ts covering the regression. Bump frontend 1.7.1 -> 1.7.2, add NEWS.md v1.7.2 entry.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
… upload Add a RunningQuizTab render test that selects an option on a 4-option question then advances to a 2-option one, reproducing the answers-length render crash and covering both the in-render questionId reset and the utils guard. Make codecov-action upload the per-package lcov reports explicitly with fail_ci_if_error, so a missing frontend report surfaces instead of showing up as 0% patch coverage. Two notes: - fail_ci_if_error: true means a genuine Codecov outage will now fail CI — the right trade for reliable coverage gating, but worth knowing. - After you push, check the Codecov comment: if it's still 0%, the report genuinely isn't being ingested and we'd dig into the upload step (flags/token); if it jumps to ~100%, both issues are resolved. My money's on resolved.
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.
Advancing from a higher-option question to a lower-option one threw "undefined is not an object (question.answers[i].correct)" during render (react-router's error screen since the RR7 upgrade). The
answersreset moved from the synchronous submit handler into useEffect([run.counter]) (47bef5d/2f38b35, quiz-counter family), so staleanswers— sized to the previous, larger question — survived one render past the counter change and isMultiChoiceAnsweredCorrectly indexed question.answers out of bounds.Two layers, neither reintroducing the synchronous reset removed in 47bef5d (which reopens the repetition-glitch double submission):
Add src/utils.test.ts covering the regression. Bump frontend 1.7.1 -> 1.7.2, add NEWS.md v1.7.2 entry.