test(camera-raw): wait for the proxy worker before recording a revision

The dialog's own controls develop the preview on a worker (#5964), so after
the scope tone drags its last frame could land after the test recorded
previewRevision and bump it during the hover check that must not re-render.
A settle() helper waits until previewPending is false; the fixture and the
drag test call it before taking a baseline.

With a 20 ms delay added to the worker, the old test failed 9 of 10 runs
with the reviewer's assertion; with settle() all 21 tests passed 10 of 10.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
fjamesprice
2026-10-19 23:02:04 -04:00
co-authored by Claude Opus 5.5
parent eafc410ce2
commit bdf2e6cb31
+15
View File
@@ -39,8 +39,21 @@ fn fixture_render(theme: ThemeKind, gpu: bool) -> Harness<'static, PhotocraftApp
h.state_mut().set_theme(&ctx, theme);
h.run_steps(3);
assert_eq!(h.state().ui.theme, theme);
settle(&mut h);
h
}
/// Waits for the proxy develop that the dialog's own controls start on a worker (#5964), so its
/// frame can't land, and bump `previewRevision`, after a test has recorded the revision.
fn settle(h: &mut Harness<'_, PhotocraftApp>) {
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(30);
while inspect(h)["previewPending"] == true {
assert!(std::time::Instant::now() < deadline, "the Camera Raw preview worker never finished");
std::thread::sleep(std::time::Duration::from_millis(2));
h.run_steps(1);
}
// The frame that picked up the result also rebuilt the scope; let it go quiet.
h.run_steps(2);
}
fn press(h: &mut Harness<'_, PhotocraftApp>, p: Pos2, pressed: bool, modifiers: Modifiers) {
h.event(Event::ModifiersChanged(modifiers));
h.event(Event::PointerMoved(p));
@@ -218,6 +231,8 @@ fn real_drag_hover_warnings_sampler_motion_and_floating_scope_across_themes() {
let ctx = h.ctx.clone();
menu(h.state_mut(), &ctx, json!({"ui":{"scope":{"samplerTool":true,"vectorscope":true,"shadows":true,"highlights":true}}})).unwrap();
h.run_steps(3);
// The tone drags above developed on the worker; the last frame may still be on its way.
settle(&mut h);
let revision = inspect(&h)["previewRevision"].clone();
let scope_revision = inspect(&h)["scopeRevision"].clone();
let preview = rect(&h, "previewRect");