From c02fe8ca53c29fd55f215f8c1d52a88685c3a857 Mon Sep 17 00:00:00 2001 From: DWAA1660 Date: Sat, 10 Oct 2026 04:02:28 -0600 Subject: [PATCH] About dialog test: wait for each control to stop moving before clicking it (#671) (#703) The About dialog is a modal centred on its own size. Switching to the Contributors tab grows it, and for a few frames it recentres: here the Table toggle sits at y=378, then 355, then 341. The test waited a fixed four frames (#656) before clicking Table. Since the 0.5.0 contributors refresh that is not always enough (deterministic on some Debian machines, intermittent on the GitHub runners), so the click landed where the button had been and the table never opened: "No nodes found matching the query: By { label: \"PRs\" }" at links.rs:78. Clicking after one frame reproduces exactly that failure. A `settled` helper now runs frames until the target node exists and its rect is the same on two frames in a row, so the test no longer depends on how many frames the modal needs. The dialog itself is fine: a real click comes long after the two or three frames the modal takes to settle. Co-authored-by: DWAA1660 Co-authored-by: Claude Opus 5.5 --- crates/ui-egui/tests/links.rs | 39 ++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/crates/ui-egui/tests/links.rs b/crates/ui-egui/tests/links.rs index 199fdb3f..b08036b1 100644 --- a/crates/ui-egui/tests/links.rs +++ b/crates/ui-egui/tests/links.rs @@ -66,22 +66,37 @@ fn help_commands_open_each_link() { } } +/// Runs frames until the node labelled `label` exists and has stopped moving, then returns it. +/// +/// The About dialog is a modal centred on its own size, and switching tabs changes that size, so +/// for a few frames afterwards the modal grows and recentres and every control in it moves. A +/// fixed number of frames is a guess at how long that takes: it was too few after the 0.5.0 +/// contributors refresh (78 names instead of 5) on some machines, the click on Table landed where +/// the button had been, and the table never opened (#671). +fn settled<'a>(h: &'a mut Harness<'static, PdfCraftApp>, label: &'a str) -> egui_kittest::Node<'a> { + let mut last = None; + for _ in 0..60 { + h.run_steps(1); + let now = h.query_by_label(label).map(|n| n.rect()); + if now.is_some() && now == last { + return h.get_by_label(label); + } + last = now; + } + panic!("{label:?} never appeared or never stopped moving"); +} + #[test] fn about_dialog_has_contributors_and_models_tabs() { let mut h = harness(|app| app.dialog = Some(Dialog::About)); - h.get_by_label("Contributors").click(); - // Tab changes resize and recenter the modal as the compiled-in credits grow. - // Let its layout settle before clicking the next control at its new position. - h.run_steps(4); + settled(&mut h, "Contributors").click(); // The owner is always in the compiled-in credits (contributors/contributors.json), shown by username. - h.get_by_label("@echelon"); - h.get_by_label("Table").click(); - h.run_steps(4); - h.get_by_label("PRs"); - h.get_by_label("Display name").click(); - h.run_steps(4); - h.get_by_label("Brandon Thomas"); - h.get_by_label("Models").click(); + settled(&mut h, "@echelon"); + settled(&mut h, "Table").click(); + settled(&mut h, "PRs"); + settled(&mut h, "Display name").click(); + settled(&mut h, "Brandon Thomas"); + settled(&mut h, "Models").click(); h.run_steps(4); assert!(h.query_all_by_label("Anthropic").count() >= 1); }