From 647c96e72d8d44fd770c5c546a7435874c974629 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 16:55:35 -0800 Subject: [PATCH] Tests: Simplify's kept settings come from OK in its dialog, and tool.options' phrase entries need no fixed wording The menu dialog test now turns on Retain with a new tolerance in the Simplify dialog, confirms it, and checks that the reopened dialog shows both. The tool.options test reads any non-list tools phrase as the transform tools' own mapping. --- crates/ui-egui/src/dialogs/tests.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/dialogs/tests.rs b/crates/ui-egui/src/dialogs/tests.rs index 8b8070257c..5311a8c2d3 100644 --- a/crates/ui-egui/src/dialogs/tests.rs +++ b/crates/ui-egui/src/dialogs/tests.rs @@ -1106,13 +1106,21 @@ fn menu_dialog_opens_the_dialog_keys_its_params_text_names() { for named in except.split('`').skip(1).step_by(2) { assert!(opened.iter().any(|key| key == named), "the params text names `{named}`, which no listed command opens"); } - // Simplify opens its dialog, under its command id, once OK in that dialog has kept the settings. + // Simplify opens its dialog, under its command id, with the kept tolerance once OK in that dialog has kept the + // settings. let mut app = menu_dialog_app("object.path.simplify"); - let ctx = app.ui_ctx.clone().expect("a window app"); - craft::ui::runtime::memory::set_saved_value(&ctx, &super::path_ops::SIMPLIFY_KEY, Some(craft::ui::patterns::form_dialogs::DialogFields::new())); + app.run("ui.menuDialog", json!({"command": "object.path.simplify"})).unwrap(); + settle(&mut app); + app.run("ui.simplifyMoreOptions", json!({})).unwrap(); + settle(&mut app); + set_all(&mut app, [("tolerance", json!(7.5)), ("retain", json!(true))]); + assert!(confirm(&mut app), "OK in the Simplify dialog is taken"); + settle(&mut app); app.run("ui.menuDialog", json!({"command": "object.path.simplify"})).unwrap(); settle(&mut app); assert_eq!(dialog_keys(&app), ["object.path.simplify"]); + assert_eq!(field(&app, "tolerance"), Some(7.5), "the reopened dialog shows the kept tolerance"); + assert!(flag(&app, "retain"), "the reopened dialog keeps Retain on"); } /// Every command whose dialog `ui.menuDialog` opens and `ui.inspect` lists, with a `key` or without one, is one its @@ -1155,12 +1163,12 @@ fn tool_options_opens_the_dialog_keys_its_params_text_names() { assert!(plain.contains("key in ui.inspect"), "the params text must say the dialog names are the `key` in ui.inspect"); let field = clause(&plain, "returned dialog field holds ", &['.']); // The `dialog` value the params text gives for `tool`: " for " pairs, where names the tool - // itself (with "the corresponding transform tool" and every value in the transform group) or one value for - // every tool in . + // itself (with a phrase rather than a `|` list of tool ids, and every value in the transform group) or one + // value for every tool in . let documented_dialog = |tool: &str| -> Option { let mut mappings = field.split(", ").map(|part| part.trim_start_matches("and ")).filter_map(|part| { let (values, tools) = part.split_once(" for ")?; - if tools == "the corresponding transform tool" && values.split('|').any(|v| v == tool) { + if tools.contains(' ') && values.split('|').any(|v| v == tool) { Some(tool.to_string()) } else if tools.split('|').any(|t| t == tool) { Some(values.to_string()) @@ -1177,7 +1185,7 @@ fn tool_options_opens_the_dialog_keys_its_params_text_names() { let mut named_tools = Vec::new(); for part in field.split(", ").map(|part| part.trim_start_matches("and ")) { let (values, tools) = part.split_once(" for ").unwrap_or_else(|| panic!("`{part}` pairs no dialog value with tools")); - let named = if tools == "the corresponding transform tool" { + let named = if tools.contains(' ') { assert!(values.split('|').all(|value| groups[0].split('|').any(|tool| tool == value)), "`{part}` names a non-transform tool"); values } else {