Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update add[Edge]Waypoint.spec.ts #22

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/dmn-editor/src/diagram/edges/Waypoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export function Waypoint({

return (
<circle
data-waypointindex={index}
ref={circleRef}
className={"kie-dmn-editor--diagram-edge-waypoint"}
cx={point["@_x"]}
Expand Down
4 changes: 2 additions & 2 deletions packages/dmn-editor/tests/e2e/__fixtures__/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export const test = base.extend<DmnEditorFixtures>({
nodes: async ({ page, diagram, browserName }, use) => {
await use(new Nodes(page, diagram, browserName));
},
edges: async ({ page, nodes }, use) => {
await use(new Edges(page, nodes));
edges: async ({ page, nodes, diagram }, use) => {
await use(new Edges(page, nodes, diagram));
},
palette: async ({ page, diagram, nodes }, use) => {
await use(new Palette(page, diagram, nodes));
Expand Down
21 changes: 19 additions & 2 deletions packages/dmn-editor/tests/e2e/__fixtures__/edges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { Page } from "@playwright/test";
import { Nodes } from "./nodes";
import { Diagram } from "./diagram";

export enum EdgeType {
ASSOCIATION = "association",
Expand All @@ -28,7 +29,7 @@ export enum EdgeType {
}

export class Edges {
constructor(public page: Page, public nodes: Nodes) {}
constructor(public page: Page, public nodes: Nodes, public diagram: Diagram) {}

public async get(args: { from: string; to: string }) {
const from = await this.nodes.getId({ name: args.from });
Expand All @@ -45,6 +46,21 @@ export class Edges {
await (await this.get({ from: args.from, to: args.to })).dblclick();
}

public async moveNthWaypoint(args: {
from: string;
to: string;
nth: number;
targetPosition: { x: number; y: 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}"]`)
.dragTo(this.diagram.get(), {
targetPosition: args.targetPosition,
});
}

public async delete(args: { from: string; to: string; isBackspace?: boolean }) {
await this.select({ from: args.from, to: args.to });
if (args.isBackspace) {
Expand All @@ -55,6 +71,7 @@ export class Edges {
}

public async select(args: { from: string; to: string }) {
await (await this.get({ from: args.from, to: args.to })).click();
// because of the waypoints on the edge, we can not click into the edge bounding box middle
await (await this.get({ from: args.from, to: args.to })).locator("circle").nth(1).click();
}
}
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.
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.
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.
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
Expand Up @@ -20,6 +20,7 @@
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();
Expand All @@ -35,29 +36,88 @@ test.describe("Add edge waypoint - Association", () => {
});
});

test("should add single waypoint to Association edge and should not move when the ending node is moved", async ({
diagram,
nodes,
edges,
}) => {
await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION });
await nodes.move({ name: DefaultNodeName.TEXT_ANNOTATION, targetPosition: { x: 500, y: 300 } });
test.describe("Add Single Waypoint", () => {
test("Association edge waypoint should not move when the ending node is moved", async ({
diagram,
edges,
nodes,
}) => {
await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION });
await nodes.move({ name: DefaultNodeName.TEXT_ANNOTATION, targetPosition: { x: 500, y: 300 } });

await expect(diagram.get()).toHaveScreenshot("add-association-waypoint-and-not-move-it.png");
await expect(diagram.get()).toHaveScreenshot("add-association-waypoint-and-not-move-it.png");
});

test("Association edge ending nodes should not move when the waypoint is moved", async ({
diagram,
edges,
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 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");
});
});

test("should add multiple waypoints to Association edge and should not move when the ending nodes are moved", 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 } });
test.describe("Add Multiple Waypoints", () => {
test("Association edge waypoints should not move when the ending nodes are moved", 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 nodes.move({ name: DefaultNodeName.TEXT_ANNOTATION, targetPosition: { x: 500, y: 500 } });
await nodes.move({ name: DefaultNodeName.INPUT_DATA, targetPosition: { x: 500, y: 100 } });

await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION });
await nodes.move({ name: DefaultNodeName.TEXT_ANNOTATION, targetPosition: { x: 500, y: 500 } });
await nodes.move({ name: DefaultNodeName.INPUT_DATA, targetPosition: { x: 500, y: 100 } });
await expect(diagram.get()).toHaveScreenshot("add-multiple-association-waypoint-and-not-move-them.png");
});

test("Association edge ending nodes should not move when the waypoints are moved", async ({
diagram,
nodes,
edges,
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 edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION });
await nodes.move({ name: DefaultNodeName.TEXT_ANNOTATION, targetPosition: { x: 200, y: 500 } });

await expect(diagram.get()).toHaveScreenshot("add-multiple-association-waypoint-and-not-move-them.png");
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");
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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();
Expand All @@ -35,29 +36,90 @@ test.describe("Add edge waypoint - Authority Requirement", () => {
});
});

test("should add single waypoint to Authority Requirement and should not move when the ending node is moved", async ({
diagram,
nodes,
edges,
}) => {
await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE });
await nodes.move({ name: DefaultNodeName.KNOWLEDGE_SOURCE, targetPosition: { x: 300, y: 300 } });
test.describe("Add Single Waypoint", () => {
test("Authority Requirement waypoint should not move when the ending node is moved", async ({
diagram,
nodes,
edges,
}) => {
await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE });
await nodes.move({ name: DefaultNodeName.KNOWLEDGE_SOURCE, targetPosition: { x: 300, y: 300 } });

await expect(diagram.get()).toHaveScreenshot("add-authority-requirement-waypoint-and-not-move-it.png");
await expect(diagram.get()).toHaveScreenshot("add-authority-requirement-waypoint-and-not-move-it.png");
});

test("Authority Requirement ending nodes should not move when the waypoint is moved", async ({
diagram,
edges,
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 edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE });
await edges.moveNthWaypoint({
from: DefaultNodeName.INPUT_DATA,
to: DefaultNodeName.KNOWLEDGE_SOURCE,
nth: 1,
targetPosition: { x: 300, y: 300 },
});

await expect(diagram.get()).toHaveScreenshot("add-authority-requirement-waypoint-and-move-it.png");
});
});

test("should add multiple waypoints to Authority Requirement and should not move when the ending nodes are moved", async ({
diagram,
nodes,
edges,
}) => {
await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE });
await nodes.move({ name: DefaultNodeName.KNOWLEDGE_SOURCE, targetPosition: { x: 200, y: 500 } });
test.describe("Add Multiple Waypoints", () => {
test("Authority Requirement waypoints should not move when the ending nodes are moved", async ({
diagram,
nodes,
edges,
}) => {
await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE });
await nodes.move({ name: DefaultNodeName.KNOWLEDGE_SOURCE, targetPosition: { x: 200, y: 500 } });

await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE });
await nodes.move({ name: DefaultNodeName.KNOWLEDGE_SOURCE, targetPosition: { x: 500, y: 500 } });
await nodes.move({ name: DefaultNodeName.INPUT_DATA, targetPosition: { x: 500, y: 100 } });

await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE });
await nodes.move({ name: DefaultNodeName.KNOWLEDGE_SOURCE, targetPosition: { x: 500, y: 500 } });
await nodes.move({ name: DefaultNodeName.INPUT_DATA, targetPosition: { x: 500, y: 100 } });
await expect(diagram.get()).toHaveScreenshot(
"add-multiple-authority-requirement-waypoints-and-not-move-them.png"
);
});

test("Authority Requirement ending nodes should not move when the waypoints are moved", async ({
diagram,
nodes,
edges,
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 edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE });
await nodes.move({ name: DefaultNodeName.KNOWLEDGE_SOURCE, targetPosition: { x: 200, y: 500 } });

await expect(diagram.get()).toHaveScreenshot("add-multiple-authority-requirement-waypoints-and-not-move-them.png");
await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.KNOWLEDGE_SOURCE });

await edges.moveNthWaypoint({
from: DefaultNodeName.INPUT_DATA,
to: DefaultNodeName.KNOWLEDGE_SOURCE,
nth: 1,
targetPosition: { x: 500, y: 100 },
});
await edges.moveNthWaypoint({
from: DefaultNodeName.INPUT_DATA,
to: DefaultNodeName.KNOWLEDGE_SOURCE,
nth: 2,
targetPosition: { x: 500, y: 500 },
});

await expect(diagram.get()).toHaveScreenshot("add-multiple-authority-requirement-waypoints-and-move-them.png");
});
});
});
Loading
Loading