refactor(kebab-tui): p9-fb-24 task 2 — Inspect PgUp/PgDn via pager::PAGE_STEP

Refactor the Inspect pane's PageDown/PageUp handlers to consume the
PAGE_STEP constant from pager.rs instead of hard-coding 10. Adds
regression tests to pin the scroll delta (=10), ensuring future
viewport-aware refactors surface here rather than silently in
user-visible behaviour.

Test coverage: added page_down_scrolls_by_ten_in_inspect and
page_up_rewinds_by_ten_saturating_in_inspect (+ existing
page_keys_scroll_by_ten still passes).

Remove #[allow(dead_code)] from pager.rs now that PAGE_STEP is
consumed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-04 16:41:24 +00:00
parent 8039a8b4fb
commit 94541523e7
3 changed files with 35 additions and 8 deletions

View File

@@ -188,6 +188,39 @@ fn page_keys_scroll_by_ten() {
assert_eq!(app.inspect.as_ref().unwrap().scroll, 0);
}
/// p9-fb-24 task 2: PageDown advances scroll by `PAGE_STEP` (= 10).
/// Pins the constant so a future viewport-aware refactor surfaces
/// here, not silently in user-visible behaviour.
#[test]
fn page_down_scrolls_by_ten_in_inspect() {
let mut app = fresh_app();
let outcome = handle_key_inspect(
&mut app,
KeyEvent::new(KeyCode::PageDown, KeyModifiers::NONE),
);
assert_eq!(outcome, KeyOutcome::Continue);
assert_eq!(app.inspect.as_ref().unwrap().scroll, 10);
}
/// p9-fb-24 task 2: PageUp rewinds scroll by `PAGE_STEP`, saturating
/// at 0 (no underflow).
#[test]
fn page_up_rewinds_by_ten_saturating_in_inspect() {
let mut app = fresh_app();
app.inspect.as_mut().unwrap().scroll = 25;
handle_key_inspect(
&mut app,
KeyEvent::new(KeyCode::PageUp, KeyModifiers::NONE),
);
assert_eq!(app.inspect.as_ref().unwrap().scroll, 15);
app.inspect.as_mut().unwrap().scroll = 3;
handle_key_inspect(
&mut app,
KeyEvent::new(KeyCode::PageUp, KeyModifiers::NONE),
);
assert_eq!(app.inspect.as_ref().unwrap().scroll, 0);
}
#[test]
fn c_toggles_collapse_state() {
let mut app = fresh_app();