diff --git a/crates/ui-egui/src/tests/plugins.rs b/crates/ui-egui/src/tests/plugins.rs index c2a72c626d..6dc9853a2a 100644 --- a/crates/ui-egui/src/tests/plugins.rs +++ b/crates/ui-egui/src/tests/plugins.rs @@ -193,8 +193,13 @@ fn filter_dialog_previews_and_commits_one_undo_step() { assert_eq!(fields(h.state())["amount"], json!(100.0)); // A click in the visible slider must reach the same values the live preview reads. use egui_kittest::kittest::Queryable as _; + // Let the modal finish its opening placement before reading a widget's screen bounds. + for _ in 0..3 { + step(&mut h); + } let at = h.get_by_role(egui::accesskit::Role::Dialog).get_by_role(egui::accesskit::Role::Slider).rect().center(); h.input_mut().events.push(egui::Event::PointerMoved(at)); + step(&mut h); for pressed in [true, false] { h.input_mut().events.push(egui::Event::PointerButton { pos: at, @@ -204,7 +209,8 @@ fn filter_dialog_previews_and_commits_one_undo_step() { }); step(&mut h); } - assert!(fields(h.state())["amount"].as_f64().is_some_and(|amount| amount > 0.0 && amount < 100.0)); + let clicked = fields(h.state()); + assert!(clicked["amount"].as_f64().is_some_and(|amount| amount > 0.0 && amount < 100.0), "slider at {at:?}: {clicked}"); // Agents set fields like `ui.dialog.set` does; the frame previews them. set_field(&mut h, "amount", json!(50)).unwrap(); step(&mut h);