From 3256fffe35cc1c11b4aedb1ec5ca53ba453edc31 Mon Sep 17 00:00:00 2001 From: Philipp Bischoff <86558944+PhilippBischoff0@users.noreply.github.com> Date: Wed, 14 Oct 2026 14:16:49 +0200 Subject: [PATCH] test(ui): find command dialogs by their published rect (#1011) The dialog_docked scenario check and the ui_layout width test looked up the dialog window by the id "sc_dialog", but dialogs are now registered under ("sc_dialog", ). Every lookup failed with "no command dialog", so the test had to stay ignored and could no longer catch an oversized dialog. Read the rect the dialog publishes each frame instead (viewport dialog_rect in the check, "dialog:outer" in the test), and re-enable every_dialog_opens_docked_within_its_width_limits. The exploded view dialog it was ignored for now opens 365 px wide, inside its limits. Claude-Session: https://claude.ai/code/session_01VbBYY5zfMXgq939AF9Vren Co-authored-by: PhilippBischoff0 <PhilippBischoff0@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: bherbruck <brennen.herbruck@gmail.com> --- crates/ui-egui/src/scenario.rs | 4 +++- crates/ui-egui/tests/ui_layout.rs | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/scenario.rs b/crates/ui-egui/src/scenario.rs index f8162f5a..6af116b3 100644 --- a/crates/ui-egui/src/scenario.rs +++ b/crates/ui-egui/src/scenario.rs @@ -731,7 +731,9 @@ pub fn check(h: &mut Harness, e: &Value) -> Result<(), String> { } "dialog_docked" => { // The command dialog: docked at the viewport's right, its width in [min, max]. - let r = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_dialog"))).ok_or("no command dialog")?; + // Its window id carries the dialog's title, so read the rect the dialog + // publishes each frame rather than looking up a fixed id. + let r = h.app.viewport.dialog_rect.filter(|_| h.app.dialog.is_some()).ok_or("no command dialog")?; let vp = h.app.viewport.rect.unwrap_or(egui::Rect::NOTHING); let (lo, hi) = (v["min"].as_f64().unwrap_or(260.0) as f32, v["max"].as_f64().unwrap_or(380.0) as f32); if r.width() < lo - 0.5 || r.width() > hi + 0.5 { diff --git a/crates/ui-egui/tests/ui_layout.rs b/crates/ui-egui/tests/ui_layout.rs index eafb13de..eb4acd28 100644 --- a/crates/ui-egui/tests/ui_layout.rs +++ b/crates/ui-egui/tests/ui_layout.rs @@ -3,7 +3,7 @@ //! every window it opens fits on screen. use serde_json::{Value, json}; -use solidcraft_ui_egui::scenario::{Harness, check}; +use solidcraft_ui_egui::scenario::{Harness, check, rect_of}; /// A box body (its sketch finished) to give feature dialogs something to work on. fn harness() -> Harness { @@ -21,7 +21,6 @@ fn harness() -> Harness { } #[test] -#[ignore = "pending: the exploded view dialog opens 635 px wide (solidcraft-ui)"] fn every_dialog_opens_docked_within_its_width_limits() { let mut bad = Vec::new(); let mut seen = 0; @@ -36,7 +35,7 @@ fn every_dialog_opens_docked_within_its_width_limits() { seen += 1; // Command dialogs are 260–380 px (plus their 1 px border), the few with tables // (motion study, configurations) 480–560. - let w = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_dialog"))).map_or(0.0, |r| r.width()); + let w = rect_of("dialog:outer").map_or(0.0, |r| r.width()); let limits = if w > 400.0 { json!({"min": 480, "max": 562}) } else { json!({"min": 260, "max": 382}) }; if let Err(e) = check(&mut h, &json!({ "dialog_docked": limits })) { bad.push(format!("{}: {e}", spec.id));