test(react-chess-puzzle): regression test for #82 (crash on puzzle prop change)#85
Merged
Conversation
…crash The crash from #82 ("Invalid move" thrown while replaying the previous puzzle's history over the new fen in getCurrentFen) was fixed by the prop-sync rework in 0c3df58 but never covered by a test. The test fails on the released 1.0.x code and passes on main. Closes #82 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
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.
Context
Issue #82 reports an
Invalid move: Rxd6+crash when thepuzzleprop ofChessPuzzle.Rootchanges after solving a puzzle (e.g.onSolveadvancing to the next puzzle).Diagnosis
The crash happened in
getCurrentFen(packages/react-chess-game/src/utils/chess.ts): during the puzzle switch a render saw the new fen but the old puzzle's history, and replaying the moves inside theuseMemothrewInvalid move.The bug is already fixed on main by the "prop sync" rework (0c3df58), which was never released: the 1.0.x versions on npm don't include it. Verified empirically: this test fails on d21ecb8 (the code published as 1.0.x) with exactly the stack trace from the issue, and passes on main.
What this PR does
Adds only the regression test, faithful to the issue's repro: two puzzles cycled via
onSolve(the first withmakeFirstMove: true), solve the first one and assert the second loads cleanly and is solvable in turn.No production code changes, so no changeset.
Closes #82
🤖 Generated with Claude Code