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

Split move and add waypoint tests #23

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
18 changes: 11 additions & 7 deletions packages/dmn-editor/tests/e2e/__fixtures__/edges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export class Edges {
return this.page.getByRole("button", { name: `Edge from ${from} to ${to}` });
}

public async getWaypoint(args: { from: string; to: string; waypointIndex: number }) {
return (await this.get({ from: args.from, to: args.to })).locator(`[data-waypointindex="${args.waypointIndex}"]`);
}

public async getType(args: { from: string; to: string }) {
return (await this.get({ from: args.from, to: args.to })).locator("path").nth(0).getAttribute("data-edgetype");
}
Expand All @@ -46,19 +50,19 @@ export class Edges {
await (await this.get({ from: args.from, to: args.to })).dblclick();
}

public async moveNthWaypoint(args: {
public async moveWaypoint(args: {
from: string;
to: string;
nth: number;
waypointIndex: 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,
});
await (
await this.getWaypoint({ from: args.from, to: args.to, waypointIndex: args.waypointIndex })
).dragTo(this.diagram.get(), {
targetPosition: args.targetPosition,
});
}

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.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
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 @@ -36,88 +35,44 @@ test.describe("Add edge waypoint - Association", () => {
});
});

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 } });
test("should attach single Association waypoint to the DOM", async ({ edges }) => {
await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION });

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({
await expect(
await edges.getWaypoint({
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");
});
waypointIndex: 1,
})
).toBeAttached();
await expect(
await edges.getWaypoint({
from: DefaultNodeName.INPUT_DATA,
to: DefaultNodeName.TEXT_ANNOTATION,
waypointIndex: 2,
})
).not.toBeAttached();
});

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 } });
test("should attach multiple Association waypoints to the DOM", async ({ 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 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 edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION });

await edges.moveNthWaypoint({
await expect(
await edges.getWaypoint({
from: DefaultNodeName.INPUT_DATA,
to: DefaultNodeName.TEXT_ANNOTATION,
nth: 1,
targetPosition: { x: 500, y: 100 },
});
await edges.moveNthWaypoint({
waypointIndex: 1,
})
).toBeAttached();
await expect(
await edges.getWaypoint({
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");
});
waypointIndex: 2,
})
).toBeAttached();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* 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("Move edge waypoint - Association", () => {
test.beforeEach(async ({ palette, nodes }) => {
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.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("move-association-ending-waypoint.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.moveWaypoint({
from: DefaultNodeName.INPUT_DATA,
to: DefaultNodeName.TEXT_ANNOTATION,
waypointIndex: 1,
targetPosition: { x: 500, y: 300 },
});

await expect(diagram.get()).toHaveScreenshot("move-association-middle-waypoint.png");
});
});

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 expect(diagram.get()).toHaveScreenshot("move-association-starting-and-ending-waypoint.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 edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION });

await edges.moveWaypoint({
from: DefaultNodeName.INPUT_DATA,
to: DefaultNodeName.TEXT_ANNOTATION,
waypointIndex: 1,
targetPosition: { x: 500, y: 100 },
});
await edges.moveWaypoint({
from: DefaultNodeName.INPUT_DATA,
to: DefaultNodeName.TEXT_ANNOTATION,
waypointIndex: 2,
targetPosition: { x: 500, y: 500 },
});

await expect(diagram.get()).toHaveScreenshot("move-association-middle-waypoints.png");
});
});
});
Loading
Loading