Skip to content

Commit

Permalink
introduce addWaypoint2 fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
jomarko committed Mar 13, 2024
1 parent 3e8f074 commit 98cb233
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
7 changes: 7 additions & 0 deletions packages/dmn-editor/tests/e2e/__fixtures__/diagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ export class Diagram {
return this.page.getByTestId("kie-dmn-editor--diagram-container");
}

public async dblclick(position: { x: number; y: number }) {
const offsetX = 100;
const offsetY = 100;

return this.get().dblclick({ position: { x: position.x + offsetX, y: position.y + offsetY } });
}

public async resetFocus() {
return this.get().click({ position: { x: 0, y: 0 } });
}
Expand Down
21 changes: 21 additions & 0 deletions packages/dmn-editor/tests/e2e/__fixtures__/edges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,27 @@ export class Edges {
await (await this.get({ from: args.from, to: args.to })).dblclick();
}

public async addWaypoint2(args: { from: string; to: string; waypointIndex?: number }) {
const dAttribute = await (
await (await this.get({ from: args.from, to: args.to })).locator("path").first()
).getAttribute("d");

const edgeSegments = dAttribute?.match(/M [0-9]*,[0-9]* L [0-9]*,[0-9]*/);

if (edgeSegments) {
const edgeSegment = args.waypointIndex ? edgeSegments[Math.max(0, args.waypointIndex - 1)] : edgeSegments[0];
const from = edgeSegment.split(/ L [0-9]*,[0-9]*/)[0];
const to = edgeSegment.split(/M [0-9]*,[0-9]* /)[1];

const fromPoint = { x: parseInt(from.slice(2).split(",")[0]), y: parseInt(from.slice(2).split(",")[1]) };
const toPoint = { x: parseInt(to.slice(2).split(",")[0]), y: parseInt(to.slice(2).split(",")[1]) };

const targetPoint = { x: (fromPoint.x + toPoint.x) / 2, y: (fromPoint.y + toPoint.y) / 2 };

await this.diagram.dblclick(targetPoint);
}
}

public async moveWaypoint(args: {
from: string;
to: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ test.describe("Add edge waypoint - Association", () => {
});
});

test("should attach single Association waypoint to the DOM", async ({ edges }) => {
await edges.addWaypoint({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION });
test.only("should attach single Association waypoint to the DOM", async ({ edges }) => {
await edges.addWaypoint2({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION });

await expect(
await edges.getWaypoint({
Expand Down

0 comments on commit 98cb233

Please sign in to comment.