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 <DWAA1660@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DWAA1660 2026-10-10 04:02:28 -06:00 committed by GitHub
parent e5e6ded35b
commit c02fe8ca53
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 27 additions and 12 deletions

View File

@ -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);
}