Skip to content

Commit

Permalink
Introduce delete[edge]Waypoint.spec.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
jomarko committed Mar 6, 2024
1 parent e43996b commit 9a99f3c
Show file tree
Hide file tree
Showing 9 changed files with 292 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/dmn-editor/tests/e2e/__fixtures__/edges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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");
});
});
Original file line number Diff line number Diff line change
@@ -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();
});
});
Original file line number Diff line number Diff line change
@@ -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();
});
});
Original file line number Diff line number Diff line change
@@ -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();
});
});

0 comments on commit 9a99f3c

Please sign in to comment.