Tests a-m: the halftone test sets its field through the control channel, the old shortcut set name loads as preferences are sanitized

This commit is contained in:
bflatastic
2026-11-23 04:04:28 +07:00
parent 587e890142
commit 259fbbf3d8
2 changed files with 6 additions and 2 deletions
+4 -1
View File
@@ -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));
+2 -1
View File
@@ -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::<crate::state::UiState>(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");