Skip to content

Commit

Permalink
fix(realization-view): Fix broken styleclass for edges (#106)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: huyenngn <[email protected]>
  • Loading branch information
ewuerger and huyenngn authored Jun 18, 2024
1 parent 03d8285 commit 4453836
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
3 changes: 1 addition & 2 deletions capellambse_context_diagrams/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,12 +540,11 @@ def _create_diagram(self, params: dict[str, t.Any]) -> cdiagram.Diagram:
for edge in edges:
layout.children.append(
_elkjs.ELKOutputEdge(
id=edge.id,
id=f"__Realization:{edge.id}",
type="edge",
sourceId=edge.sources[0],
targetId=edge.targets[0],
routingPoints=[],
styleclass="Realization",
)
)
self._add_layer_labels(layout)
Expand Down
1 change: 1 addition & 0 deletions capellambse_context_diagrams/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def make_diagram(

self.diagram.calculate_viewport()
self.order_children()
self._edges.clear()
return self.diagram

def deserialize_child(
Expand Down
24 changes: 23 additions & 1 deletion tests/test_context_diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
"f0bc11ba-89aa-4297-98d2-076440e9117f",
}
TEST_DERIVED_UUID = "dbd99773-efb6-4476-bf5c-270a61f18b09"
TEST_ENTITY_UUID = "e37510b9-3166-4f80-a919-dfaac9b696c7"


@pytest.mark.parametrize(
"uuid",
[
pytest.param("e37510b9-3166-4f80-a919-dfaac9b696c7", id="Entity"),
pytest.param(TEST_ENTITY_UUID, id="Entity"),
pytest.param("8bcb11e6-443b-4b92-bec2-ff1d87a224e7", id="Activity"),
pytest.param(
"344a405e-c7e5-4367-8a9a-41d3d9a27f81", id="SystemComponent"
Expand Down Expand Up @@ -58,10 +59,31 @@ def test_context_diagrams(model: capellambse.MelodyModel, uuid: str) -> None:
obj = model.by_uuid(uuid)

diag = obj.context_diagram
diag.render(None, display_parent_relation=True)
diag.render(None, display_parent_relation=False)

assert diag.nodes


@pytest.mark.parametrize(
"parameter",
[
"display_parent_relation",
"display_symbols_as_boxes",
"display_derived_interfaces",
"slim_center_box",
],
)
def test_context_diagrams_rerender_on_parameter_change(
model: capellambse.MelodyModel, parameter: str
) -> None:
obj = model.by_uuid(TEST_ENTITY_UUID)

diag = obj.context_diagram
diag.render(None, **{parameter: True})
diag.render(None, **{parameter: False})


@pytest.mark.parametrize(
"diagram_elements",
[
Expand Down

0 comments on commit 4453836

Please sign in to comment.