Compute Failure Summary new-failure flags in render without mutating props#9668
Draft
camd wants to merge 1 commit into
Draft
Compute Failure Summary new-failure flags in render without mutating props#9668camd wants to merge 1 commit into
camd wants to merge 1 commit into
Conversation
…props FailureSummaryTab.render() mutated its own props on every render: it set selectedJob.newFailure and toggled suggestion.showNewButton on the suggestion objects while building the output. Deriving these during render makes the output a pure function of props/state. - Replace the mutation loop with an isNewFailureLine() predicate plus local newFailureCount and firstNewFailureIndex derivations. - Pass showNewButton to SuggestionsListItem as an explicit prop instead of mutating suggestion.showNewButton; the item reads it from props. - Add tests covering the new-failure banner count and single NEW flag.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9668 +/- ##
=======================================
Coverage 82.59% 82.59%
=======================================
Files 622 622
Lines 36580 36577 -3
Branches 3279 3276 -3
=======================================
- Hits 30213 30212 -1
+ Misses 6217 6215 -2
Partials 150 150 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
FailureSummaryTab.render()mutated its own props on every render — it setselectedJob.newFailureand toggledsuggestion.showNewButtonon the suggestion objects while building the output. This makes render impure and can produce subtle bugs when React reuses those objects across renders.This change derives those values during render instead:
isNewFailureLine()predicate plus localnewFailureCountandfirstNewFailureIndex.showNewButtontoSuggestionsListItemas an explicit prop instead of mutatingsuggestion.showNewButton; the item now reads it from props.Behavior is preserved: the banner still counts every qualifying "new failure" line, and only the first qualifying line is flagged with the NEW button.
Testing
FailureSummaryTabsuite passes (8 tests).