Skip to content

[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
repo-assist/test-switch-view-scrollbar-2026-05-02-8f33025a3c79e5cd
Draft

[Repo Assist] test: add 10 unit tests for switch_view state reset and scrollbar_jump#175
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/test-switch-view-scrollbar-2026-05-02-8f33025a3c79e5cd

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 2, 2026

🤖 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_view state reset (6 tests)

PR #156 tested that Left/Right keys change app.mode, but did not verify the side-effect state resets that switch_view performs. These tests close that gap:

Test What it verifies
switch_view_clears_local_filter local_filter is emptied so the new view starts unfiltered
switch_view_clears_selected_packages Multi-select indices are dropped (they are invalid in the new view)
switch_view_clears_detail_panel Stale detail from the old view is not carried over
switch_view_increments_detail_generation Generation counter is bumped to discard in-flight detail requests
switch_view_resets_focus_to_package_list Focus returns to the package list after switching
switch_view_no_op_when_already_on_target_mode Switching to the already-active mode is a no-op

scrollbar_jump position math (4 tests)

scrollbar_jump converts a pixel row to a list index via a ratio calculation. It had no test coverage at all:

Test What it verifies
scrollbar_jump_selects_first_item_when_clicking_track_top Top of track → item 0
scrollbar_jump_selects_last_item_when_clicking_track_bottom Bottom of track → last item
scrollbar_jump_no_op_on_empty_list Does not panic or mutate state when list is empty
scrollbar_jump_clamps_row_below_track_top_to_first_item Row above track is clamped to item 0

Why

The switch_view invariants (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. The scrollbar_jump ratio calculation is non-trivial and benefits from boundary-condition tests.

Test Status

cargo check --all-targets  → clean
cargo fmt -- --check       → clean
cargo clippy -- -D warnings → clean
cargo test                 → 241 passed (was 231) — 10 new tests

Generated by Repo Assist · ● 4.8M ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@cbb46ab386962aa371045839fc9998ee4e97ca64

- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants