aboutsummaryrefslogtreecommitdiff
path: root/src/client/shell/tests/endpoints.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-09-15 15:02:07 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-09-15 15:02:09 +0300
commit9bd5f4ed37d9b087aa4e89d17f2d5ee74c69beae (patch)
tree1b38565f0c20d5f3109a8773f8bacb9c3457c45b /src/client/shell/tests/endpoints.rs
parent052779c4159ed851ae78ed1271130811986d1166 (diff)
fix: reveal newly focused workspaces in the machines sidebar
Diffstat (limited to 'src/client/shell/tests/endpoints.rs')
-rw-r--r--src/client/shell/tests/endpoints.rs69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/client/shell/tests/endpoints.rs b/src/client/shell/tests/endpoints.rs
index b43b9a31..de7abb3d 100644
--- a/src/client/shell/tests/endpoints.rs
+++ b/src/client/shell/tests/endpoints.rs
@@ -565,6 +565,75 @@ fn saved_machine_preserves_endpoint_scoped_worktree_collapses() {
}
#[test]
+fn expanded_machine_sidebar_reveals_newly_focused_workspace() {
+ let (mut state, remote_id) = state_with_remote();
+ let mut initial = snapshot();
+ let template = initial.workspaces[0].clone();
+ initial.workspaces = (1..=12)
+ .map(|number| ClientShellWorkspace {
+ workspace_id: format!("ws_{number}"),
+ number,
+ label: format!("space-{number}"),
+ focused: number == 1,
+ ..template.clone()
+ })
+ .collect();
+ // Reuse workspace IDs across machines so revealing must be endpoint-scoped.
+ let mut remote = initial.clone();
+ remote.boot_id = "remote-boot".into();
+ remote.workspaces.push(ClientShellWorkspace {
+ workspace_id: "ws_13".into(),
+ number: 13,
+ focused: false,
+ ..template.clone()
+ });
+ state.set_endpoint_snapshot(&remote_id, Box::new(remote));
+ state.set_snapshot(Box::new(initial));
+ state.compose(106, 20).expect("full machines sidebar");
+ assert!(state.hits.workspace_max_scroll > 0);
+
+ let mut update = state.snapshot.as_deref().expect("snapshot").clone();
+ update.revision = 2;
+ update.workspaces.push(ClientShellWorkspace {
+ workspace_id: "ws_13".into(),
+ number: 13,
+ label: "new-space".into(),
+ ..template
+ });
+ update.focused_workspace_id = Some("ws_13".into());
+ for workspace in &mut update.workspaces {
+ workspace.focused = workspace.workspace_id == "ws_13";
+ }
+ state.set_snapshot(Box::new(update));
+ let mut updated_surface = surface();
+ updated_surface.projection_revision = 2;
+ state.set_pane_surface(updated_surface);
+ state.compose(106, 2).expect("zero-height workspace body");
+ assert!(state.reveal_focused_workspace);
+ state.compose(106, 20).expect("new workspace revealed");
+ assert!(state
+ .hits
+ .workspaces
+ .iter()
+ .any(|hit| { hit.endpoint_id == ClientEndpointId::Local && hit.workspace_id == "ws_13" }));
+
+ state.workspace_scroll = 0;
+ state.compose(106, 20).expect("manual scroll");
+ assert_eq!(state.workspace_scroll, 0);
+ assert!(!state
+ .hits
+ .workspaces
+ .iter()
+ .any(|hit| { hit.endpoint_id == ClientEndpointId::Local && hit.workspace_id == "ws_13" }));
+ let unchanged = state.snapshot.as_deref().expect("snapshot").clone();
+ state.set_snapshot(Box::new(unchanged));
+ state
+ .compose(106, 20)
+ .expect("unchanged focus preserves scroll");
+ assert_eq!(state.workspace_scroll, 0);
+}
+
+#[test]
fn expanded_machine_sidebar_applies_space_row_gap_within_each_machine() {
let (mut state, remote_id) = state_with_remote();
state.config.spaces.row_gap = 1;