From 259fbbf3d8d048c3ea822cb0adaeeae7db8119d8 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Mon, 23 Nov 2026 04:04:28 +0700 Subject: [PATCH] Tests a-m: the halftone test sets its field through the control channel, the old shortcut set name loads as preferences are sanitized --- crates/ui-egui/src/tests/adjust.rs | 5 ++++- crates/ui-egui/src/tests/labels.rs | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/tests/adjust.rs b/crates/ui-egui/src/tests/adjust.rs index 53b895e512..3ad058127c 100644 --- a/crates/ui-egui/src/tests/adjust.rs +++ b/crates/ui-egui/src/tests/adjust.rs @@ -23,7 +23,10 @@ fn the_halftone_menu_item_opens_a_previewing_dialog() { dialogs::host::pump(&mut app, &ctx); assert!(app.session.in_interaction(), "the preview runs"); assert!(app.session.active().unwrap().doc.node(id).is_none(), "the preview shows the halftone in place of the art"); - app.run("ui.dialog.set", json!({"dialog": dialogs::halftone::CMD, "field": "mode", "value": "cmyk"})).unwrap(); + // A control channel method, not an engine command. + let (req, _) = craft::automation::ControlRequest::new("ui.dialog.set", json!({"field": "mode", "value": "cmyk"})); + let craft::automation::Reply::Done(r) = crate::control::handle(&mut app, &ctx, &req) else { panic!("ui.dialog.set answers at once") }; + assert_eq!(r["ok"], true, "{r}"); dialogs::host::pump(&mut app, &ctx); let undo = app.session.doc().unwrap().history.undo.len(); host.with(|h| h.confirm_by_id(&ctx, dialog)); diff --git a/crates/ui-egui/src/tests/labels.rs b/crates/ui-egui/src/tests/labels.rs index d91ebd372e..b37e2eacc2 100644 --- a/crates/ui-egui/src/tests/labels.rs +++ b/crates/ui-egui/src/tests/labels.rs @@ -359,7 +359,8 @@ fn shortcut_set_old_name_is_accepted() { let (old, _) = crate::shortcut_editor::LEGACY_PRESETS[0]; assert_eq!(PRESETS, ["VectorCraft Defaults", "Classic Defaults"]); // UI preferences saved by an earlier version load (and save again) under the current name. - let ui: crate::state::UiState = serde_json::from_value(json!({ "shortcut_set": old })).unwrap(); + // A loaded file's old keys become the sets as the settings are sanitized. + let ui = serde_json::from_value::(json!({ "shortcut_set": old })).unwrap().sanitized(); assert_eq!(ui.shortcut_sets.active_name(&BUILTINS), "Classic Defaults"); let saved = serde_json::to_value(&ui).unwrap(); assert_eq!(saved["shortcut_sets"]["active"], "Classic Defaults");