mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-26 02:59:17 -06:00
Menus: list Reshuffle once in the Sort submenu
library.shuffle's registry menu path made the menu builder append it a second time after the hand-built entry. Hide it from the auto-listing; test that it appears once and is enabled only while sorting at random. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
a72118ec6e
commit
17daca8a87
@@ -251,6 +251,7 @@ const HIDDEN: &[&str] = &[
|
||||
"photo.unflag",
|
||||
"photo.label",
|
||||
"library.sort",
|
||||
"library.shuffle",
|
||||
"album.addPhotos",
|
||||
"album.create",
|
||||
"library.import",
|
||||
@@ -790,6 +791,30 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
/// The Sort submenu is expanded by hand: Reshuffle appears once (not again from the registry),
|
||||
/// only while sorting at random, and the direction items are off for a shuffle.
|
||||
#[test]
|
||||
fn sort_menu_lists_reshuffle_once_and_only_enables_it_for_random() {
|
||||
fn sort_children(bar: &[(String, Vec<MenuNode>)]) -> Vec<MenuNode> {
|
||||
let view = &bar.iter().find(|(t, _)| t == "View").expect("View menu").1;
|
||||
view.iter()
|
||||
.find_map(|n| match n {
|
||||
MenuNode::Submenu { label, children } if label == "Sort" => Some(children.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.expect("Sort submenu")
|
||||
}
|
||||
let count = |nodes: &[MenuNode]| nodes.iter().filter(|n| matches!(n, MenuNode::Item { id, .. } if id == "library.shuffle")).count();
|
||||
let mut a = app();
|
||||
let kids = sort_children(&menu_bar(&a));
|
||||
assert_eq!(count(&kids), 1);
|
||||
assert!(matches!(find(&kids, "library.shuffle"), Some(MenuNode::Item { enabled: false, .. })), "off until Random is chosen");
|
||||
a.session.execute("library.sort", &json!({"key": "random"})).expect("sort at random");
|
||||
let kids = sort_children(&menu_bar(&a));
|
||||
assert_eq!(count(&kids), 1);
|
||||
assert!(matches!(find(&kids, "library.shuffle"), Some(MenuNode::Item { enabled: true, .. })));
|
||||
}
|
||||
|
||||
/// File opens with the import entry points, worded as importing (not as adding a sidebar
|
||||
/// folder): Import Photos… (⇧⌘I), Import from Folder…, Import from Device ▸.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user