use super::*; use crate::shell::client::phone_tests::attached; use serde_json::json; fn todo(client: &crate::shell::client::ClientController, data: Value) -> String { let made = crate::phone::records::call(client, "records.create", &json!({"table":"todo","data":data})).unwrap(); ["/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() } #[test] fn a_todo_is_its_face_then_its_notes() { let (_dir, client) = attached(); let plain = todo(&client, json!({"title":"Synthetic post the letter"})); let answer = of_record(&client, &json!({"table":"todo","id":plain})).unwrap(); assert_eq!(answer["pages"], json!([{"kind":"face","label":"1 / 1"}])); let noted = todo(&client, json!({"title":"Synthetic pack","notes":"Passport and charger."})); let answer = of_record(&client, &json!({"table":"todo","id":noted})).unwrap(); assert_eq!( answer["pages"], json!([ {"kind":"face","label":"1 / 2"}, {"kind":"text","column":"notes","text":"Passport and charger.","label":"2 / 2"} ]) ); }