LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
UI tests: wait for the Remove missing tick to land before going on
Nathaniel Ledfordf7828fdfbcc0
diff --git a/crates/ui-egui/src/tests_sync.rs b/crates/ui-egui/src/tests_sync.rsindex 3873fbec1..bf1c33867 100644--- a/crates/ui-egui/src/tests_sync.rs+++ b/crates/ui-egui/src/tests_sync.rs@@ -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 openlet 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);