Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

M4.10: shortcut-set alias test reads the legacy name from the alias table

bflatastic879295dd1a3d
diff --git a/crates/ui-egui/src/shortcut_editor.rs b/crates/ui-egui/src/shortcut_editor.rs
index e55e388f9..e145c7de8 100644
--- a/crates/ui-egui/src/shortcut_editor.rs
+++ b/crates/ui-egui/src/shortcut_editor.rs
@@ -20,7 +20,7 @@ use crate::{VectorcraftApp, menus, widgets};
pub const PRESETS: &[&str] = &["VectorCraft Defaults", "Classic Defaults"];
pub const CUSTOM: &str = "Custom";
/// Set names earlier versions saved: (old name, current name).
-const LEGACY_PRESETS: &[(&str, &str)] = &[("Illustrator Defaults", "Classic Defaults")]; // brand-ok: legacy preference value
+pub const LEGACY_PRESETS: &[(&str, &str)] = &[("Illustrator Defaults", "Classic Defaults")]; // brand-ok: legacy preference value
/// The current name of a shortcut set: names earlier versions saved map to today's.
pub fn set_name(name: &str) -> &str {
diff --git a/crates/ui-egui/src/tests_labels.rs b/crates/ui-egui/src/tests_labels.rs
index b67fc18b5..f17a0d6a0 100644
--- a/crates/ui-egui/src/tests_labels.rs
+++ b/crates/ui-egui/src/tests_labels.rs
@@ -84,10 +84,10 @@ fn clipboard_preferences_name_the_legacy_format_neutrally() {
#[test]
fn shortcut_set_old_name_is_accepted() {
use crate::shortcut_editor::{PRESETS, import_json};
- const OLD: &str = "Illustrator Defaults"; // brand-ok: legacy preference value under test
+ 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();
+ let ui: crate::state::UiState = serde_json::from_value(json!({ "shortcut_set": old })).unwrap();
assert_eq!(ui.shortcut_set, "Classic Defaults");
let saved = serde_json::to_value(&ui).unwrap();
assert_eq!(saved["shortcut_set"], "Classic Defaults");
@@ -97,11 +97,11 @@ fn shortcut_set_old_name_is_accepted() {
assert_eq!(default.shortcut_set, PRESETS[0]);
// The command and imported sets take the old name too.
let mut app = app();
- app.run("shortcuts.preset", json!({ "name": OLD })).unwrap();
+ app.run("shortcuts.preset", json!({ "name": old })).unwrap();
assert_eq!(app.ui.shortcut_set, "Classic Defaults");
app.run("shortcuts.preset", json!({ "name": "VectorCraft Defaults" })).unwrap();
assert_eq!(app.ui.shortcut_set, "VectorCraft Defaults");
assert!(app.run("shortcuts.preset", json!({ "name": "Nope" })).is_err());
- let (set, _) = import_json(&json!({ "set": OLD, "overrides": {} })).unwrap();
+ let (set, _) = import_json(&json!({ "set": old, "overrides": {} })).unwrap();
assert_eq!(set, "Classic Defaults");
}