[Slider] Refactor test "Value indicator appears when it should"#183143
[Slider] Refactor test "Value indicator appears when it should"#183143dkwingsmt wants to merge 2 commits intoflutter:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors a large test for slider value indicators into smaller, more readable tests grouped by behavior. It introduces a new test helper that checks both dragged and released states and resets the widget state to prevent leaks between test runs. This refactoring also led to the correction of a test case and related documentation for ShowValueIndicator.alwaysVisible. The changes significantly improve the test suite's readability and reliability. I have one minor suggestion to further improve code clarity in one of the new tests.
Note: Security Review is unavailable for this PR.
| await expectValueIndicator(isVisible: true, theme: theme, dragged: false); | ||
| await expectValueIndicator(isVisible: true, theme: theme, enabled: false, dragged: false); | ||
| testWidgets('showValueIndicator set to onlyForDiscrete', (WidgetTester tester) async { | ||
| final sliderTheme = baseSliderTheme; |
There was a problem hiding this comment.
The sliderTheme local variable is redundant here as it's just an alias for baseSliderTheme. For improved readability and consistency with the other tests in this group that create modified themes, consider removing this variable and using baseSliderTheme directly in the expectValueIndicator calls.
References
- Code should be optimized for readability, as it is read more often than it is written. Removing this redundant variable makes the code slightly clearer. (link)
This PR refactors this slider test so that
expectValueIndicatortests both the dragged state and the released state, for better readability.expectValueIndicatorto avoid state leak...ShowValueIndicator.alwaysVisible's doc is corrected to reflect its actual behavior.This PR is split from, and is a prerequisite of, #182991.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.