Skip to content

Commit

Permalink
addAssociationWaypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jomarko committed Mar 13, 2024
1 parent 98cb233 commit bd936db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 4 additions & 2 deletions packages/dmn-editor/tests/e2e/__fixtures__/edges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,17 @@ export class Edges {
await (await this.get({ from: args.from, to: args.to })).dblclick();
}

public async addWaypoint2(args: { from: string; to: string; waypointIndex?: number }) {
public async addWaypoint2(args: { from: string; to: string; afterWaypointIndex?: 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 edgeSegment = args.afterWaypointIndex
? edgeSegments[Math.min(edgeSegments.length - 1, args.afterWaypointIndex)]
: edgeSegments[0];
const from = edgeSegment.split(/ L [0-9]*,[0-9]*/)[0];
const to = edgeSegment.split(/M [0-9]*,[0-9]* /)[1];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test.beforeEach(async ({ editor }) => {
await editor.open();
});

test.describe("Add edge waypoint - Association", () => {
test.describe.only("Add edge waypoint - Association", () => {
test.beforeEach(async ({ palette, nodes }) => {
await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } });
await nodes.dragNewConnectedNode({
Expand All @@ -35,7 +35,7 @@ test.describe("Add edge waypoint - Association", () => {
});
});

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

await expect(
Expand All @@ -55,10 +55,12 @@ test.describe("Add edge waypoint - Association", () => {
});

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 edges.addWaypoint2({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION });
await edges.addWaypoint2({
from: DefaultNodeName.INPUT_DATA,
to: DefaultNodeName.TEXT_ANNOTATION,
afterWaypointIndex: 1,
});

await expect(
await edges.getWaypoint({
Expand Down

0 comments on commit bd936db

Please sign in to comment.