use cotton_core::definitions::TableDefinition;use cotton_core::kit::AppKit;usesuper::*;fn tables() -> Vec<TableDefinition> { [ include_str!("../../../cotton-core/kits/personal/tables/book.json"), include_str!("../../../cotton-core/kits/personal/tables/film.json"), ] .iter() .map(|raw| TableDefinition::from_json(raw).expect("a kit table")) .collect()}/// RULE (15 Nov 2026): an app's own link opens the app on/// the record it names (`/lists/<table>/<id>`, host or path alike, as the/// iPhone reads it), on a tool it holds by its bare key, or as it stands/// when it names nothing; anything else, a table the app does not keep/// among them, says in the kit's words that nothing here opens it.#[test]fn an_apps_link_opens_its_record_its_tool_or_says_why_not() {let books = AppKit::named("books");let books = books.as_ref();let visit = json!({ "visit": { "table": "book", "id": "b-1" } }); assert_eq!(opens(books, &tables(), "cottonbooks://lists/book/b-1"), visit); assert_eq!(opens(books, &tables(), "cottonbooksdev:///lists/book/b-1?database=personal"), visit); assert_eq!(opens(books, &tables(), "cottonbooks://books"), json!({ "tool": "books" })); assert_eq!(opens(books, &tables(), "cottonbooks://"), json!({}));let refused = opens(books, &tables(), "cottonbooks://lists/film/f-1");let said = refused["said"].as_str().expect("said"); assert!(said.contains("lists/film/f-1") && !said.contains("Cotton"), "the app's words: {said}"); assert!(opens(books, &tables(), "cottonbooks://todos")["said"].is_string(), "a tool Books does not hold");let cinemas = AppKit::named("cinemas"); assert_eq!(opens(cinemas.as_ref(), &tables(), "cottoncinemas://lists/film/f-1"), json!({ "visit": { "table": "film", "id": "f-1" } }));}#[test]fn a_link_is_read_by_its_host_and_path() { assert_eq!(segments("cottonmusic://lists/song/s-1#top"), ["lists", "song", "s-1"]); assert_eq!(segments("cottonmusic:lists//song/"), ["lists", "song"]); assert!(segments("cottonmusic://?x=1").is_empty());}