From b0f821f2db7378632b03b785ce1f3807d29ce4cb Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 00:39:56 -0800 Subject: [PATCH] Graph Type: test that typed numbers and text reach the draft only on commit The Column Width and Prefix rows write the draft only when their edit is committed. The existing dialog test still passed with either row reading every proposal while typing, so a new test types into each row, checks that the draft keeps its value, then presses Tab and checks that the typed value is in the draft. --- crates/ui-egui/src/dialogs/graph_type.rs | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/crates/ui-egui/src/dialogs/graph_type.rs b/crates/ui-egui/src/dialogs/graph_type.rs index 962b569dd7..1d75fd7b97 100644 --- a/crates/ui-egui/src/dialogs/graph_type.rs +++ b/crates/ui-egui/src/dialogs/graph_type.rs @@ -1219,6 +1219,40 @@ mod tests { } } + /// A number or text row leaves the draft alone while its text is still being typed, and writes + /// the typed value once Tab commits it. + #[test] + fn typed_number_and_text_rows_reach_the_draft_only_when_committed() { + use crate::tests::panel_harness::Panel; + use craft::ui::contract::Role; + use egui::{Key, Modifiers}; + + let mut app = app_with_graph("column"); + app.run(COMMAND, json!({"columnWidth": 80, "prefix": "USD"})).unwrap(); + let mut panel = Panel::new(app, crate::tests::picks::dialogs); + panel.room(egui::vec2(900.0, 900.0)); + open(&mut panel.app()).unwrap(); + panel.frame(); + panel.click_role("Column Width", Role::SPIN_BUTTON); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("140"); + panel.frame(); + assert_eq!(field(&panel.app(), "columnWidth"), json!(80.0), "a number being typed is not in the draft"); + panel.key(Key::Tab, Modifiers::NONE); + panel.frame(); + assert_eq!(field(&panel.app(), "columnWidth"), json!(140.0), "Tab commits the typed number"); + set(&panel.app(), PAGE, json!("valueAxis")).unwrap(); + panel.frame(); + panel.click_role("Prefix", Role::TEXT_INPUT); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("EUR"); + panel.frame(); + assert_eq!(field(&panel.app(), "prefix"), json!("USD"), "text being typed is not in the draft"); + panel.key(Key::Tab, Modifiers::NONE); + panel.frame(); + assert_eq!(field(&panel.app(), "prefix"), json!("EUR"), "Tab commits the typed text"); + } + /// Object › Graph › Type… opens the dialog on the selected graph's options, on its Graph /// Options page; each page the type has can be shown, and Override Calculated Values of the /// right axis takes input only while that axis has a scale of its own.