|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2024, 2025 Obeo. |
| 2 | + * Copyright (c) 2024, 2026 Obeo. |
3 | 3 | * This program and the accompanying materials |
4 | 4 | * are made available under the terms of the Eclipse Public License v2.0 |
5 | 5 | * which accompanies this distribution, and is available at |
|
26 | 26 |
|
27 | 27 | import org.eclipse.sirius.components.collaborative.dto.CreateChildInput; |
28 | 28 | import org.eclipse.sirius.components.collaborative.dto.CreateChildSuccessPayload; |
| 29 | +import org.eclipse.sirius.components.collaborative.forms.dto.EditSelectInput; |
29 | 30 | import org.eclipse.sirius.components.collaborative.forms.dto.FormRefreshedEventPayload; |
| 31 | +import org.eclipse.sirius.components.core.api.SuccessPayload; |
30 | 32 | import org.eclipse.sirius.components.forms.AbstractWidget; |
| 33 | +import org.eclipse.sirius.components.forms.Select; |
| 34 | +import org.eclipse.sirius.components.forms.tests.graphql.EditSelectMutationRunner; |
31 | 35 | import org.eclipse.sirius.web.AbstractIntegrationTests; |
32 | 36 | import org.eclipse.sirius.web.application.views.details.dto.DetailsEventInput; |
33 | 37 | import org.eclipse.sirius.web.data.StudioIdentifiers; |
@@ -61,6 +65,9 @@ public class DiagramViewControllerIntegrationTests extends AbstractIntegrationTe |
61 | 65 | @Autowired |
62 | 66 | private CreateChildMutationRunner createChildMutationRunner; |
63 | 67 |
|
| 68 | + @Autowired |
| 69 | + private EditSelectMutationRunner editSelectMutationRunner; |
| 70 | + |
64 | 71 | @Autowired |
65 | 72 | private DetailsEventSubscriptionRunner detailsEventSubscriptionRunner; |
66 | 73 |
|
@@ -149,4 +156,96 @@ public void givenAViewWhenADiagramDescriptionIsCreatedThenItIsCreatedProperly() |
149 | 156 | } |
150 | 157 |
|
151 | 158 |
|
| 159 | + @Test |
| 160 | + @GivenSiriusWebServer |
| 161 | + @DisplayName("Given a diagram description, when an edge style is edited, then it is possible to select the ClosedArrowWith4Dots arrow style") |
| 162 | + public void givenADiagramDescriptionWhenAEdgeStyleIsEditedThenItIsPossibleToSelectTheClosedArrowWith4DotsArrowStyle() { |
| 163 | + var objectId = "a2a3713f-57bc-422b-92e8-b22ed69e94a8"; // The edge style of the sample studio |
| 164 | + var detailsRepresentationId = this.representationIdBuilder.buildDetailsRepresentationId(List.of(objectId)); |
| 165 | + var input = new DetailsEventInput(UUID.randomUUID(), StudioIdentifiers.SAMPLE_STUDIO_EDITING_CONTEXT_ID, detailsRepresentationId); |
| 166 | + var flux = this.detailsEventSubscriptionRunner.run(input) |
| 167 | + .flux() |
| 168 | + .filter(FormRefreshedEventPayload.class::isInstance); |
| 169 | + |
| 170 | + var sourceArrowStyleWidgetId = new AtomicReference<String>(); |
| 171 | + var targetArrowStyleWidgetId = new AtomicReference<String>(); |
| 172 | + var closedArrowWith4DotsValue = new AtomicReference<String>(); |
| 173 | + |
| 174 | + Consumer<Object> formContentBeforeEdit = assertRefreshedFormThat(form -> { |
| 175 | + var firstPage = form.getPages().get(0); |
| 176 | + var firstGroup = firstPage.getGroups().get(0); |
| 177 | + var sourceArrowStyleWidget = firstGroup.getWidgets().stream() |
| 178 | + .filter(Select.class::isInstance) |
| 179 | + .map(Select.class::cast) |
| 180 | + .filter(selectWidget -> Objects.equals("Source Arrow Style", selectWidget.getLabel())) |
| 181 | + .findFirst(); |
| 182 | + assertThat(sourceArrowStyleWidget).isPresent(); |
| 183 | + assertThat(sourceArrowStyleWidget.get().getValue()).isEqualTo("0"); |
| 184 | + var sourceArrowStyleWidgetOptions = sourceArrowStyleWidget.get().getOptions(); |
| 185 | + var optClosedArrowWith4Dots = sourceArrowStyleWidgetOptions.stream() |
| 186 | + .filter(selectOption -> Objects.equals("ClosedArrowWith4Dots", selectOption.getLabel())) |
| 187 | + .findFirst(); |
| 188 | + assertThat(optClosedArrowWith4Dots).isPresent(); |
| 189 | + sourceArrowStyleWidgetId.set(sourceArrowStyleWidget.get().getId()); |
| 190 | + closedArrowWith4DotsValue.set(optClosedArrowWith4Dots.get().getId()); |
| 191 | + |
| 192 | + var targetArrowStyleWidget = firstGroup.getWidgets().stream() |
| 193 | + .filter(Select.class::isInstance) |
| 194 | + .map(Select.class::cast) |
| 195 | + .filter(selectWidget -> Objects.equals("Target Arrow Style", selectWidget.getLabel())) |
| 196 | + .findFirst(); |
| 197 | + assertThat(targetArrowStyleWidget).isPresent(); |
| 198 | + assertThat(targetArrowStyleWidget.get().getValue()).isEqualTo("2"); |
| 199 | + assertThat(targetArrowStyleWidget.get().getOptions()).anyMatch(selectOption -> Objects.equals("ClosedArrowWith4Dots", selectOption.getLabel())); |
| 200 | + targetArrowStyleWidgetId.set(targetArrowStyleWidget.get().getId()); |
| 201 | + }); |
| 202 | + |
| 203 | + Runnable editSourceArrowStyle = () -> { |
| 204 | + var editSelectSourceArrowStyleInput = new EditSelectInput(UUID.randomUUID(), StudioIdentifiers.SAMPLE_STUDIO_EDITING_CONTEXT_ID, detailsRepresentationId, sourceArrowStyleWidgetId.get(), closedArrowWith4DotsValue.get()); |
| 205 | + var result = this.editSelectMutationRunner.run(editSelectSourceArrowStyleInput); |
| 206 | + var typename = JsonPath.read(result.data(), "$.data.editSelect.__typename"); |
| 207 | + assertThat(typename).isEqualTo(SuccessPayload.class.getSimpleName()); |
| 208 | + }; |
| 209 | + |
| 210 | + Consumer<Object> formContentAfterSourceArrowStyleEdit = assertRefreshedFormThat(form -> { |
| 211 | + var firstPage = form.getPages().get(0); |
| 212 | + var firstGroup = firstPage.getGroups().get(0); |
| 213 | + var sourceArrowStyleWidget = firstGroup.getWidgets().stream() |
| 214 | + .filter(Select.class::isInstance) |
| 215 | + .map(Select.class::cast) |
| 216 | + .filter(selectWidget -> Objects.equals("Source Arrow Style", selectWidget.getLabel())) |
| 217 | + .findFirst(); |
| 218 | + assertThat(sourceArrowStyleWidget).isPresent(); |
| 219 | + assertThat(sourceArrowStyleWidget.get().getValue()).isEqualTo(closedArrowWith4DotsValue.get()); |
| 220 | + }); |
| 221 | + |
| 222 | + Runnable editTargetArrowStyle = () -> { |
| 223 | + var editSelectTargetArrowStyleInput = new EditSelectInput(UUID.randomUUID(), StudioIdentifiers.SAMPLE_STUDIO_EDITING_CONTEXT_ID, detailsRepresentationId, targetArrowStyleWidgetId.get(), closedArrowWith4DotsValue.get()); |
| 224 | + var result = this.editSelectMutationRunner.run(editSelectTargetArrowStyleInput); |
| 225 | + var typename = JsonPath.read(result.data(), "$.data.editSelect.__typename"); |
| 226 | + assertThat(typename).isEqualTo(SuccessPayload.class.getSimpleName()); |
| 227 | + }; |
| 228 | + |
| 229 | + Consumer<Object> formContentAfterTargetArrowStyleEdit = assertRefreshedFormThat(form -> { |
| 230 | + var firstPage = form.getPages().get(0); |
| 231 | + var firstGroup = firstPage.getGroups().get(0); |
| 232 | + |
| 233 | + var targetArrowStyleWidget = firstGroup.getWidgets().stream() |
| 234 | + .filter(Select.class::isInstance) |
| 235 | + .map(Select.class::cast) |
| 236 | + .filter(selectWidget -> Objects.equals("Target Arrow Style", selectWidget.getLabel())) |
| 237 | + .findFirst(); |
| 238 | + assertThat(targetArrowStyleWidget).isPresent(); |
| 239 | + assertThat(targetArrowStyleWidget.get().getValue()).isEqualTo(closedArrowWith4DotsValue.get()); |
| 240 | + }); |
| 241 | + |
| 242 | + StepVerifier.create(flux) |
| 243 | + .consumeNextWith(formContentBeforeEdit) |
| 244 | + .then(editSourceArrowStyle) |
| 245 | + .consumeNextWith(formContentAfterSourceArrowStyleEdit) |
| 246 | + .then(editTargetArrowStyle) |
| 247 | + .consumeNextWith(formContentAfterTargetArrowStyleEdit) |
| 248 | + .thenCancel() |
| 249 | + .verify(Duration.ofSeconds(100)); |
| 250 | + } |
152 | 251 | } |
0 commit comments