From 44538360e851149dbd5cfcdfac19125c799fb8bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernst=20W=C3=BCrger?= Date: Tue, 18 Jun 2024 12:25:26 +0200 Subject: [PATCH] fix(realization-view): Fix broken styleclass for edges (#106) --------- Co-authored-by: huyenngn --- capellambse_context_diagrams/context.py | 3 +-- capellambse_context_diagrams/serializers.py | 1 + tests/test_context_diagrams.py | 24 ++++++++++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/capellambse_context_diagrams/context.py b/capellambse_context_diagrams/context.py index 41f85941..a9786c31 100644 --- a/capellambse_context_diagrams/context.py +++ b/capellambse_context_diagrams/context.py @@ -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) diff --git a/capellambse_context_diagrams/serializers.py b/capellambse_context_diagrams/serializers.py index 0bb5aae2..a5f9c806 100644 --- a/capellambse_context_diagrams/serializers.py +++ b/capellambse_context_diagrams/serializers.py @@ -93,6 +93,7 @@ def make_diagram( self.diagram.calculate_viewport() self.order_children() + self._edges.clear() return self.diagram def deserialize_child( diff --git a/tests/test_context_diagrams.py b/tests/test_context_diagrams.py index 101b7857..cbba7589 100644 --- a/tests/test_context_diagrams.py +++ b/tests/test_context_diagrams.py @@ -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" @@ -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", [