use super::*; use crate::shell::client::phone_tests::attached; use serde_json::json; #[test] fn the_repeat_is_a_write() { assert!(!crate::methods::read_only("cards.repeat")); } #[test] fn a_todo_comes_round_weekly_then_monthly_then_stops() { let (_dir, client) = attached(); let made = crate::phone::records::call( &client, "records.create", &json!({"table":"todo","data":{"title":"Synthetic water the plants","due_at":"2026-10-22T09:00:00Z"}}), ) .unwrap(); let id = ["/record/id", "/id", "/after/id", "/change/after/id"] .iter() .find_map(|pointer| made.pointer(pointer).and_then(Value::as_str)) .unwrap_or_else(|| panic!("the made todo's id: {made}")) .to_string(); let series = |client: &ClientController| { let todo = crate::phone::records::call(client, "records.get", &json!({"table":"todo","id":id})).unwrap(); let data = todo.get("data").cloned().unwrap_or(todo); data["recurrence_id"].as_str().map(str::to_string) }; repeat(&client, &json!({"id":id,"preset":"weekly","timezone":"UTC"})).unwrap(); let weekly = series(&client).expect("the todo repeats"); repeat(&client, &json!({"id":id,"preset":"monthly","timezone":"UTC"})).unwrap(); let monthly = series(&client).expect("the todo still repeats"); assert_ne!(weekly, monthly, "a new rule is a new series from this occurrence"); assert_eq!(repeat(&client, &json!({"id":id,"preset":"monthly"})).unwrap()["unchanged"], true); repeat(&client, &json!({"id":id,"preset":"none"})).unwrap(); assert_eq!(series(&client), None); }