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", <title>). 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 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: bherbruck <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-10-14 08:16:49 -04:00
1 parent 0f4cda0510
commit 3256fffe35
2 files changed
+5 -4

No files matched your search

+3 -1
View File
@@ -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 {
+2 -3
View File
@@ -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));