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.
This commit is contained in:
dotCooCoo committed 2026-11-29 16:55:35 -08:00
1 parent a1bba4a8e4
commit 647c96e72d
1 file changed
+15 -7
+15 -7
View File
@@ -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`: "<values> for <tools>" pairs, where <values> names the tool
// itself (with <tools> "the corresponding transform tool" and every value in the transform group) or one value for
// every tool in <tools>.
// itself (with <tools> a phrase rather than a `|` list of tool ids, and every value in the transform group) or one
// value for every tool in <tools>.
let documented_dialog = |tool: &str| -> Option<String> {
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 {