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).
This commit is contained in:
dotCooCoo committed 2026-11-28 23:06:27 -08:00
1 parent 67f9daecb8
commit dc6ba53e6e
1 file changed
+19 -1
+19 -1
View File
@@ -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.