mirror of
https://github.com/storytold/lightcraft.git
synced 2026-12-04 04:53:04 -05:00
Catalog date runs (stacks never split), Sort.group (auto/day/month/year/none) in the sort menus, library.groups query, sticky headers, header click selects the group; layout unit tests and a headless test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
35 lines
1.6 KiB
Rust
35 lines
1.6 KiB
Rust
//! Library management commands: date groups, keyword rename/delete/merge, batch rename, capture
|
|
//! time, label names, import review.
|
|
|
|
use serde_json::json;
|
|
|
|
use crate::Session;
|
|
|
|
/// Date headers follow the grid order and the sort's grouping.
|
|
#[test]
|
|
fn date_groups_follow_sort_and_grouping() {
|
|
let mut s = Session::with_demo();
|
|
let vis = s.visible_cloned();
|
|
let g = s.execute("library.groups", &json!({})).unwrap();
|
|
let groups = g.as_array().unwrap();
|
|
assert!(groups.len() > 3, "{g}");
|
|
let total: u64 = groups.iter().map(|x| x["count"].as_u64().unwrap()).sum();
|
|
assert_eq!(total as usize, vis.len());
|
|
// contiguous runs in grid order, labelled with weekday and date
|
|
let mut next = 0;
|
|
for x in groups {
|
|
assert_eq!(x["start"].as_u64().unwrap(), next);
|
|
next += x["count"].as_u64().unwrap();
|
|
assert!(x["label"].as_str().unwrap().contains(", "), "{x}");
|
|
}
|
|
let months = s.execute("library.groups", &json!({"by": "month"})).unwrap();
|
|
assert!(months.as_array().unwrap().len() < groups.len());
|
|
assert_eq!(months[0]["key"].as_str().unwrap().len(), 7);
|
|
s.execute("library.sort", &json!({"group": "none"})).unwrap();
|
|
assert_eq!(s.execute("library.groups", &json!({})).unwrap(), json!([]));
|
|
s.execute("library.sort", &json!({"group": "year", "key": "fileName"})).unwrap();
|
|
assert_eq!(s.execute("library.groups", &json!({})).unwrap(), json!([]), "no date headers when sorting by name");
|
|
assert_eq!(s.sort.group, lightcraft_catalog::GroupBy::Year);
|
|
assert!(s.execute("library.sort", &json!({"group": "week"})).is_err());
|
|
}
|