From edaa41cf0596f8bf18945b22ac5b856d62736edb Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 26 Oct 2026 00:07:40 +0000 Subject: [PATCH] Panels: tests find the rail by its own button, since it is drawn inside the canvas panel --- crates/ui-egui/src/panels.rs | 10 ++++++++-- crates/ui-egui/src/workspace_ui.rs | 10 ++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 0ddf937278f..389d684fc94 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -6793,6 +6793,12 @@ mod embedding_tests { egui::containers::panel::PanelState::load(&h.ctx, panel_state_id(&h.ctx, panel)).is_some() } + /// The rail is drawn inside the canvas panel, so its panel state is keyed under that panel's + /// scope: find it by a button only the rail has. + fn rail_drawn(h: &egui_kittest::Harness<'_, PhotocraftApp>) -> bool { + h.query_by_label("Color & Swatches").is_some() + } + /// An app that embeds the UI can hide the icon rail and the menu bar; both are on by default. #[test] fn rail_and_menu_bar_follow_their_panel_flags() { @@ -6800,11 +6806,11 @@ mod embedding_tests { assert!(panels.rail && panels.menu_bar); let h = whole_app(true, true); - assert!(drawn(&h, "rail") && drawn(&h, "title_bar")); + assert!(rail_drawn(&h) && drawn(&h, "title_bar")); assert!(h.query_by_label("File").is_some()); let h = whole_app(false, false); - assert!(!drawn(&h, "rail"), "the icon rail is drawn"); + assert!(!rail_drawn(&h), "the icon rail is drawn"); assert!(!drawn(&h, "title_bar"), "the title bar is drawn"); assert!(h.query_by_label("File").is_none(), "the menus are drawn"); assert!(crate::panel_docking::last_bodies(&h.ctx).iter().any(|(id, _)| id == "layers"), "the dock itself stays"); diff --git a/crates/ui-egui/src/workspace_ui.rs b/crates/ui-egui/src/workspace_ui.rs index bb182045ed6..b5a67b1800d 100644 --- a/crates/ui-egui/src/workspace_ui.rs +++ b/crates/ui-egui/src/workspace_ui.rs @@ -597,10 +597,12 @@ mod tests { crate::menus::invoke(h.state_mut(), &ctx, "window.workspace.select", json!({"name": "Embedded"})).unwrap(); h.run_steps(4); assert_eq!(h.state().ui.theme, theme, "the fixture renders the requested theme"); - for name in ["title_bar", "rail"] { - if egui::containers::panel::PanelState::load(&h.ctx, crate::panels::panel_state_id(&h.ctx, name)).is_some() { - failures.push(format!("{theme:?}, width={width}: {name} is drawn")); - } + if egui::containers::panel::PanelState::load(&h.ctx, crate::panels::panel_state_id(&h.ctx, "title_bar")).is_some() { + failures.push(format!("{theme:?}, width={width}: title_bar is drawn")); + } + // The rail is drawn inside the canvas panel: find it by a button only it has. + if egui_kittest::kittest::Queryable::query_by_label(&h, "Color & Swatches").is_some() { + failures.push(format!("{theme:?}, width={width}: rail is drawn")); } if h.state().ui.panels.menu_bar || h.state().ui.panels.rail { failures.push(format!("{theme:?}, width={width}: host flags were overwritten"));