From 4e22873b44dfcf5ec6d5a8e7fd8b077501b07662 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Sun, 1 Nov 2026 12:01:33 -0500 Subject: [PATCH] Page opacity test: a scrub on the field is live and one undo step Co-Authored-By: Claude Fable 5.1 --- crates/ui-egui/src/field_tests.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/ui-egui/src/field_tests.rs b/crates/ui-egui/src/field_tests.rs index 8802bb7e9..a6fd9830f 100644 --- a/crates/ui-egui/src/field_tests.rs +++ b/crates/ui-egui/src/field_tests.rs @@ -1217,6 +1217,14 @@ fn the_page_background_opacity_field_sets_the_page_colour_alpha() { type_into(&mut u, "Opacity", "50", Key::Enter); assert!(near(page_bg(&u).a, 0.5), "{:?}", page_bg(&u)); assert_eq!(undo_steps(&u), steps + 1, "one undo step for the commit"); + // No label is drawn, so the field's leading strip scrubs it: a percent a point, live, and one + // undo step for the whole drag. + let edge = lead(&u, Id::unique("pagebg_a")); + drag(&mut u, edge, -25.0, Modifiers::NONE); + assert!(near(page_bg(&u).a, 0.25), "{:?}", page_bg(&u)); + assert_eq!(undo_steps(&u), steps + 2, "one undo step for the whole scrub"); + u.app.run("edit.undo", json!({})); + assert!(near(page_bg(&u).a, 0.5), "undo takes back the scrub alone"); // The hex field keeps the opacity when the typed colour has none, and takes one it carries. let hex = |u: &mut Ui| u.ctx.read_response(Id::unique("pagebg").with("click")).expect("the hex field").rect.center(); let at = hex(&mut u);