use super::*; use serde_json::json; fn args(value: Value) -> Map { value.as_object().cloned().expect("an object") } /// RULE: A session list read is cut by the queue's seven-day window unless it is a search of two characters or more or one project's list, which reach past it as the app's history card does, and a page is cut by the window. #[test] fn a_search_or_one_projects_list_is_cut_as_history() { let window = Cut::Window(SESSIONS_WINDOW_MS); assert_eq!(cut_of(&args(json!({})), false), window); assert_eq!(cut_of(&args(json!({ "query": "a" })), false), window, "one character is no search"); assert_eq!(cut_of(&args(json!({ "query": "branch" })), false), Cut::History); assert_eq!(cut_of(&args(json!({ "project": "field-notes" })), false), Cut::History); assert_eq!(cut_of(&args(json!({ "where": { "project_id": "p-1" } })), false), Cut::History); assert_eq!(cut_of(&args(json!({ "query": "branch" })), true), window); } /// RULE: A session's stored row is spelled to the words' rules in the camelCase list_sessions answers, a null column left out, so the generic read and the phone's reads feed the one copy of the rules the same row. #[test] fn a_row_is_spelled_as_list_sessions_spells_it() { let row = args(json!({ "id": "s-1", "host_owned": true, "last_active_at": "2026-09-21T12:00:00.000Z", "ended_at": null })); let spelled = spelled(&row, SESSION_FIELDS); assert_eq!(spelled["hostOwned"], true); assert_eq!(spelled["lastActiveAt"], "2026-09-21T12:00:00.000Z"); assert!(spelled.get("endedAt").is_none() && spelled.get("ended_at").is_none(), "{spelled:?}"); }