use materialcraft_formats::sbs::{read_sbs, write_sbs}; use serde_json::json; #[test] fn native_graph_attributes_load_and_survive_sbs_save() { for kind in ["graph", "function"] { let body = if kind == "function" { "" } else { "" }; let xml = format!( r#"<{kind}> {body}"# ); let imported = read_sbs(xml.as_bytes(), "attributes.sbs", &|_| None).unwrap().pkg; let expected = json!({"label": "Readable & non-unique label", "description": "First line\n

Second line

", "category": "Tools/Math", "author": "Example author", "authorUrl": "https://example.org/?a=1&b=2", "tags": "math utility", "group": "Utilities", "userData": "pipeline=example"}); assert_eq!(serde_json::to_value(&imported.graphs[0].attributes).unwrap(), expected, "{kind} import"); let bytes = write_sbs(&imported).unwrap(); let saved = read_sbs(&bytes, "saved.sbs", &|_| None).unwrap().pkg; assert_eq!(saved.graphs[0].name, "Stable_identifier"); assert_eq!(serde_json::to_value(&saved.graphs[0].attributes).unwrap(), expected, "{kind} save"); let xml = String::from_utf8(bytes).unwrap(); assert!(xml.contains("