From dc6ba53e6e8ffb50719c60035f450ac7d8fd0133 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 23:06:27 -0800 Subject: [PATCH] Tool options: tests cover a canceled field edit that keeps the dialog open The Live Paint Bucket Width test and the nullable length test pressed Escape, which closes the modal, and then reopened it, so they passed with the number and length rows still reading only proposals. Each test now also types a value, adds text that does not parse, and leaves the field with Tab. The dialog stays open, and the row must hold the opening value again (4 px, and null). --- crates/ui-egui/src/dialogs/option_form.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/dialogs/option_form.rs b/crates/ui-egui/src/dialogs/option_form.rs index 7b127c08ef..fde3f40932 100644 --- a/crates/ui-egui/src/dialogs/option_form.rs +++ b/crates/ui-egui/src/dialogs/option_form.rs @@ -507,6 +507,15 @@ pub(super) mod tests { crate::toolbar::open_options(&mut panel.app(), "livePaintBucket").unwrap(); panel.frame(); assert_eq!(fields(&panel.app()), before); + panel.click_role("Width", Role::SPIN_BUTTON); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("9"); + assert_eq!(fields(&panel.app())["width"], 9.0, "typing proposes the width"); + panel.type_text("x"); + panel.key(Key::Tab, Modifiers::NONE); + panel.frame(); + assert!(is_open(&panel.app()), "leaving the field keeps the dialog open"); + assert_eq!(fields(&panel.app()), before, "leaving the field on text that is not a number restores the opening width"); if commit { panel.click_role("Width", Role::SPIN_BUTTON); panel.key(Key::A, Modifiers::COMMAND); @@ -530,7 +539,7 @@ pub(super) mod tests { /// Normal Gap Options supplies numeric points. This hosted row fixture separately checks /// the nullable length helper's contract, including restoring an empty opening value. #[test] - fn a_nullable_length_row_restores_null_on_escape() { + fn a_nullable_length_row_restores_null_when_its_typing_is_canceled() { static NULL_LENGTH: OptionSpec = OptionSpec { key: "nullableLengthTest", title: || "Nullable Length".into(), @@ -555,6 +564,15 @@ pub(super) mod tests { open(&mut panel.app(), &NULL_LENGTH, Map::from_iter([("length".into(), Value::Null)]), Value::Null).unwrap(); panel.frame(); assert_eq!(fields(&panel.app())["length"], Value::Null); + panel.click_role("Length", Role::SPIN_BUTTON); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("9 pt"); + assert_eq!(fields(&panel.app())["length"], 9.0); + panel.type_text("x"); + panel.key(Key::Tab, Modifiers::NONE); + panel.frame(); + assert!(is_open(&panel.app()), "leaving the field keeps the dialog open"); + assert_eq!(fields(&panel.app())["length"], Value::Null, "leaving the field on text that is not a length restores null"); } /// Whether `a` and `b` are the same value, numbers by their value.