|
31 | 31 | import org.eclipse.sirius.components.collaborative.diagrams.dto.InvokeSingleClickOnTwoDiagramElementsToolSuccessPayload; |
32 | 32 | import org.eclipse.sirius.components.diagrams.tests.graphql.ConnectorToolsQueryRunner; |
33 | 33 | import org.eclipse.sirius.components.diagrams.tests.graphql.InvokeSingleClickOnTwoDiagramElementsToolMutationRunner; |
| 34 | +import org.eclipse.sirius.components.diagrams.tests.graphql.PaletteQueryRunner; |
34 | 35 | import org.eclipse.sirius.components.diagrams.tests.navigation.DiagramNavigator; |
35 | 36 | import org.eclipse.sirius.web.tests.services.api.IGivenInitialServerState; |
36 | 37 | import org.eclipse.syson.AbstractIntegrationTests; |
@@ -78,6 +79,9 @@ public class GVInheritedPortTests extends AbstractIntegrationTests { |
78 | 79 | @Autowired |
79 | 80 | private ShowDiagramsInheritedMembersMutationRunner showDiagramsInheritedMembersMutationRunner; |
80 | 81 |
|
| 82 | + @Autowired |
| 83 | + private PaletteQueryRunner paletteQueryRunner; |
| 84 | + |
81 | 85 | private Flux<DiagramRefreshedEventPayload> givenSubscriptionToDiagram() { |
82 | 86 | var diagramEventInput = new DiagramEventInput(UUID.randomUUID(), |
83 | 87 | GeneralViewInheritedPortTestProjectData.EDITING_CONTEXT_ID, |
@@ -369,4 +373,42 @@ public void checkInheritedPortAsSourceAndTargetRedefinition(String parameterized |
369 | 373 | .thenCancel() |
370 | 374 | .verify(Duration.ofSeconds(10)); |
371 | 375 | } |
| 376 | + |
| 377 | + @DisplayName("GIVEN a diagram with some inherited port, WHEN palette is retrieved, THEN delete and rename tools should not be available") |
| 378 | + @Sql(scripts = { GeneralViewInheritedPortTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, |
| 379 | + config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
| 380 | + @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
| 381 | + @Test |
| 382 | + public void checkInheritedPortPalette() { |
| 383 | + var flux = this.givenSubscriptionToDiagram(); |
| 384 | + var diagramId = new AtomicReference<String>(); |
| 385 | + var inheritedPortId = new AtomicReference<String>(); |
| 386 | + |
| 387 | + Consumer<Object> initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram -> { |
| 388 | + diagramId.set(diagram.getId()); |
| 389 | + var v1Node = new DiagramNavigator(diagram).nodeWithLabel("\u00ABpart\u00BB\nv1 : Vehicle").getNode(); |
| 390 | + assertThat(v1Node.getBorderNodes()).hasSize(1); |
| 391 | + assertThat(v1Node.getBorderNodes()).allMatch(node -> node.getOutsideLabels().get(0).text().equals("^fuelInPort : FuelPort")); |
| 392 | + inheritedPortId.set(v1Node.getBorderNodes().get(0).getId()); |
| 393 | + }); |
| 394 | + |
| 395 | + Runnable triggerEdgeTool = () -> { |
| 396 | + Map<String, Object> variables = Map.of( |
| 397 | + "editingContextId", GeneralViewInheritedPortTestProjectData.EDITING_CONTEXT_ID, |
| 398 | + "representationId", diagramId.get(), |
| 399 | + "diagramElementId", inheritedPortId.get() |
| 400 | + ); |
| 401 | + var result = this.paletteQueryRunner.run(variables); |
| 402 | + List<String> quickAccessToolIds = JsonPath.read(result, "$.data.viewer.editingContext.representation.description.palette.quickAccessTools[*].id"); |
| 403 | + assertThat(quickAccessToolIds).doesNotContain("semantic-delete", "edit"); |
| 404 | + List<String> editToolSectionIds = JsonPath.read(result, "$.data.viewer.editingContext.representation.description.palette.paletteEntries[?(@.id=='edit-section')].tools[*].id"); |
| 405 | + assertThat(editToolSectionIds).doesNotContain("semantic-delete", "edit"); |
| 406 | + }; |
| 407 | + |
| 408 | + StepVerifier.create(flux) |
| 409 | + .consumeNextWith(initialDiagramContentConsumer) |
| 410 | + .then(triggerEdgeTool) |
| 411 | + .thenCancel() |
| 412 | + .verify(Duration.ofSeconds(10)); |
| 413 | + } |
372 | 414 | } |
0 commit comments