From 96c0ca4db2be4ad60cf69bc5d18e036d485b23df Mon Sep 17 00:00:00 2001 From: THEtheChad <880190+THEtheChad@users.noreply.github.com> Date: Mon, 9 Nov 2026 17:18:45 -0600 Subject: [PATCH 1/2] test(ui-egui): #3822 the second folder drop waits for the Missing Photos count dont_ask_again_moves_the_next_drop_at_once read the home row's rect one frame after the first move. The move changes the Missing Photos count, which a worker takes: a count already running when beach.png moved finds its old path empty and adds the Missing Photos row, and the recount takes it away. Each shifts every folder row below it by one row, so on a busy machine the second drop, aimed at the rect read before the count landed, went to the folder above (dunes.png moved into the parent folder) or to trip ("Already in"). Waiting longer for home/dunes.png could not help. The test now settles the sidebar before reading the row, as other sidebar tests do, and runs with a slow count so the race happens on every run: it checks that the row stays put for longer than the count takes. Without the settle it fails every time ("home stays where the drop aims"). The move is synchronous, so the 20 s wait from #3834 is replaced by an immediate check that prints the toast, and the drag checks the drop hint before releasing. --- crates/ui-egui/src/tests/folder_drop.rs | 43 +++++++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/tests/folder_drop.rs b/crates/ui-egui/src/tests/folder_drop.rs index ba1dc5c501..d264013ea6 100644 --- a/crates/ui-egui/src/tests/folder_drop.rs +++ b/crates/ui-egui/src/tests/folder_drop.rs @@ -28,6 +28,11 @@ fn folders(tag: &str) -> (PathBuf, PathBuf, PathBuf) { /// The photos at `paths` in the catalog (`local`: browsed, not in the library), in the grid with /// the sidebar out, tall enough for the Folders section. fn app(paths: &[(PathBuf, bool)]) -> Headless { + app_prepared(paths, |_| {}) +} + +/// [`app`], with `prepare` run on the app before its first frame. +fn app_prepared(paths: &[(PathBuf, bool)], prepare: impl FnOnce(&mut LightcraftApp)) -> Headless { use lightcraft_catalog::{Op, Photo, Source}; let mut session = lightcraft_engine::Session::new().with_fs(); for (path, local) in paths { @@ -37,7 +42,9 @@ fn app(paths: &[(PathBuf, bool)]) -> Headless { p.local = *local; session.catalog.apply(Op::AddPhoto { photo: Box::new(p) }).unwrap(); } - let mut h = Headless::new(LightcraftApp::new(session, Services { png: None, ..Default::default() }), [1300.0, 1600.0], 1.0); + let mut app = LightcraftApp::new(session, Services { png: None, ..Default::default() }); + prepare(&mut app); + let mut h = Headless::new(app, [1300.0, 1600.0], 1.0); let r = h.request("ui.set", json!({"view": "photoGrid", "leftPanel": true, "sidebar": ["folders"]}), std::time::Duration::from_secs(10)); assert_eq!(r["ok"], true, "{r}"); for _ in 0..6 { @@ -317,11 +324,18 @@ fn cancelling_the_question_moves_nothing() { let _ = std::fs::remove_dir_all(&root); } +/// Issue #3822: the folder rows are read for the second drop only once the sidebar settled. The +/// first move changes the Missing Photos count, which a worker takes: a count that was running +/// when the photo moved finds its old place empty and adds the Missing Photos row, and the +/// recount takes it away again. Each moves every folder row below it, so on a busy machine a drop +/// aimed at the row read before the count landed went to the folder above (here, a slow count). #[test] fn dont_ask_again_moves_the_next_drop_at_once() { + let count = std::time::Duration::from_secs(1); let (root, trip, home) = folders("dont-ask"); std::fs::copy(trip.join("beach.png"), trip.join("dunes.png")).unwrap(); - let mut h = app(&[(trip.join("beach.png"), false), (trip.join("dunes.png"), false), (home.join("garden.png"), false)]); + let photos = [(trip.join("beach.png"), false), (trip.join("dunes.png"), false), (home.join("garden.png"), false)]; + let mut h = app_prepared(&photos, |app| app.missing_count_test_delay = Some(count)); click(&mut h, &format!("libraryFolderToggle:{}", folder_key(&root))); let target = folder_row(&h, &home).unwrap(); let beach = id_of(&h, "beach.png"); @@ -335,13 +349,28 @@ fn dont_ask_again_moves_the_next_drop_at_once() { // the next drop goes at once let dunes = id_of(&h, "dunes.png"); h.app.session.selection = lightcraft_engine::Selection::single(lightcraft_catalog::PhotoId(dunes)); - h.step(); + assert!(h.settle(std::time::Duration::from_secs(120)), "the sidebar settles after the move"); let target = folder_row(&h, &home).unwrap(); - drop_beach(&mut h, dunes, target); + // nothing moves the folder rows once settled, however long the count takes + let t0 = std::time::Instant::now(); + while t0.elapsed() < count { + h.step(); + std::thread::sleep(std::time::Duration::from_millis(5)); + } + assert_eq!(folder_row(&h, &home), Some(target), "home stays where the drop aims"); + let from = widget(&h, &format!("thumb:{dunes}")).unwrap().center(); + press(&mut h, from); + glide(&mut h, from, target.center()); + // (synthetic pointer events reach the app one a frame, the press's two included: one more + // frame brings the pointer to the end of the glide) + h.step(); + assert_eq!(hint(&h).as_deref(), Some("Move 1 photo to “home”"), "over home"); + release(&mut h, target.center()); + h.step(); assert!(h.app.ui.dialog.is_none(), "not asked"); - // no question comes first, but the file itself can take a moment on a busy machine - let moved = home.join("dunes.png"); - assert!(h.step_until(std::time::Duration::from_secs(20), |_| moved.is_file()), "moved without a question"); + // the move runs within the frame of the drop: a file not there now never moves, and the + // toast says why + assert!(home.join("dunes.png").is_file(), "moved without a question (toast: {:?})", toast(&h)); let _ = std::fs::remove_dir_all(&root); } From c1fa91c38956ad11bba8e04c2602f1bb1ce7585d Mon Sep 17 00:00:00 2001 From: THEtheChad <880190+THEtheChad@users.noreply.github.com> Date: Tue, 10 Nov 2026 14:37:43 -0600 Subject: [PATCH 2/2] test(ui-egui): #3822 say what the slow count in the folder-drop test catches Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/tests/folder_drop.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/tests/folder_drop.rs b/crates/ui-egui/src/tests/folder_drop.rs index d264013ea6..6bb1afe119 100644 --- a/crates/ui-egui/src/tests/folder_drop.rs +++ b/crates/ui-egui/src/tests/folder_drop.rs @@ -328,7 +328,9 @@ fn cancelling_the_question_moves_nothing() { /// first move changes the Missing Photos count, which a worker takes: a count that was running /// when the photo moved finds its old place empty and adds the Missing Photos row, and the /// recount takes it away again. Each moves every folder row below it, so on a busy machine a drop -/// aimed at the row read before the count landed went to the folder above (here, a slow count). +/// aimed at the row read before the count landed went to the folder above. The slow count here +/// doesn't make the drop miss by itself: it makes the rows move after the first move on every +/// run, and the test checks that `home` stays put once the sidebar settled. #[test] fn dont_ask_again_moves_the_next_drop_at_once() { let count = std::time::Duration::from_secs(1);