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


##########
packages/bpmn-editor/tests-e2e/flowElements/addBoundaryEvent.spec.ts:
##########
@@ -0,0 +1,229 @@
+/*
+ * 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 boundaryEvent = await jsonModel.getFlowElement({ elementIndex: 1 
});
+      expect(boundaryEvent.__$$element).toBe("boundaryEvent");
+      expect(boundaryEvent["@_attachedToRef"]).toBeDefined();
+
+      const boundaryEventNode = 
page.locator(".kie-bpmn-editor--intermediate-catch-event-node").first();
+      await expect(boundaryEventNode).toBeAttached();
+    });
+
+    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 boundaryEvent = await jsonModel.getFlowElement({ elementIndex: 1 
});
+      expect(boundaryEvent.__$$element).toBe("boundaryEvent");
+      expect(boundaryEvent["@_attachedToRef"]).toBeDefined();
+
+      const boundaryEventNode = 
page.locator(".kie-bpmn-editor--intermediate-catch-event-node").first();
+      await expect(boundaryEventNode).toBeAttached();
+    });
+
+    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 } });
+
+      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();
+      });
+
+      await 
expect(diagram.get()).toHaveScreenshot("attach-multiple-boundary-events-to-task.png");
+    });
+  });
+
+  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.locator(".kie-bpmn-editor--intermediate-catch-event-node").first();
+      await expect(boundaryEventNode).toBeVisible({ timeout: 5000 });
+
+      await boundaryEventNode.dragTo(diagram.get(), { targetPosition: { x: 
500, y: 100 } });
+
+      const detachedEvent = await jsonModel.getFlowElement({ elementIndex: 1 
});
+      expect(detachedEvent.__$$element).toBe("intermediateCatchEvent");
+      expect(detachedEvent["@_attachedToRef"]).toBeUndefined();
+
+      await 
expect(diagram.get()).toHaveScreenshot("detach-boundary-event-from-task.png");
+    });
+  });
+
+  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 } });
+
+      const boundaryEvent = await jsonModel.getFlowElement({ elementIndex: 1 
});
+      expect(boundaryEvent.__$$element).toBe("boundaryEvent");
+      expect(boundaryEvent["@_attachedToRef"]).toBeDefined();
+      expect(boundaryEvent["@_cancelActivity"]).not.toBe(false);
+
+      await 
expect(diagram.get()).toHaveScreenshot("interrupting-boundary-event.png");
+    });
+
+    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.locator(".kie-bpmn-editor--intermediate-catch-event-node").first();
+      await expect(boundaryEventNode).toBeVisible({ timeout: 5000 });
+      await boundaryEventNode.click();
+
+      await intermediateEventPropertiesPanel.setCancelActivity({ 
cancelActivity: false });
+
+      await expect
+        .poll(
+          async () => {
+            return await jsonModel.getFlowElement({ elementIndex: 1 });
+          },
+          { timeout: 10000 }
+        )
+        .toMatchObject({
+          __$$element: "boundaryEvent",
+          "@_attachedToRef": expect.stringMatching(/.+/),
+          "@_cancelActivity": false,
+        });
+
+      await 
expect(diagram.get()).toHaveScreenshot("non-interrupting-boundary-event.png");
+    });
+  });
+
+  test.describe("Activity types", () => {
+    test("should attach to user task", async ({ palette, nodes, jsonModel, 
page, diagram }) => {
+      await palette.dragNewNode({ type: NodeType.TASK, targetPosition: { x: 
300, y: 300 } });
+
+      const task = page.locator(`[data-nodelabel="${DefaultNodeName.TASK}"]`);
+      await nodes.morphNode({ nodeLocator: task, targetMorphType: "User task" 
});
+
+      await palette.dragNewNode({ type: NodeType.INTERMEDIATE_CATCH_EVENT, 
targetPosition: { x: 450, y: 300 } });
+
+      const boundaryEvent = await jsonModel.getFlowElement({ elementIndex: 1 
});
+      expect(boundaryEvent.__$$element).toBe("boundaryEvent");
+      expect(boundaryEvent["@_attachedToRef"]).toBeDefined();
+
+      await 
expect(diagram.get()).toHaveScreenshot("attach-boundary-event-to-user-task.png");
+    });
+
+    test("should attach to call activity", async ({ palette, jsonModel, 
diagram }) => {
+      await palette.dragNewNode({ type: NodeType.CALL_ACTIVITY, 
targetPosition: { x: 300, y: 300 } });
+      await palette.dragNewNode({ type: NodeType.INTERMEDIATE_CATCH_EVENT, 
targetPosition: { x: 450, y: 300 } });
+
+      const boundaryEvent = await jsonModel.getFlowElement({ elementIndex: 1 
});
+      expect(boundaryEvent.__$$element).toBe("boundaryEvent");
+      expect(boundaryEvent["@_attachedToRef"]).toBeDefined();
+
+      await 
expect(diagram.get()).toHaveScreenshot("attach-boundary-event-to-call-activity.png");
+    });
+  });
+
+  test.describe("Operations", () => {
+    test("should delete boundary event", 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.locator(".kie-bpmn-editor--intermediate-catch-event-node").first();
+      await expect(boundaryEventNode).toBeVisible({ timeout: 5000 });
+      await boundaryEventNode.click();
+      await boundaryEventNode.press("Delete");
+
+      const process = await jsonModel.getProcess();
+      expect(
+        process.flowElement?.find((e: { __$$element: string }) => 
e.__$$element === "boundaryEvent")
+      ).toBeUndefined();
+      expect(process.flowElement?.find((e: { __$$element: string }) => 
e.__$$element === "task")).toBeDefined();
+
+      await expect(boundaryEventNode).not.toBeAttached();
+    });
+
+    test.skip("should delete task with boundary event", async ({ palette, 
nodes, jsonModel, diagram }) => {
+      // TODO: Enable when boundary event deletion logic is implemented

Review Comment:
   I’ve already raised this issue and I’ll take action soon.



-- 
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