[Repo Assist] test: add 10 unit tests for switch_view state reset and scrollbar_jump#175
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
- switch_view_clears_local_filter: verifies local_filter is cleared when switching views (so the new view starts unfiltered) - switch_view_clears_selected_packages: verifies multi-select indices are dropped (they are invalid after a view switch) - switch_view_clears_detail_panel: verifies stale detail from the previous view is not carried over - switch_view_increments_detail_generation: verifies the generation counter is bumped to discard in-flight detail requests from the old view - switch_view_resets_focus_to_package_list: verifies focus returns to the list (not the detail pane) after switching views - switch_view_no_op_when_already_on_target_mode: verifies that switching to the already-active mode is a no-op (local_filter and detail_generation are unchanged) - scrollbar_jump_selects_first_item_when_clicking_track_top: clicking the top pixel of the scrollbar track → item 0 - scrollbar_jump_selects_last_item_when_clicking_track_bottom: clicking the bottom pixel → last item - scrollbar_jump_no_op_on_empty_list: should not panic or mutate state - scrollbar_jump_clamps_row_below_track_top_to_first_item: a click above the track is clamped to the top → item 0 231 → 241 tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
21 tasks
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
What
Adds 10 unit tests covering two previously-untested functions in
handler.rs:switch_viewstate reset (6 tests)PR #156 tested that
Left/Rightkeys changeapp.mode, but did not verify the side-effect state resets thatswitch_viewperforms. These tests close that gap:switch_view_clears_local_filterlocal_filteris emptied so the new view starts unfilteredswitch_view_clears_selected_packagesswitch_view_clears_detail_panelswitch_view_increments_detail_generationswitch_view_resets_focus_to_package_listswitch_view_no_op_when_already_on_target_modescrollbar_jumpposition math (4 tests)scrollbar_jumpconverts a pixel row to a list index via a ratio calculation. It had no test coverage at all:scrollbar_jump_selects_first_item_when_clicking_track_topscrollbar_jump_selects_last_item_when_clicking_track_bottomscrollbar_jump_no_op_on_empty_listscrollbar_jump_clamps_row_below_track_top_to_first_itemWhy
The
switch_viewinvariants (clear local filter, clear multi-select, clear detail, bump generation) are important for correctness. A regression in any of them would cause confusing UI state when the user presses Left/Right to switch views. Thescrollbar_jumpratio calculation is non-trivial and benefits from boundary-condition tests.Test Status