ljmotta commented on code in PR #3556: URL: https://github.com/apache/incubator-kie-tools/pull/3556#discussion_r3270871659
########## 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: Same. Why do we have an assert for the "first" boundary event node? ########## 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(); Review Comment: What is the reason behind this assertion? ########## 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(); + await boundaryEventNode.click(); + + await intermediateEventPropertiesPanel.setCancelActivity({ cancelActivity: false }); + + await expect + .poll(async () => { + return await jsonModel.getFlowElement({ elementIndex: 1 }); + }) + .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, diagram }) => { + await palette.dragNewNode({ type: NodeType.TASK, targetPosition: { x: 300, y: 300 } }); + + const task = nodes.get({ name: DefaultNodeName.TASK }); + await nodes.morphNode({ nodeLocator: task, targetMorphType: "User task" }); + + await palette.dragNewNode({ type: NodeType.INTERMEDIATE_CATCH_EVENT, targetPosition: { x: 450, y: 300 } }); + + await expect(diagram.get()).toHaveScreenshot("attach-boundary-event-to-user-task.png"); + + const boundaryEvent = await jsonModel.getFlowElement({ elementIndex: 1 }); + expect(boundaryEvent.__$$element).toBe("boundaryEvent"); + expect(boundaryEvent["@_attachedToRef"]).toBeDefined(); + }); + + 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 } }); + + await expect(diagram.get()).toHaveScreenshot("attach-boundary-event-to-call-activity.png"); + + const boundaryEvent = await jsonModel.getFlowElement({ elementIndex: 1 }); + expect(boundaryEvent.__$$element).toBe("boundaryEvent"); + expect(boundaryEvent["@_attachedToRef"]).toBeDefined(); + }); + }); + + 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.getByTestId(/^kie-tools--bpmn-editor--node-intermediate-catch-event-/).first(); + await expect(boundaryEventNode).toBeVisible(); + await boundaryEventNode.click(); + await boundaryEventNode.press("Delete"); + + await expect(boundaryEventNode).not.toBeAttached(); Review Comment: A few things to make a more readble test: If the intetation is to create an assertion to check if the node was indeed created, put it together with the block where the node was created. Use the fixtures to get and manipulate the node. Use the same type of assertion. If you want to use `toBeVisible()`, use its counterpart `not.toBeVisible()`. For this case, I believe `toBeAttached` would make more sense, as it does not take into account if the element is visible or not. ```suggestion 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(nodes.get(...)).toBeAttached(); await nodes.delete(...) await expect(nodes.get(...)).not.toBeAttached(); ``` ########## 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: please, add a test annotation tag with the issue link so we don't lose track of this test ########## 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(); Review Comment: Why are you not using the nodes fixture to get the node? ########## packages/bpmn-editor/tests-e2e/__fixtures__/edges.ts: ########## @@ -0,0 +1,97 @@ +/* + * 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 { expect, Locator, Page } from "@playwright/test"; +import { Diagram } from "./diagram"; +import { Nodes } from "./nodes"; + +export enum EdgeType { + SEQUENCE_FLOW = "edge_sequenceFlow", + ASSOCIATION = "edge_association", +} + +export class Edges { + constructor( + public page: Page, + public nodes: Nodes, + public diagram: Diagram + ) {} + + public async get(args: { from: string; to: string }): Promise<Locator> { Review Comment: Is it not possible to use the same approach we have on DMN Editor? ########## packages/bpmn-editor/tests-e2e/flowElements/addCallActivity.spec.ts: ########## @@ -0,0 +1,436 @@ +/* + * 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 { TestAnnotations } from "@kie-tools/playwright-base/annotations"; +import { test, expect } from "../__fixtures__/base"; +import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe("Add node - Call Activity", () => { + test.describe("Add from palette", () => { + test("should add Call Activity node from palette", async ({ palette, nodes, jsonModel }) => { + await palette.dragNewNode({ type: NodeType.CALL_ACTIVITY, targetPosition: { x: 100, y: 100 } }); + + await expect(nodes.get({ name: DefaultNodeName.CALL_ACTIVITY })).toBeAttached(); + + const callActivity = await jsonModel.getFlowElement({ elementIndex: 0 }); + expect(callActivity.__$$element).toBe("callActivity"); + expect(callActivity["@_name"]).toBe(DefaultNodeName.CALL_ACTIVITY); + }); + + test("should add two Call Activity nodes from palette in a row", async ({ palette, nodes, diagram }) => { + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + }); + + await palette.dragNewNode({ + type: NodeType.CALL_ACTIVITY, + targetPosition: { x: 100, y: 100 }, + thenRenameTo: "First Call Activity", + }); + + await palette.dragNewNode({ + type: NodeType.CALL_ACTIVITY, + targetPosition: { x: 300, y: 300 }, + thenRenameTo: "Second Call Activity", + }); + + await diagram.resetFocus(); + + await expect(nodes.get({ name: "First Call Activity" })).toBeAttached(); + await expect(nodes.get({ name: "Second Call Activity" })).toBeAttached(); + }); + }); + + test.describe("Add connected Call Activity node", () => { + test("should add connected Task node from Call Activity", async ({ diagram, palette, page, nodes }) => { + await palette.dragNewNode({ + type: NodeType.CALL_ACTIVITY, + targetPosition: { x: 100, y: 100 }, + }); + + const callActivity = nodes.get({ name: "New Call Activity" }); + await expect(callActivity).toBeAttached(); + + const box = await callActivity.boundingBox(); + expect(box).not.toBeNull(); + + await page.mouse.move(box!.x + box!.width - 10, box!.y + box!.height / 2); Review Comment: Shouldn't this be on a fixture? -- 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]
