63 lines
2.2 KiB
Rust
63 lines
2.2 KiB
Rust
#[test]
|
|
fn traceability_show_menu_matches_cross_layer_and_port_placement_eligibility() {
|
|
let mut project = Project::empty();
|
|
let sa = project
|
|
.add_element(Kind::Function, Layer::Sa, "Counterpart", None)
|
|
.unwrap();
|
|
let port = Id::new_v4();
|
|
project.elements.insert(
|
|
port,
|
|
Element {
|
|
id: port,
|
|
alias: "legacy_port".into(),
|
|
name: "Port".into(),
|
|
description: String::new(),
|
|
parent: Some(sa),
|
|
body: ElementBody::shared_in(
|
|
Layer::Sa,
|
|
SharedBody::Port {
|
|
contract: PortContract::Legacy,
|
|
legacy: Some(LegacyPortContract {
|
|
direction: PortDirection::InOut,
|
|
interface: None,
|
|
}),
|
|
},
|
|
),
|
|
},
|
|
);
|
|
let diagram = project.ensure_diagram(Layer::Oa);
|
|
oa_core::validate_candidate(&project).unwrap();
|
|
for projection in [ProjectionKind::Overview, ProjectionKind::Traceability] {
|
|
let mut p = project.clone();
|
|
p.diagrams.get_mut(&diagram).unwrap().projection = projection;
|
|
let mut app = App::with_project(p);
|
|
app.page = Page::Diagram;
|
|
app.layer = Layer::Oa;
|
|
app.active_diagram = Some(diagram);
|
|
for object in [sa, port] {
|
|
send(&mut app, open(object, Point::ORIGIN));
|
|
let action = popup(&app)
|
|
.unwrap()
|
|
.entries
|
|
.into_iter()
|
|
.find_map(|e| match e {
|
|
Entry::Action { label, message, .. } if label == "Show in this diagram" => {
|
|
Some(message)
|
|
}
|
|
_ => None,
|
|
});
|
|
if object == port {
|
|
assert!(
|
|
action.is_none(),
|
|
"Ports never acquire independent node placements"
|
|
);
|
|
} else {
|
|
assert_eq!(
|
|
action.expect("non-port placement entry").is_some(),
|
|
projection == ProjectionKind::Traceability
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|