Support setting referent properties via attributes (#843)

Co-authored-by: Kenneth Loeffler <kenloef@gmail.com>
This commit is contained in:
Micah
2024-06-20 15:48:52 -07:00
committed by GitHub
parent a7b45ee859
commit 7e2bab921a
64 changed files with 942 additions and 7 deletions

View File

@@ -360,3 +360,88 @@ fn no_name_top_level_project() {
);
});
}
#[test]
fn ref_properties() {
run_serve_test("ref_properties", |session, mut redactions| {
let info = session.get_api_rojo().unwrap();
let root_id = info.root_instance_id;
assert_yaml_snapshot!("ref_properties_info", redactions.redacted_yaml(info));
let read_response = session.get_api_read(root_id).unwrap();
assert_yaml_snapshot!(
"ref_properties_all",
read_response.intern_and_redact(&mut redactions, root_id)
);
fs::write(
session.path().join("ModelTarget.model.json"),
r#"{
"className": "Folder",
"attributes": {
"Rojo_Id": "model target 2"
},
"children": [
{
"name": "ModelPointer",
"className": "Model",
"attributes": {
"Rojo_Target_PrimaryPart": "model target 2"
}
},
{
"name": "ProjectPointer",
"className": "Model",
"attributes": {
"Rojo_Target_PrimaryPart": "project target"
}
}
]
}"#,
)
.unwrap();
let subscribe_response = session.get_api_subscribe(0).unwrap();
assert_yaml_snapshot!(
"ref_properties_subscribe",
subscribe_response.intern_and_redact(&mut redactions, ())
);
let read_response = session.get_api_read(root_id).unwrap();
assert_yaml_snapshot!(
"ref_properties_all-2",
read_response.intern_and_redact(&mut redactions, root_id)
);
});
}
#[test]
fn ref_properties_remove() {
run_serve_test("ref_properties_remove", |session, mut redactions| {
let info = session.get_api_rojo().unwrap();
let root_id = info.root_instance_id;
assert_yaml_snapshot!("ref_properties_remove_info", redactions.redacted_yaml(info));
let read_response = session.get_api_read(root_id).unwrap();
assert_yaml_snapshot!(
"ref_properties_remove_all",
read_response.intern_and_redact(&mut redactions, root_id)
);
fs::remove_file(session.path().join("src/target.model.json")).unwrap();
let subscribe_response = session.get_api_subscribe(0).unwrap();
assert_yaml_snapshot!(
"ref_properties_remove_subscribe",
subscribe_response.intern_and_redact(&mut redactions, ())
);
let read_response = session.get_api_read(root_id).unwrap();
assert_yaml_snapshot!(
"ref_properties_remove_all-2",
read_response.intern_and_redact(&mut redactions, root_id)
);
});
}