UI tests: wait for the Remove missing tick to land before going on

A click is queued input: under a loaded test run it could land after the
stale confirm had replaced the dialog, on a box that was disabled while
scanning, so the choice the test checks was never made.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nathaniel Ledford 2026-10-09 18:48:58 -04:00
parent 4153f62bb5
commit f7828fdfbc
No known key found for this signature in database
1 changed files with 10 additions and 6 deletions

View File

@ -109,6 +109,14 @@ fn synchronize(h: &mut Headless) {
assert!(h.step_until(T, |h| h.app.sync_run.is_none()), "the work finishes");
}
/// Tick "Remove missing photos" and wait until the click has landed (a click is queued input).
fn tick_remove_missing(h: &mut Headless) {
let r = h.request("ui.clickWidget", json!({"id": "syncRemoveMissing"}), T);
assert_eq!(r["ok"], true, "{r}");
let ticked = h.step_until(T, |h| matches!(h.app.ui.dialog, Some(Dialog::SynchronizeFolder { remove_missing: true, .. })));
assert!(ticked, "ticked");
}
fn counts(h: &Headless) -> crate::state::SyncCounts {
match &h.app.ui.dialog {
Some(Dialog::SynchronizeFolder { counts: Some(c), .. }) => c.clone(),
@ -140,9 +148,7 @@ fn ticking_remove_missing_also_removes_the_missing_photos() {
let dir = Scratch::new("remove");
let mut h = changed_folder(&dir);
open_and_scan(&mut h, &dir.path("trip"));
let r = h.request("ui.clickWidget", json!({"id": "syncRemoveMissing"}), T);
assert_eq!(r["ok"], true, "{r}");
h.step();
tick_remove_missing(&mut h);
synchronize(&mut h);
assert_eq!(in_library(&h), vec!["a.png", "c.png"], "b went to Recently Deleted");
let r = h.request("engine.execute", json!({"command": "edit.undo", "params": {}}), T);
@ -180,9 +186,7 @@ fn a_scan_gone_stale_in_the_dialog_is_made_again_in_the_background() {
let dir = Scratch::new("restale");
let mut h = changed_folder(&dir);
open_and_scan(&mut h, &dir.path("trip"));
let r = h.request("ui.clickWidget", json!({"id": "syncRemoveMissing"}), T);
assert_eq!(r["ok"], true, "{r}");
h.step();
tick_remove_missing(&mut h);
// a photo of the folder changes while the dialog is open
let a = h.app.session.catalog.photos().find(|p| p.file_name == "a.png").unwrap().id;
let r = h.request("engine.execute", json!({"command": "photo.rate", "params": {"ids": [a.0], "rating": 3}}), T);