Preserve nested architecture during authoring and distinguish allocation summaries

This commit is contained in:
2026-09-05 17:58:46 +03:00
parent c20a2073d7
commit c7101b970a
13 changed files with 2719 additions and 1653 deletions
+71
View File
@@ -1,5 +1,76 @@
use oa_core::{projection::*, *};
#[test]
fn unplaced_work_parent_cannot_detach_a_leaf_from_its_visible_performer() {
let mut p = Project::empty();
let performer = p
.add_element(Kind::Entity, Layer::Oa, "Rescue team", None)
.unwrap();
let work = p
.add_element(Kind::Activity, Layer::Oa, "Respond", None)
.unwrap();
let leaf = p
.add_element(Kind::Activity, Layer::Oa, "Dispatch", Some(work))
.unwrap();
p.relate(RelationKind::Allocation, "Performs", performer, leaf);
let diagram = p.ensure_diagram(Layer::Oa);
p.diagrams.get_mut(&diagram).unwrap().projection = ProjectionKind::Allocation;
let owner = p.place(diagram, performer, Position { x: 0., y: 0. });
let child = p.place(diagram, leaf, Position { x: 40., y: 80. });
let view = project_view(&p, diagram);
assert_eq!(
view.nodes
.iter()
.find(|n| n.id == child)
.unwrap()
.visual_parent,
Some(owner)
);
let summary = p.place(diagram, work, Position { x: 24., y: 64. });
let view = project_view(&p, diagram);
assert!(
view.nodes
.iter()
.find(|n| n.id == summary)
.unwrap()
.allocation_summary
);
assert!(
!view
.nodes
.iter()
.find(|n| n.id == child)
.unwrap()
.allocation_summary
);
assert_eq!(
view.nodes
.iter()
.find(|n| n.id == child)
.unwrap()
.visual_parent,
Some(summary)
);
p.diagrams.get_mut(&diagram).unwrap().projection = ProjectionKind::FunctionalDataflow;
assert!(
project_view(&p, diagram)
.nodes
.iter()
.all(|n| !n.allocation_summary)
);
p.diagrams.get_mut(&diagram).unwrap().projection = ProjectionKind::Allocation;
p.diagrams.get_mut(&diagram).unwrap().nodes.remove(&summary);
let view = project_view(&p, diagram);
assert_eq!(
view.nodes
.iter()
.find(|n| n.id == child)
.unwrap()
.visual_parent,
Some(owner)
);
}
#[test]
fn architecture_is_nested_exchange_context_and_ports_attach_without_placements() {
let p = Project::demo();