aboutsummaryrefslogtreecommitdiff
path: root/src/client/shell/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/shell/tests')
-rw-r--r--src/client/shell/tests/chrome_context.rs98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/client/shell/tests/chrome_context.rs b/src/client/shell/tests/chrome_context.rs
index 5747bb97..ed21bc8a 100644
--- a/src/client/shell/tests/chrome_context.rs
+++ b/src/client/shell/tests/chrome_context.rs
@@ -47,6 +47,104 @@ fn tab_overflow_controls_scroll_the_client_owned_tab_bar() {
}
#[test]
+fn focused_last_overflow_tab_shows_its_full_label() {
+ let mut projected = snapshot();
+ let labels = [
+ "1",
+ "Laiza Portfolio Site",
+ "linkedin posts",
+ "update cv",
+ "nvim",
+ "brother",
+ "day organiser",
+ "nvim test",
+ ];
+ projected.tabs = labels
+ .iter()
+ .enumerate()
+ .map(|(index, label)| ClientShellTab {
+ tab_id: format!("tab_{}", index + 1),
+ workspace_id: "ws_1".into(),
+ number: index + 1,
+ label: (*label).into(),
+ custom_label: index > 0,
+ zoomed: false,
+ focused: index == 7,
+ agent_status: AgentStatus::Idle,
+ })
+ .collect();
+ let mut state = ClientShellState::new(ClientShellConfig::from_config(&Config::default()));
+ for number in [8, 7, 8] {
+ let tab_id = format!("tab_{number}");
+ projected.focused_tab_id = Some(tab_id.clone());
+ projected.workspaces[0].active_tab_id = tab_id.clone();
+ projected.panes[0].tab_id = tab_id.clone();
+ for tab in &mut projected.tabs {
+ tab.focused = tab.tab_id == tab_id;
+ }
+ state.set_snapshot(Box::new(projected.clone()));
+ state.set_pane_surface(surface());
+ let frame = state
+ .compose(133, 20)
+ .expect("reporter's overflowing strip");
+ assert_eq!(
+ state.hits.new_tab.right() - state.hits.tab_scroll_left.x,
+ 107
+ );
+ let rect = state
+ .hits
+ .tabs
+ .iter()
+ .find(|(_, id)| id == &tab_id)
+ .expect("focused tab")
+ .0;
+ let text = (rect.x..rect.right())
+ .map(|x| {
+ frame.cells[(rect.y * frame.width + x) as usize]
+ .symbol
+ .as_str()
+ })
+ .collect::<String>();
+ assert!(
+ text.contains(labels[number - 1]),
+ "focused tab rendered as {text:?}, rect={rect:?}"
+ );
+ }
+
+ // Manual scrolling must be able to reveal the rest of a partially drawn last tab.
+ let end_scroll = state.tab_scroll;
+ let left = state.hits.tab_scroll_left;
+ state.handle_raw_events(vec![RawInputEvent::Mouse(MouseEvent {
+ kind: MouseEventKind::Down(MouseButton::Left),
+ column: left.x + 1,
+ row: left.y,
+ modifiers: KeyModifiers::empty(),
+ })]);
+ let frame = state.compose(133, 20).expect("manual scroll left");
+ assert_eq!(state.tab_scroll, end_scroll - 1);
+ let right = state.hits.tab_scroll_right;
+ assert_eq!(
+ frame.cells[(right.y * frame.width + right.x + 1) as usize].fg,
+ crate::protocol::color_to_u32(state.config.palette.overlay1),
+ "right arrow stays enabled while the final tab is clipped"
+ );
+ state.handle_raw_events(vec![RawInputEvent::Mouse(MouseEvent {
+ kind: MouseEventKind::Down(MouseButton::Left),
+ column: right.x + 1,
+ row: right.y,
+ modifiers: KeyModifiers::empty(),
+ })]);
+ let frame = state.compose(133, 20).expect("manual scroll right");
+ assert_eq!(state.tab_scroll, end_scroll);
+ assert!(frame_rows(&frame)[0].contains("nvim test"));
+ assert_eq!(
+ frame.cells[(right.y * frame.width + right.x + 1) as usize].fg,
+ crate::protocol::color_to_u32(state.config.palette.overlay0),
+ "right arrow dims at the useful scroll limit"
+ );
+}
+
+#[test]
fn focused_workspace_change_reveals_new_workspace_in_full_sidebar() {
let mut initial = snapshot();
let template = initial.workspaces[0].clone();