diff --git a/packages/dmn-editor/tests/e2e/__fixtures__/edges.ts b/packages/dmn-editor/tests/e2e/__fixtures__/edges.ts index 7bde0b20643..89df06d9129 100644 --- a/packages/dmn-editor/tests/e2e/__fixtures__/edges.ts +++ b/packages/dmn-editor/tests/e2e/__fixtures__/edges.ts @@ -59,6 +59,13 @@ export class Edges { .dragTo(this.diagram.get(), { targetPosition: args.targetPosition, }); + } + + public async deleteNthWaypoint(args: { from: string; to: string; nth: number }) { + await this.select({ from: args.from, to: args.to }); + await (await this.get({ from: args.from, to: args.to })) + .locator(`[data-waypointindex="${args.nth}"]`) + .dblclick(); } public async delete(args: { from: string; to: string; isBackspace?: boolean }) { diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/delete-association-waypoint-edge-with-corner.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/delete-association-waypoint-edge-with-corner.png new file mode 100644 index 00000000000..3f3f0c93369 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/delete-association-waypoint-edge-with-corner.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/delete-association-waypoint-straight-edge.png b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/delete-association-waypoint-straight-edge.png new file mode 100644 index 00000000000..a5aca3768f9 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/Google-Chrome/drdArtifacts/delete-association-waypoint-straight-edge.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/delete-association-waypoint-edge-with-corner.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/delete-association-waypoint-edge-with-corner.png new file mode 100644 index 00000000000..b7c22c48abf Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/delete-association-waypoint-edge-with-corner.png differ diff --git a/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/delete-association-waypoint-straight-edge.png b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/delete-association-waypoint-straight-edge.png new file mode 100644 index 00000000000..d28fbfe1d97 Binary files /dev/null and b/packages/dmn-editor/tests/e2e/__screenshots__/chromium/drdArtifacts/delete-association-waypoint-straight-edge.png differ diff --git a/packages/dmn-editor/tests/e2e/drdArtifacts/deleteAssociationWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drdArtifacts/deleteAssociationWaypoint.spec.ts new file mode 100644 index 00000000000..e870bcf6758 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drdArtifacts/deleteAssociationWaypoint.spec.ts @@ -0,0 +1,92 @@ +/* + * 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 } from "@playwright/test"; +import { test } from "../__fixtures__/base"; +import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; +import { TestAnnotations } from "@kie-tools/playwright-base/annotations"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe.only("Delete edge waypoint - Association", () => { + test.beforeEach(async ({ palette, nodes, browserName }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } }); + await nodes.dragNewConnectedNode({ + from: DefaultNodeName.INPUT_DATA, + type: NodeType.TEXT_ANNOTATION, + targetPosition: { x: 100, y: 300 }, + }); + }); + + test("should delete the single Association edge waypoint to make it straight", async ({ diagram, edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION }); + await edges.moveNthWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + nth: 1, + targetPosition: { x: 500, y: 300 }, + }); + await expect(diagram.get()).toHaveScreenshot("add-association-waypoint-and-move-it.png"); + + await edges.deleteNthWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + nth: 1, + }); + await expect(diagram.get()).toHaveScreenshot("delete-association-waypoint-straight-edge.png"); + }); + + test("should delete one of Association edge waypoints to reduce edge corners", async ({ diagram, nodes, edges }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION }); + await nodes.move({ name: DefaultNodeName.TEXT_ANNOTATION, targetPosition: { x: 200, y: 500 } }); + + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION }); + + await edges.moveNthWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + nth: 1, + targetPosition: { x: 500, y: 100 }, + }); + await edges.moveNthWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + nth: 2, + targetPosition: { x: 500, y: 500 }, + }); + + await expect(diagram.get()).toHaveScreenshot("add-multiple-association-waypoint-and-move-them.png"); + + await edges.deleteNthWaypoint({ + from: DefaultNodeName.INPUT_DATA, + to: DefaultNodeName.TEXT_ANNOTATION, + nth: 1, + }); + + await expect(diagram.get()).toHaveScreenshot("delete-association-waypoint-edge-with-corner.png"); + }); +}); diff --git a/packages/dmn-editor/tests/e2e/drgRequirements/deleteAuthorityRequirementWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drgRequirements/deleteAuthorityRequirementWaypoint.spec.ts new file mode 100644 index 00000000000..6bfdfdf78f4 --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drgRequirements/deleteAuthorityRequirementWaypoint.spec.ts @@ -0,0 +1,65 @@ +/* + * 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 } from "@playwright/test"; +import { test } from "../__fixtures__/base"; +import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; +import { TestAnnotations } from "@kie-tools/playwright-base/annotations"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe("Delete edge waypoint - Authority Requirement", () => { + test.beforeEach(async ({ palette, nodes, browserName }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } }); + await nodes.dragNewConnectedNode({ + from: DefaultNodeName.INPUT_DATA, + type: NodeType.KNOWLEDGE_SOURCE, + targetPosition: { x: 100, y: 300 }, + }); + }); + + test("should delete first waypoint of the Authoriry Requirement and second waypoint should stay", async ({ + diagram, + nodes, + edges, + }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE }); + const boundingBox = await nodes.get({ name: DefaultNodeName.KNOWLEDGE_SOURCE }).boundingBox(); + await nodes + .get({ name: DefaultNodeName.KNOWLEDGE_SOURCE }) + .dragTo(diagram.get(), { targetPosition: { x: 100 + (boundingBox?.width ?? 0) / 2, y: 500 } }); + + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE }); + await nodes + .get({ name: DefaultNodeName.KNOWLEDGE_SOURCE }) + .dragTo(diagram.get(), { targetPosition: { x: 500, y: 500 } }); + await nodes.get({ name: DefaultNodeName.INPUT_DATA }).dragTo(diagram.get(), { targetPosition: { x: 500, y: 100 } }); + + await edges.deleteNthWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE, nth: 1 }); + await expect(diagram.get()).toHaveScreenshot(); + }); +}); diff --git a/packages/dmn-editor/tests/e2e/drgRequirements/deleteInformationRequirementWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drgRequirements/deleteInformationRequirementWaypoint.spec.ts new file mode 100644 index 00000000000..74872fdd76f --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drgRequirements/deleteInformationRequirementWaypoint.spec.ts @@ -0,0 +1,64 @@ +/* + * 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 } from "@playwright/test"; +import { test } from "../__fixtures__/base"; +import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; +import { TestAnnotations } from "@kie-tools/playwright-base/annotations"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe("Delete edge waypoint - Information Requirement", () => { + test.beforeEach(async ({ palette, nodes, browserName }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } }); + await nodes.dragNewConnectedNode({ + from: DefaultNodeName.INPUT_DATA, + type: NodeType.DECISION, + targetPosition: { x: 100, y: 300 }, + }); + }); + + test("should delete first waypoint of the Information Requirement edge and second waypoint should stay", async ({ + diagram, + nodes, + edges, + }) => { + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION }); + const boundingBox = await nodes.get({ name: DefaultNodeName.DECISION }).boundingBox(); + await nodes + .get({ name: DefaultNodeName.DECISION }) + .dragTo(diagram.get(), { targetPosition: { x: 100 + (boundingBox?.width ?? 0) / 2, y: 500 } }); + + await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION }); + await nodes.get({ name: DefaultNodeName.DECISION }).dragTo(diagram.get(), { targetPosition: { x: 500, y: 500 } }); + await nodes.get({ name: DefaultNodeName.INPUT_DATA }).dragTo(diagram.get(), { targetPosition: { x: 500, y: 100 } }); + + await edges.deleteNthWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.DECISION, nth: 1 }); + + await expect(diagram.get()).toHaveScreenshot(); + }); +}); diff --git a/packages/dmn-editor/tests/e2e/drgRequirements/deleteKnowledgeRequirementWaypoint.spec.ts b/packages/dmn-editor/tests/e2e/drgRequirements/deleteKnowledgeRequirementWaypoint.spec.ts new file mode 100644 index 00000000000..bf049c2a23f --- /dev/null +++ b/packages/dmn-editor/tests/e2e/drgRequirements/deleteKnowledgeRequirementWaypoint.spec.ts @@ -0,0 +1,64 @@ +/* + * 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 } from "@playwright/test"; +import { test } from "../__fixtures__/base"; +import { DefaultNodeName, NodeType } from "../__fixtures__/nodes"; +import { TestAnnotations } from "@kie-tools/playwright-base/annotations"; + +test.beforeEach(async ({ editor }) => { + await editor.open(); +}); + +test.describe("Delete edge waypoint - Knowledge Requirement", () => { + test.beforeEach(async ({ palette, nodes, browserName }) => { + test.skip(browserName === "webkit", "https://github.com/apache/incubator-kie-issues/issues/991"); + test.info().annotations.push({ + type: TestAnnotations.REGRESSION, + description: "https://github.com/apache/incubator-kie-issues/issues/991", + }); + + await palette.dragNewNode({ type: NodeType.BKM, targetPosition: { x: 100, y: 100 } }); + await nodes.dragNewConnectedNode({ + from: DefaultNodeName.BKM, + type: NodeType.DECISION, + targetPosition: { x: 100, y: 300 }, + }); + }); + + test("should delete first waypoint of the Knowledge Requirement edge and second waypoint should stay", async ({ + diagram, + nodes, + edges, + }) => { + await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION }); + const boundingBox = await nodes.get({ name: DefaultNodeName.DECISION }).boundingBox(); + await nodes + .get({ name: DefaultNodeName.DECISION }) + .dragTo(diagram.get(), { targetPosition: { x: 100 + (boundingBox?.width ?? 0) / 2, y: 500 } }); + + await edges.addWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION }); + await nodes.get({ name: DefaultNodeName.DECISION }).dragTo(diagram.get(), { targetPosition: { x: 500, y: 500 } }); + await nodes.get({ name: DefaultNodeName.BKM }).dragTo(diagram.get(), { targetPosition: { x: 500, y: 100 } }); + + await edges.deleteNthWaypoint({ from: DefaultNodeName.BKM, to: DefaultNodeName.DECISION, nth: 1 }); + + await expect(diagram.get()).toHaveScreenshot(); + }); +});