mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-30 02:07:10 +01:00
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.
This commit is contained in:
1 parent
5f92d8987f
commit
b0f821f2db
1 file changed
+34
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user