rajalakshmys-27 commented on code in PR #3556:
URL: 
https://github.com/apache/incubator-kie-tools/pull/3556#discussion_r3271722844


##########
packages/bpmn-editor/tests-e2e/flowElements/addBoundaryEvent.spec.ts:
##########
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { test, expect } from "../__fixtures__/base";
+import { NodeType, DefaultNodeName } from "../__fixtures__/nodes";
+
+test.beforeEach(async ({ editor }) => {
+  await editor.open();
+});
+
+test.describe("Add Boundary Event", () => {
+  test.describe("Basic attachment", () => {
+    test("should attach intermediate catch event to task", async ({ palette, 
jsonModel, page }) => {
+      await palette.dragNewNode({ type: NodeType.TASK, targetPosition: { x: 
300, y: 300 } });
+      await palette.dragNewNode({ type: NodeType.INTERMEDIATE_CATCH_EVENT, 
targetPosition: { x: 450, y: 300 } });
+
+      const boundaryEventNode = 
page.getByTestId(/^kie-tools--bpmn-editor--node-intermediate-catch-event-/).first();
+      await expect(boundaryEventNode).toBeAttached();
+
+      const boundaryEvent = await jsonModel.getFlowElement({ elementIndex: 1 
});
+      expect(boundaryEvent.__$$element).toBe("boundaryEvent");
+      expect(boundaryEvent["@_attachedToRef"]).toBeDefined();
+    });
+
+    test("should attach intermediate catch event to subprocess", async ({ 
palette, jsonModel, page }) => {
+      await palette.dragNewNode({ type: NodeType.SUB_PROCESS, targetPosition: 
{ x: 100, y: 300 } });
+      await palette.dragNewNode({ type: NodeType.INTERMEDIATE_CATCH_EVENT, 
targetPosition: { x: 550, y: 350 } });
+
+      const boundaryEventNode = 
page.getByTestId(/^kie-tools--bpmn-editor--node-intermediate-catch-event-/).first();
+      await expect(boundaryEventNode).toBeAttached();
+
+      const boundaryEvent = await jsonModel.getFlowElement({ elementIndex: 1 
});
+      expect(boundaryEvent.__$$element).toBe("boundaryEvent");
+      expect(boundaryEvent["@_attachedToRef"]).toBeDefined();
+    });
+
+    test("should attach multiple boundary events to same task", async ({ 
palette, jsonModel, diagram }) => {
+      await palette.dragNewNode({ type: NodeType.TASK, targetPosition: { x: 
300, y: 300 } });
+      await palette.dragNewNode({ type: NodeType.INTERMEDIATE_CATCH_EVENT, 
targetPosition: { x: 300, y: 280 } });
+      await palette.dragNewNode({ type: NodeType.INTERMEDIATE_CATCH_EVENT, 
targetPosition: { x: 450, y: 300 } });
+      await palette.dragNewNode({ type: NodeType.INTERMEDIATE_CATCH_EVENT, 
targetPosition: { x: 350, y: 350 } });
+
+      await 
expect(diagram.get()).toHaveScreenshot("attach-multiple-boundary-events-to-task.png");
+
+      const process = await jsonModel.getProcess();
+      const boundaryEvents = process.flowElement?.filter(
+        (e: { __$$element: string }) => e.__$$element === "boundaryEvent"
+      );
+      expect(boundaryEvents?.length).toBe(3);
+      boundaryEvents?.forEach((event: { __$$element: string; 
"@_attachedToRef"?: string }) => {
+        expect(event.__$$element).toBe("boundaryEvent");
+        expect(event["@_attachedToRef"]).toBeDefined();
+      });
+    });
+  });
+
+  test.describe("Detachment", () => {
+    test("should detach boundary event back to intermediate catch event", 
async ({
+      palette,
+      jsonModel,
+      diagram,
+      page,
+    }) => {
+      await palette.dragNewNode({ type: NodeType.TASK, targetPosition: { x: 
300, y: 300 } });
+      await palette.dragNewNode({ type: NodeType.INTERMEDIATE_CATCH_EVENT, 
targetPosition: { x: 450, y: 300 } });
+
+      const boundaryEventNode = 
page.getByTestId(/^kie-tools--bpmn-editor--node-intermediate-catch-event-/).first();
+      await expect(boundaryEventNode).toBeVisible();
+
+      await boundaryEventNode.dragTo(diagram.get(), { targetPosition: { x: 
500, y: 100 } });
+
+      await 
expect(diagram.get()).toHaveScreenshot("detach-boundary-event-from-task.png");
+
+      const detachedEvent = await jsonModel.getFlowElement({ elementIndex: 1 
});
+      expect(detachedEvent.__$$element).toBe("intermediateCatchEvent");
+      expect(detachedEvent["@_attachedToRef"]).toBeUndefined();
+    });
+  });
+
+  test.describe("Interrupting vs Non-interrupting", () => {
+    test("should create interrupting boundary event by default", async ({ 
palette, jsonModel, diagram }) => {
+      await palette.dragNewNode({ type: NodeType.TASK, targetPosition: { x: 
300, y: 300 } });
+      await palette.dragNewNode({ type: NodeType.INTERMEDIATE_CATCH_EVENT, 
targetPosition: { x: 450, y: 300 } });
+
+      await 
expect(diagram.get()).toHaveScreenshot("interrupting-boundary-event.png");
+
+      const boundaryEvent = await jsonModel.getFlowElement({ elementIndex: 1 
});
+      expect(boundaryEvent.__$$element).toBe("boundaryEvent");
+      expect(boundaryEvent["@_attachedToRef"]).toBeDefined();
+      expect(boundaryEvent["@_cancelActivity"]).not.toBe(false);
+    });
+
+    test("should create non-interrupting boundary event", async ({
+      palette,
+      jsonModel,
+      diagram,
+      page,
+      intermediateEventPropertiesPanel,
+    }) => {
+      await palette.dragNewNode({ type: NodeType.TASK, targetPosition: { x: 
300, y: 300 } });
+      await palette.dragNewNode({ type: NodeType.INTERMEDIATE_CATCH_EVENT, 
targetPosition: { x: 450, y: 300 } });
+
+      const boundaryEventNode = 
page.getByTestId(/^kie-tools--bpmn-editor--node-intermediate-catch-event-/).first();
+      await expect(boundaryEventNode).toBeVisible();

Review Comment:
   removed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to