[WIP] Seed result is NaN #47
Draft
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.
Fix for NaN seed results in competition groups
renderResultByEventIdreceives undefined/null valuesseedResultfunction before callingrenderResultByEventIdseedResultfunction for previous round resultsseedResultfunction for personal best resultsrenderResultByEventIdfunction to handle null/undefined/NaN valuesChanges Made
1. EventActivity.tsx: Added explicit null checks in
seedResultfunction before passing values torenderResultByEventIdprevRoundResults.averageis null before rendering average resultsprevRoundResults.bestis null before rendering single results2. results.ts: Added defensive validation in
renderResultByEventIdfunction3. Added comprehensive tests: Created test suites to validate null/undefined handling
results.test.ts: Tests for the core rendering function (6 tests)seedResult.test.ts: Tests for edge cases with mocked dependencies (8 tests)Solution Summary
This fix ensures that instead of displaying "NaN" when result data is missing or invalid, the application will display an empty string, providing a cleaner user experience. The fix implements a two-layer defense:
renderResultByEventIdrenderResultByEventIdif invalid values are receivedThe fix has been thoroughly tested with 14 new test cases covering all edge cases.
Fixes #17.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.