From 5a40d0f53eeb32e6498e6062a15222eb8bc5fc19 Mon Sep 17 00:00:00 2001 From: Jozef Marko Date: Mon, 8 Apr 2024 11:58:39 +0200 Subject: [PATCH] add more resize tests - snapping --- .../src/overlaysPanel/OverlaysPanel.tsx | 2 + .../tests/e2e/__fixtures__/overlays.ts | 7 + .../e2e/drdArtifacts/resizeGroup.spec.ts | 129 ++++++++--- .../drdArtifacts/resizeTextAnnotation.spec.ts | 213 ++++++++++++++---- .../tests/e2e/drgElements/resizeBkm.spec.ts | 129 ++++++++--- .../e2e/drgElements/resizeDecision.spec.ts | 127 ++++++++--- .../drgElements/resizeDecisionService.spec.ts | 213 ++++++++++++++---- .../e2e/drgElements/resizeInputData.spec.ts | 129 ++++++++--- .../drgElements/resizeKnowledgeSource.spec.ts | 143 +++++++++--- 9 files changed, 868 insertions(+), 224 deletions(-) diff --git a/packages/dmn-editor/src/overlaysPanel/OverlaysPanel.tsx b/packages/dmn-editor/src/overlaysPanel/OverlaysPanel.tsx index f964ee90256..5bb3e0a31b0 100644 --- a/packages/dmn-editor/src/overlaysPanel/OverlaysPanel.tsx +++ b/packages/dmn-editor/src/overlaysPanel/OverlaysPanel.tsx @@ -50,6 +50,7 @@ export function OverlaysPanel() { { }); test.describe("Resize node - Group", () => { - test.beforeEach(async ({ overlays, palette }) => { - await overlays.turnOffSnapping(); - await palette.dragNewNode({ type: NodeType.GROUP, targetPosition: { x: 100, y: 100 } }); - }); + test.describe("Resize with snapping turned off", () => { + test.beforeEach(async ({ overlays, palette }) => { + await overlays.turnOffSnapping(); + await palette.dragNewNode({ type: NodeType.GROUP, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Group node size", async ({ nodes, groupPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: 50, yOffset: 50 }); + + await groupPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP }); + const { width, height } = await groupPropertiesPanel.getShape(); + expect(height).toEqual("370"); + expect(width).toEqual("370"); + }); + + test("should decrease Group node size", async ({ nodes, groupPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: 100, yOffset: 100 }); + await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: -20, yOffset: -20 }); - test("should increase Group node size", async ({ nodes, groupPropertiesPanel }) => { - await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: 50, yOffset: 50 }); + await groupPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP }); + const { width, height } = await groupPropertiesPanel.getShape(); + expect(height).toEqual("400"); + expect(width).toEqual("400"); + }); - await groupPropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP }); - const { width, height } = await groupPropertiesPanel.getShape(); - expect(height).toEqual("370"); - expect(width).toEqual("370"); + test("should not decrease below minimal Group node size", async ({ nodes, groupPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: -50, yOffset: -50 }); + + await groupPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP }); + const { width, height } = await groupPropertiesPanel.getShape(); + expect(height).toEqual("270"); + expect(width).toEqual("280"); + }); }); - test("should decrease Group node size", async ({ nodes, groupPropertiesPanel }) => { - await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: 100, yOffset: 100 }); - await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: -20, yOffset: -20 }); + test.describe("Resize with snapping turned on", () => { + test.beforeEach(async ({ palette }) => { + await palette.dragNewNode({ type: NodeType.GROUP, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Group node size", async ({ nodes, groupPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: 50, yOffset: 50 }); + + await groupPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP }); + const { width, height } = await groupPropertiesPanel.getShape(); + expect(height).toEqual("360"); + expect(width).toEqual("360"); + }); + + test("should decrease Group node size", async ({ nodes, groupPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: 100, yOffset: 100 }); + await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: -20, yOffset: -20 }); - await groupPropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP }); - const { width, height } = await groupPropertiesPanel.getShape(); - expect(height).toEqual("400"); - expect(width).toEqual("400"); + await groupPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP }); + const { width, height } = await groupPropertiesPanel.getShape(); + expect(height).toEqual("400"); + expect(width).toEqual("400"); + }); + + test("should not decrease below minimal Group node size", async ({ nodes, groupPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: -50, yOffset: -50 }); + + await groupPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP }); + const { width, height } = await groupPropertiesPanel.getShape(); + expect(height).toEqual("260"); + expect(width).toEqual("280"); + }); }); - test("should not decrease below minimal Group node size", async ({ nodes, groupPropertiesPanel }) => { - await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: -50, yOffset: -50 }); + test.describe("Resize with non default snapping", () => { + test.beforeEach(async ({ overlays, palette }) => { + await overlays.setSnapping({ horizontal: "50", vertical: "50" }); + await palette.dragNewNode({ type: NodeType.GROUP, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Group node size", async ({ nodes, groupPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: 50, yOffset: 50 }); + + await groupPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP }); + const { width, height } = await groupPropertiesPanel.getShape(); + expect(height).toEqual("400"); + expect(width).toEqual("400"); + }); + + test("should decrease Group node size", async ({ nodes, groupPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: 100, yOffset: 100 }); + await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: -20, yOffset: -20 }); + + await groupPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP }); + const { width, height } = await groupPropertiesPanel.getShape(); + expect(height).toEqual("400"); + expect(width).toEqual("400"); + }); + + test("should not decrease below minimal Group node size", async ({ nodes, groupPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.GROUP, position: NodePosition.TOP, xOffset: -50, yOffset: -50 }); - await groupPropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP }); - const { width, height } = await groupPropertiesPanel.getShape(); - expect(height).toEqual("270"); - expect(width).toEqual("280"); + await groupPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.GROUP, position: NodePosition.TOP }); + const { width, height } = await groupPropertiesPanel.getShape(); + expect(height).toEqual("300"); + expect(width).toEqual("300"); + }); }); }); diff --git a/packages/dmn-editor/tests/e2e/drdArtifacts/resizeTextAnnotation.spec.ts b/packages/dmn-editor/tests/e2e/drdArtifacts/resizeTextAnnotation.spec.ts index 297a6b6127b..e1f5bdb9a8e 100644 --- a/packages/dmn-editor/tests/e2e/drdArtifacts/resizeTextAnnotation.spec.ts +++ b/packages/dmn-editor/tests/e2e/drdArtifacts/resizeTextAnnotation.spec.ts @@ -25,62 +25,185 @@ test.beforeEach(async ({ editor }) => { }); test.describe("Resize node - Text Annotation", () => { - test.beforeEach(async ({ overlays, palette }) => { - await overlays.turnOffSnapping(); - await palette.dragNewNode({ type: NodeType.TEXT_ANNOTATION, targetPosition: { x: 100, y: 100 } }); - }); + test.describe("Resize with snapping turned off", () => { + test.beforeEach(async ({ overlays, palette }) => { + await overlays.turnOffSnapping(); + await palette.dragNewNode({ type: NodeType.TEXT_ANNOTATION, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Text Annotation node size", async ({ nodes, textAnnotationPropertiesPanel }) => { + await nodes.resize({ + nodeName: DefaultNodeName.TEXT_ANNOTATION, + position: NodePosition.TOP, + xOffset: 50, + yOffset: 50, + }); + + await textAnnotationPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION }); + const { width, height } = await textAnnotationPropertiesPanel.getShape(); + expect(height).toEqual("250"); + expect(width).toEqual("250"); + }); + + test("should decrease Text Annotation node size", async ({ nodes, textAnnotationPropertiesPanel }) => { + await nodes.resize({ + nodeName: DefaultNodeName.TEXT_ANNOTATION, + position: NodePosition.TOP, + xOffset: 100, + yOffset: 100, + }); + await nodes.resize({ + nodeName: DefaultNodeName.TEXT_ANNOTATION, + position: NodePosition.TOP, + xOffset: -20, + yOffset: -20, + }); - test("should increase Text Annotation node size", async ({ nodes, textAnnotationPropertiesPanel }) => { - await nodes.resize({ - nodeName: DefaultNodeName.TEXT_ANNOTATION, - position: NodePosition.TOP, - xOffset: 50, - yOffset: 50, + await textAnnotationPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION }); + const { width, height } = await textAnnotationPropertiesPanel.getShape(); + expect(height).toEqual("280"); + expect(width).toEqual("280"); }); - await textAnnotationPropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION }); - const { width, height } = await textAnnotationPropertiesPanel.getShape(); - expect(height).toEqual("250"); - expect(width).toEqual("250"); + test("should not decrease below minimal Text Annotation node size", async ({ + nodes, + textAnnotationPropertiesPanel, + }) => { + await nodes.resize({ + nodeName: DefaultNodeName.TEXT_ANNOTATION, + position: NodePosition.TOP, + xOffset: -50, + yOffset: -50, + }); + + await textAnnotationPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION }); + const { width, height } = await textAnnotationPropertiesPanel.getShape(); + expect(height).toEqual("150"); + expect(width).toEqual("200"); + }); }); - test("should decrease Text Annotation node size", async ({ nodes, textAnnotationPropertiesPanel }) => { - await nodes.resize({ - nodeName: DefaultNodeName.TEXT_ANNOTATION, - position: NodePosition.TOP, - xOffset: 100, - yOffset: 100, + test.describe("Resize with snapping turned on", () => { + test.beforeEach(async ({ palette }) => { + await palette.dragNewNode({ type: NodeType.TEXT_ANNOTATION, targetPosition: { x: 100, y: 100 } }); }); - await nodes.resize({ - nodeName: DefaultNodeName.TEXT_ANNOTATION, - position: NodePosition.TOP, - xOffset: -20, - yOffset: -20, + + test("should increase Text Annotation node size", async ({ nodes, textAnnotationPropertiesPanel }) => { + await nodes.resize({ + nodeName: DefaultNodeName.TEXT_ANNOTATION, + position: NodePosition.TOP, + xOffset: 50, + yOffset: 50, + }); + + await textAnnotationPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION }); + const { width, height } = await textAnnotationPropertiesPanel.getShape(); + expect(height).toEqual("240"); + expect(width).toEqual("240"); }); - await textAnnotationPropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION }); - const { width, height } = await textAnnotationPropertiesPanel.getShape(); - expect(height).toEqual("280"); - expect(width).toEqual("280"); + test("should decrease Text Annotation node size", async ({ nodes, textAnnotationPropertiesPanel }) => { + await nodes.resize({ + nodeName: DefaultNodeName.TEXT_ANNOTATION, + position: NodePosition.TOP, + xOffset: 100, + yOffset: 100, + }); + await nodes.resize({ + nodeName: DefaultNodeName.TEXT_ANNOTATION, + position: NodePosition.TOP, + xOffset: -20, + yOffset: -20, + }); + + await textAnnotationPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION }); + const { width, height } = await textAnnotationPropertiesPanel.getShape(); + expect(height).toEqual("280"); + expect(width).toEqual("280"); + }); + + test("should not decrease below minimal Text Annotation node size", async ({ + nodes, + textAnnotationPropertiesPanel, + }) => { + await nodes.resize({ + nodeName: DefaultNodeName.TEXT_ANNOTATION, + position: NodePosition.TOP, + xOffset: -50, + yOffset: -50, + }); + + await textAnnotationPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION }); + const { width, height } = await textAnnotationPropertiesPanel.getShape(); + expect(height).toEqual("140"); + expect(width).toEqual("200"); + }); }); - test("should not decrease below minimal Text Annotation node size", async ({ - nodes, - textAnnotationPropertiesPanel, - }) => { - await nodes.resize({ - nodeName: DefaultNodeName.TEXT_ANNOTATION, - position: NodePosition.TOP, - xOffset: -50, - yOffset: -50, + test.describe("Resize with non default snapping", () => { + test.beforeEach(async ({ overlays, palette }) => { + await overlays.setSnapping({ horizontal: "50", vertical: "50" }); + await palette.dragNewNode({ type: NodeType.TEXT_ANNOTATION, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Text Annotation node size", async ({ nodes, textAnnotationPropertiesPanel }) => { + await nodes.resize({ + nodeName: DefaultNodeName.TEXT_ANNOTATION, + position: NodePosition.TOP, + xOffset: 50, + yOffset: 50, + }); + + await textAnnotationPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION }); + const { width, height } = await textAnnotationPropertiesPanel.getShape(); + expect(height).toEqual("250"); + expect(width).toEqual("250"); }); - await textAnnotationPropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION }); - const { width, height } = await textAnnotationPropertiesPanel.getShape(); - expect(height).toEqual("150"); - expect(width).toEqual("200"); + test("should decrease Text Annotation node size", async ({ nodes, textAnnotationPropertiesPanel }) => { + await nodes.resize({ + nodeName: DefaultNodeName.TEXT_ANNOTATION, + position: NodePosition.TOP, + xOffset: 100, + yOffset: 100, + }); + await nodes.resize({ + nodeName: DefaultNodeName.TEXT_ANNOTATION, + position: NodePosition.TOP, + xOffset: -20, + yOffset: -20, + }); + + await textAnnotationPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION }); + const { width, height } = await textAnnotationPropertiesPanel.getShape(); + expect(height).toEqual("250"); + expect(width).toEqual("250"); + }); + + test("should not decrease below minimal Text Annotation node size", async ({ + nodes, + textAnnotationPropertiesPanel, + }) => { + await nodes.resize({ + nodeName: DefaultNodeName.TEXT_ANNOTATION, + position: NodePosition.TOP, + xOffset: -50, + yOffset: -50, + }); + + await textAnnotationPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.TEXT_ANNOTATION }); + const { width, height } = await textAnnotationPropertiesPanel.getShape(); + expect(height).toEqual("150"); + expect(width).toEqual("200"); + }); }); }); diff --git a/packages/dmn-editor/tests/e2e/drgElements/resizeBkm.spec.ts b/packages/dmn-editor/tests/e2e/drgElements/resizeBkm.spec.ts index 0aebca2422c..e2eea469021 100644 --- a/packages/dmn-editor/tests/e2e/drgElements/resizeBkm.spec.ts +++ b/packages/dmn-editor/tests/e2e/drgElements/resizeBkm.spec.ts @@ -25,39 +25,116 @@ test.beforeEach(async ({ editor }) => { }); test.describe("Resize node - BKM", () => { - test.beforeEach(async ({ overlays, palette }) => { - await overlays.turnOffSnapping(); - await palette.dragNewNode({ type: NodeType.BKM, targetPosition: { x: 100, y: 100 } }); - }); + test.describe("Resize with snapping turned off", () => { + test.beforeEach(async ({ overlays, palette }) => { + await overlays.turnOffSnapping(); + await palette.dragNewNode({ type: NodeType.BKM, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase BKM node size", async ({ nodes, bkmPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: 50, yOffset: 50 }); + + await bkmPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.BKM }); + const { width, height } = await bkmPropertiesPanel.getShape(); + expect(width).toEqual("210"); + expect(height).toEqual("130"); + }); + + test("should decrease BKM node size", async ({ nodes, bkmPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: 100, yOffset: 100 }); + await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: -20, yOffset: -20 }); - test("should increase BKM node size", async ({ nodes, bkmPropertiesPanel }) => { - await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: 50, yOffset: 50 }); + await bkmPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.BKM }); + const { width, height } = await bkmPropertiesPanel.getShape(); + expect(width).toEqual("240"); + expect(height).toEqual("160"); + }); - await bkmPropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.BKM }); - const { width, height } = await bkmPropertiesPanel.getShape(); - expect(width).toEqual("210"); - expect(height).toEqual("130"); + test("should not decrease below minimal BKM node size", async ({ nodes, bkmPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: -50, yOffset: -50 }); + + await bkmPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.BKM }); + const { width, height } = await bkmPropertiesPanel.getShape(); + expect(width).toEqual("160"); + expect(height).toEqual("80"); + }); }); - test("should decrease BKM node size", async ({ nodes, bkmPropertiesPanel }) => { - await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: 100, yOffset: 100 }); - await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: -20, yOffset: -20 }); + test.describe("Resize with snapping turned on", () => { + test.beforeEach(async ({ palette }) => { + await palette.dragNewNode({ type: NodeType.BKM, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase BKM node size", async ({ nodes, bkmPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: 50, yOffset: 50 }); + + await bkmPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.BKM }); + const { width, height } = await bkmPropertiesPanel.getShape(); + expect(width).toEqual("200"); + expect(height).toEqual("120"); + }); + + test("should decrease BKM node size", async ({ nodes, bkmPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: 100, yOffset: 100 }); + await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: -20, yOffset: -20 }); - await bkmPropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.BKM }); - const { width, height } = await bkmPropertiesPanel.getShape(); - expect(width).toEqual("240"); - expect(height).toEqual("160"); + await bkmPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.BKM }); + const { width, height } = await bkmPropertiesPanel.getShape(); + expect(width).toEqual("240"); + expect(height).toEqual("160"); + }); + + test("should not decrease below minimal BKM node size", async ({ nodes, bkmPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: -50, yOffset: -50 }); + + await bkmPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.BKM }); + const { width, height } = await bkmPropertiesPanel.getShape(); + expect(width).toEqual("160"); + expect(height).toEqual("80"); + }); }); - test("should not decrease below minimal BKM node size", async ({ nodes, bkmPropertiesPanel }) => { - await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: -50, yOffset: -50 }); + test.describe("Resize with non default snapping", () => { + test.beforeEach(async ({ overlays, palette }) => { + await overlays.setSnapping({ horizontal: "50", vertical: "50" }); + await palette.dragNewNode({ type: NodeType.BKM, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase BKM node size", async ({ nodes, bkmPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: 50, yOffset: 50 }); + + await bkmPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.BKM }); + const { width, height } = await bkmPropertiesPanel.getShape(); + expect(width).toEqual("250"); + expect(height).toEqual("150"); + }); + + test("should decrease BKM node size", async ({ nodes, bkmPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: 100, yOffset: 100 }); + await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: -20, yOffset: -20 }); + + await bkmPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.BKM }); + const { width, height } = await bkmPropertiesPanel.getShape(); + expect(width).toEqual("250"); + expect(height).toEqual("150"); + }); + + test("should not decrease below minimal BKM node size", async ({ nodes, bkmPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.BKM, xOffset: -50, yOffset: -50 }); - await bkmPropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.BKM }); - const { width, height } = await bkmPropertiesPanel.getShape(); - expect(width).toEqual("160"); - expect(height).toEqual("80"); + await bkmPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.BKM }); + const { width, height } = await bkmPropertiesPanel.getShape(); + expect(width).toEqual("200"); + expect(height).toEqual("100"); + }); }); }); diff --git a/packages/dmn-editor/tests/e2e/drgElements/resizeDecision.spec.ts b/packages/dmn-editor/tests/e2e/drgElements/resizeDecision.spec.ts index 3212a9583af..e9a0dd8041d 100644 --- a/packages/dmn-editor/tests/e2e/drgElements/resizeDecision.spec.ts +++ b/packages/dmn-editor/tests/e2e/drgElements/resizeDecision.spec.ts @@ -25,39 +25,114 @@ test.beforeEach(async ({ editor }) => { }); test.describe("Resize node - Decision", () => { - test.beforeEach(async ({ overlays, palette }) => { - await overlays.turnOffSnapping(); - await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 100, y: 100 } }); - }); + test.describe("Resize with snapping turned off", () => { + test.beforeEach(async ({ overlays, palette }) => { + await overlays.turnOffSnapping(); + await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Decision node size", async ({ nodes, decisionPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: 50, yOffset: 50 }); + + await decisionPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION }); + const { width, height } = await decisionPropertiesPanel.getShape(); + expect(width).toEqual("210"); + expect(height).toEqual("130"); + }); + + test("should decrease Decision node size", async ({ nodes, decisionPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: 100, yOffset: 100 }); + await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: -20, yOffset: -20 }); - test("should increase Decision node size", async ({ nodes, decisionPropertiesPanel }) => { - await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: 50, yOffset: 50 }); + await decisionPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION }); + const { width, height } = await decisionPropertiesPanel.getShape(); + expect(width).toEqual("240"); + expect(height).toEqual("160"); + }); - await decisionPropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.DECISION }); - const { width, height } = await decisionPropertiesPanel.getShape(); - expect(width).toEqual("210"); - expect(height).toEqual("130"); + test("should not decrease below minimal Decision node size", async ({ nodes, decisionPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: -50, yOffset: -50 }); + + await decisionPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION }); + const { width, height } = await decisionPropertiesPanel.getShape(); + expect(width).toEqual("160"); + expect(height).toEqual("80"); + }); }); + test.describe("Resize with snapping turned on", () => { + test.beforeEach(async ({ palette }) => { + await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Decision node size", async ({ nodes, decisionPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: 50, yOffset: 50 }); + + await decisionPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION }); + const { width, height } = await decisionPropertiesPanel.getShape(); + expect(width).toEqual("200"); + expect(height).toEqual("120"); + }); - test("should decrease Decision node size", async ({ nodes, decisionPropertiesPanel }) => { - await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: 100, yOffset: 100 }); - await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: -20, yOffset: -20 }); + test("should decrease Decision node size", async ({ nodes, decisionPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: 100, yOffset: 100 }); + await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: -20, yOffset: -20 }); - await decisionPropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.DECISION }); - const { width, height } = await decisionPropertiesPanel.getShape(); - expect(width).toEqual("240"); - expect(height).toEqual("160"); + await decisionPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION }); + const { width, height } = await decisionPropertiesPanel.getShape(); + expect(width).toEqual("240"); + expect(height).toEqual("160"); + }); + + test("should not decrease below minimal Decision node size", async ({ nodes, decisionPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: -50, yOffset: -50 }); + + await decisionPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION }); + const { width, height } = await decisionPropertiesPanel.getShape(); + expect(width).toEqual("160"); + expect(height).toEqual("80"); + }); }); + test.describe("Resize with non default snapping", () => { + test.beforeEach(async ({ overlays, palette }) => { + await overlays.setSnapping({ horizontal: "50", vertical: "50" }); + await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Decision node size", async ({ nodes, decisionPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: 50, yOffset: 50 }); + + await decisionPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION }); + const { width, height } = await decisionPropertiesPanel.getShape(); + expect(width).toEqual("250"); + expect(height).toEqual("150"); + }); + + test("should decrease Decision node size", async ({ nodes, decisionPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: 100, yOffset: 100 }); + await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: -20, yOffset: -20 }); + + await decisionPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION }); + const { width, height } = await decisionPropertiesPanel.getShape(); + expect(width).toEqual("250"); + expect(height).toEqual("150"); + }); - test("should not decrease below minimal Decision node size", async ({ nodes, decisionPropertiesPanel }) => { - await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: -50, yOffset: -50 }); + test("should not decrease below minimal Decision node size", async ({ nodes, decisionPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.DECISION, xOffset: -50, yOffset: -50 }); - await decisionPropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.DECISION }); - const { width, height } = await decisionPropertiesPanel.getShape(); - expect(width).toEqual("160"); - expect(height).toEqual("80"); + await decisionPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION }); + const { width, height } = await decisionPropertiesPanel.getShape(); + expect(width).toEqual("200"); + expect(height).toEqual("100"); + }); }); }); diff --git a/packages/dmn-editor/tests/e2e/drgElements/resizeDecisionService.spec.ts b/packages/dmn-editor/tests/e2e/drgElements/resizeDecisionService.spec.ts index b49a097ad90..df1d6552095 100644 --- a/packages/dmn-editor/tests/e2e/drgElements/resizeDecisionService.spec.ts +++ b/packages/dmn-editor/tests/e2e/drgElements/resizeDecisionService.spec.ts @@ -25,62 +25,185 @@ test.beforeEach(async ({ editor }) => { }); test.describe("Resize node - Decision Service", () => { - test.beforeEach(async ({ overlays, palette }) => { - await overlays.turnOffSnapping(); - await palette.dragNewNode({ type: NodeType.DECISION_SERVICE, targetPosition: { x: 100, y: 100 } }); - }); + test.describe("Resize with snapping turned off", () => { + test.beforeEach(async ({ overlays, palette }) => { + await overlays.turnOffSnapping(); + await palette.dragNewNode({ type: NodeType.DECISION_SERVICE, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Decision Service node size", async ({ nodes, decisionServicePropertiesPanel }) => { + await nodes.resize({ + nodeName: DefaultNodeName.DECISION_SERVICE, + position: NodePosition.TOP, + xOffset: 50, + yOffset: 50, + }); + + await decisionServicePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION_SERVICE, position: NodePosition.TOP }); + const { width, height } = await decisionServicePropertiesPanel.getShape(); + expect(width).toEqual("370"); + expect(height).toEqual("370"); + }); + + test("should decrease Decision Service node size", async ({ nodes, decisionServicePropertiesPanel }) => { + await nodes.resize({ + nodeName: DefaultNodeName.DECISION_SERVICE, + position: NodePosition.TOP, + xOffset: 100, + yOffset: 100, + }); + await nodes.resize({ + nodeName: DefaultNodeName.DECISION_SERVICE, + position: NodePosition.TOP, + xOffset: -20, + yOffset: -20, + }); - test("should increase Decision Service node size", async ({ nodes, decisionServicePropertiesPanel }) => { - await nodes.resize({ - nodeName: DefaultNodeName.DECISION_SERVICE, - position: NodePosition.TOP, - xOffset: 50, - yOffset: 50, + await decisionServicePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION_SERVICE, position: NodePosition.TOP }); + const { width, height } = await decisionServicePropertiesPanel.getShape(); + expect(width).toEqual("400"); + expect(height).toEqual("400"); }); - await decisionServicePropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.DECISION_SERVICE, position: NodePosition.TOP }); - const { width, height } = await decisionServicePropertiesPanel.getShape(); - expect(width).toEqual("370"); - expect(height).toEqual("370"); + test("should not decrease below minimal Decision Service node size", async ({ + nodes, + decisionServicePropertiesPanel, + }) => { + await nodes.resize({ + nodeName: DefaultNodeName.DECISION_SERVICE, + position: NodePosition.TOP, + xOffset: -50, + yOffset: -50, + }); + + await decisionServicePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION_SERVICE, position: NodePosition.TOP }); + const { width, height } = await decisionServicePropertiesPanel.getShape(); + expect(width).toEqual("280"); + expect(height).toEqual("280"); + }); }); - test("should decrease Decision Service node size", async ({ nodes, decisionServicePropertiesPanel }) => { - await nodes.resize({ - nodeName: DefaultNodeName.DECISION_SERVICE, - position: NodePosition.TOP, - xOffset: 100, - yOffset: 100, + test.describe("Resize with snapping turned on", () => { + test.beforeEach(async ({ palette }) => { + await palette.dragNewNode({ type: NodeType.DECISION_SERVICE, targetPosition: { x: 100, y: 100 } }); }); - await nodes.resize({ - nodeName: DefaultNodeName.DECISION_SERVICE, - position: NodePosition.TOP, - xOffset: -20, - yOffset: -20, + + test("should increase Decision Service node size", async ({ nodes, decisionServicePropertiesPanel }) => { + await nodes.resize({ + nodeName: DefaultNodeName.DECISION_SERVICE, + position: NodePosition.TOP, + xOffset: 50, + yOffset: 50, + }); + + await decisionServicePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION_SERVICE, position: NodePosition.TOP }); + const { width, height } = await decisionServicePropertiesPanel.getShape(); + expect(width).toEqual("360"); + expect(height).toEqual("360"); }); - await decisionServicePropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.DECISION_SERVICE, position: NodePosition.TOP }); - const { width, height } = await decisionServicePropertiesPanel.getShape(); - expect(width).toEqual("400"); - expect(height).toEqual("400"); + test("should decrease Decision Service node size", async ({ nodes, decisionServicePropertiesPanel }) => { + await nodes.resize({ + nodeName: DefaultNodeName.DECISION_SERVICE, + position: NodePosition.TOP, + xOffset: 100, + yOffset: 100, + }); + await nodes.resize({ + nodeName: DefaultNodeName.DECISION_SERVICE, + position: NodePosition.TOP, + xOffset: -20, + yOffset: -20, + }); + + await decisionServicePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION_SERVICE, position: NodePosition.TOP }); + const { width, height } = await decisionServicePropertiesPanel.getShape(); + expect(width).toEqual("400"); + expect(height).toEqual("400"); + }); + + test("should not decrease below minimal Decision Service node size", async ({ + nodes, + decisionServicePropertiesPanel, + }) => { + await nodes.resize({ + nodeName: DefaultNodeName.DECISION_SERVICE, + position: NodePosition.TOP, + xOffset: -50, + yOffset: -50, + }); + + await decisionServicePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION_SERVICE, position: NodePosition.TOP }); + const { width, height } = await decisionServicePropertiesPanel.getShape(); + expect(width).toEqual("280"); + expect(height).toEqual("280"); + }); }); - test("should not decrease below minimal Decision Service node size", async ({ - nodes, - decisionServicePropertiesPanel, - }) => { - await nodes.resize({ - nodeName: DefaultNodeName.DECISION_SERVICE, - position: NodePosition.TOP, - xOffset: -50, - yOffset: -50, + test.describe("Resize with non default snapping", () => { + test.beforeEach(async ({ overlays, palette }) => { + await overlays.setSnapping({ horizontal: "50", vertical: "50" }); + await palette.dragNewNode({ type: NodeType.DECISION_SERVICE, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Decision Service node size", async ({ nodes, decisionServicePropertiesPanel }) => { + await nodes.resize({ + nodeName: DefaultNodeName.DECISION_SERVICE, + position: NodePosition.TOP, + xOffset: 50, + yOffset: 50, + }); + + await decisionServicePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION_SERVICE, position: NodePosition.TOP }); + const { width, height } = await decisionServicePropertiesPanel.getShape(); + expect(width).toEqual("400"); + expect(height).toEqual("400"); }); - await decisionServicePropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.DECISION_SERVICE, position: NodePosition.TOP }); - const { width, height } = await decisionServicePropertiesPanel.getShape(); - expect(width).toEqual("280"); - expect(height).toEqual("280"); + test("should decrease Decision Service node size", async ({ nodes, decisionServicePropertiesPanel }) => { + await nodes.resize({ + nodeName: DefaultNodeName.DECISION_SERVICE, + position: NodePosition.TOP, + xOffset: 100, + yOffset: 100, + }); + await nodes.resize({ + nodeName: DefaultNodeName.DECISION_SERVICE, + position: NodePosition.TOP, + xOffset: -20, + yOffset: -20, + }); + + await decisionServicePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION_SERVICE, position: NodePosition.TOP }); + const { width, height } = await decisionServicePropertiesPanel.getShape(); + expect(width).toEqual("400"); + expect(height).toEqual("400"); + }); + + test("should not decrease below minimal Decision Service node size", async ({ + nodes, + decisionServicePropertiesPanel, + }) => { + await nodes.resize({ + nodeName: DefaultNodeName.DECISION_SERVICE, + position: NodePosition.TOP, + xOffset: -50, + yOffset: -50, + }); + + await decisionServicePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.DECISION_SERVICE, position: NodePosition.TOP }); + const { width, height } = await decisionServicePropertiesPanel.getShape(); + expect(width).toEqual("300"); + expect(height).toEqual("300"); + }); }); }); diff --git a/packages/dmn-editor/tests/e2e/drgElements/resizeInputData.spec.ts b/packages/dmn-editor/tests/e2e/drgElements/resizeInputData.spec.ts index 54401e57e10..9ea6952aed1 100644 --- a/packages/dmn-editor/tests/e2e/drgElements/resizeInputData.spec.ts +++ b/packages/dmn-editor/tests/e2e/drgElements/resizeInputData.spec.ts @@ -25,39 +25,116 @@ test.beforeEach(async ({ editor }) => { }); test.describe("Resize node - Input Data", () => { - test.beforeEach(async ({ overlays, palette }) => { - await overlays.turnOffSnapping(); - await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } }); - }); + test.describe("Resize with snapping turned off", () => { + test.beforeEach(async ({ overlays, palette }) => { + await overlays.turnOffSnapping(); + await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Input Data node size", async ({ nodes, inputDataPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: 50, yOffset: 50 }); + + await inputDataPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.INPUT_DATA }); + const { width, height } = await inputDataPropertiesPanel.getShape(); + expect(width).toEqual("210"); + expect(height).toEqual("130"); + }); + + test("should decrease Input Data node size", async ({ nodes, inputDataPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: 100, yOffset: 100 }); + await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: -20, yOffset: -20 }); - test("should increase Input Data node size", async ({ nodes, inputDataPropertiesPanel }) => { - await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: 50, yOffset: 50 }); + await inputDataPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.INPUT_DATA }); + const { width, height } = await inputDataPropertiesPanel.getShape(); + expect(width).toEqual("240"); + expect(height).toEqual("160"); + }); - await inputDataPropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.INPUT_DATA }); - const { width, height } = await inputDataPropertiesPanel.getShape(); - expect(width).toEqual("210"); - expect(height).toEqual("130"); + test("should not decrease below minimal Input Data node size", async ({ nodes, inputDataPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: -50, yOffset: -50 }); + + await inputDataPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.INPUT_DATA }); + const { width, height } = await inputDataPropertiesPanel.getShape(); + expect(width).toEqual("160"); + expect(height).toEqual("80"); + }); }); - test("should decrease Input Data node size", async ({ nodes, inputDataPropertiesPanel }) => { - await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: 100, yOffset: 100 }); - await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: -20, yOffset: -20 }); + test.describe("Resize with snapping turned on", () => { + test.beforeEach(async ({ palette }) => { + await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Input Data node size", async ({ nodes, inputDataPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: 50, yOffset: 50 }); + + await inputDataPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.INPUT_DATA }); + const { width, height } = await inputDataPropertiesPanel.getShape(); + expect(width).toEqual("200"); + expect(height).toEqual("120"); + }); + + test("should decrease Input Data node size", async ({ nodes, inputDataPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: 100, yOffset: 100 }); + await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: -20, yOffset: -20 }); - await inputDataPropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.INPUT_DATA }); - const { width, height } = await inputDataPropertiesPanel.getShape(); - expect(width).toEqual("240"); - expect(height).toEqual("160"); + await inputDataPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.INPUT_DATA }); + const { width, height } = await inputDataPropertiesPanel.getShape(); + expect(width).toEqual("240"); + expect(height).toEqual("160"); + }); + + test("should not decrease below minimal Input Data node size", async ({ nodes, inputDataPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: -50, yOffset: -50 }); + + await inputDataPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.INPUT_DATA }); + const { width, height } = await inputDataPropertiesPanel.getShape(); + expect(width).toEqual("160"); + expect(height).toEqual("80"); + }); }); - test("should not decrease below minimal Input Data node size", async ({ nodes, inputDataPropertiesPanel }) => { - await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: -50, yOffset: -50 }); + test.describe("Resize with non default snapping", () => { + test.beforeEach(async ({ overlays, palette }) => { + await overlays.setSnapping({ horizontal: "50", vertical: "50" }); + await palette.dragNewNode({ type: NodeType.INPUT_DATA, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Input Data node size", async ({ nodes, inputDataPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: 50, yOffset: 50 }); + + await inputDataPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.INPUT_DATA }); + const { width, height } = await inputDataPropertiesPanel.getShape(); + expect(width).toEqual("250"); + expect(height).toEqual("150"); + }); + + test("should decrease Input Data node size", async ({ nodes, inputDataPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: 100, yOffset: 100 }); + await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: -20, yOffset: -20 }); + + await inputDataPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.INPUT_DATA }); + const { width, height } = await inputDataPropertiesPanel.getShape(); + expect(width).toEqual("250"); + expect(height).toEqual("150"); + }); + + test("should not decrease below minimal Input Data node size", async ({ nodes, inputDataPropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.INPUT_DATA, xOffset: -50, yOffset: -50 }); - await inputDataPropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.INPUT_DATA }); - const { width, height } = await inputDataPropertiesPanel.getShape(); - expect(width).toEqual("160"); - expect(height).toEqual("80"); + await inputDataPropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.INPUT_DATA }); + const { width, height } = await inputDataPropertiesPanel.getShape(); + expect(width).toEqual("200"); + expect(height).toEqual("100"); + }); }); }); diff --git a/packages/dmn-editor/tests/e2e/drgElements/resizeKnowledgeSource.spec.ts b/packages/dmn-editor/tests/e2e/drgElements/resizeKnowledgeSource.spec.ts index e30dee5c483..25a9d01cac9 100644 --- a/packages/dmn-editor/tests/e2e/drgElements/resizeKnowledgeSource.spec.ts +++ b/packages/dmn-editor/tests/e2e/drgElements/resizeKnowledgeSource.spec.ts @@ -25,42 +25,125 @@ test.beforeEach(async ({ editor }) => { }); test.describe("Resize node - Knowledge Source", () => { - test.beforeEach(async ({ overlays, palette }) => { - await overlays.turnOffSnapping(); - await palette.dragNewNode({ type: NodeType.KNOWLEDGE_SOURCE, targetPosition: { x: 100, y: 100 } }); - }); + test.describe("Resize with snapping turned off", () => { + test.beforeEach(async ({ overlays, palette }) => { + await overlays.turnOffSnapping(); + await palette.dragNewNode({ type: NodeType.KNOWLEDGE_SOURCE, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Knowledge Source node size", async ({ nodes, knowledgeSourcePropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: 50, yOffset: 50 }); + + await knowledgeSourcePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.KNOWLEDGE_SOURCE }); + const { width, height } = await knowledgeSourcePropertiesPanel.getShape(); + expect(width).toEqual("210"); + expect(height).toEqual("130"); + }); + + test("should decrease Knowledge Source node size", async ({ nodes, knowledgeSourcePropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: 100, yOffset: 100 }); + await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: -20, yOffset: -20 }); - test("should increase Knowledge Source node size", async ({ nodes, knowledgeSourcePropertiesPanel }) => { - await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: 50, yOffset: 50 }); + await knowledgeSourcePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.KNOWLEDGE_SOURCE }); + const { width, height } = await knowledgeSourcePropertiesPanel.getShape(); + expect(width).toEqual("240"); + expect(height).toEqual("160"); + }); - await knowledgeSourcePropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.KNOWLEDGE_SOURCE }); - const { width, height } = await knowledgeSourcePropertiesPanel.getShape(); - expect(width).toEqual("210"); - expect(height).toEqual("130"); + test("should not decrease below minimal Knowledge Source node size", async ({ + nodes, + knowledgeSourcePropertiesPanel, + }) => { + await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: -50, yOffset: -50 }); + + await knowledgeSourcePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.KNOWLEDGE_SOURCE }); + const { width, height } = await knowledgeSourcePropertiesPanel.getShape(); + expect(width).toEqual("160"); + expect(height).toEqual("80"); + }); }); - test("should decrease Knowledge Source node size", async ({ nodes, knowledgeSourcePropertiesPanel }) => { - await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: 100, yOffset: 100 }); - await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: -20, yOffset: -20 }); + test.describe("Resize with snapping turned on", () => { + test.beforeEach(async ({ palette }) => { + await palette.dragNewNode({ type: NodeType.KNOWLEDGE_SOURCE, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Knowledge Source node size", async ({ nodes, knowledgeSourcePropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: 50, yOffset: 50 }); + + await knowledgeSourcePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.KNOWLEDGE_SOURCE }); + const { width, height } = await knowledgeSourcePropertiesPanel.getShape(); + expect(width).toEqual("200"); + expect(height).toEqual("120"); + }); + + test("should decrease Knowledge Source node size", async ({ nodes, knowledgeSourcePropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: 100, yOffset: 100 }); + await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: -20, yOffset: -20 }); - await knowledgeSourcePropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.KNOWLEDGE_SOURCE }); - const { width, height } = await knowledgeSourcePropertiesPanel.getShape(); - expect(width).toEqual("240"); - expect(height).toEqual("160"); + await knowledgeSourcePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.KNOWLEDGE_SOURCE }); + const { width, height } = await knowledgeSourcePropertiesPanel.getShape(); + expect(width).toEqual("240"); + expect(height).toEqual("160"); + }); + + test("should not decrease below minimal Knowledge Source node size", async ({ + nodes, + knowledgeSourcePropertiesPanel, + }) => { + await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: -50, yOffset: -50 }); + + await knowledgeSourcePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.KNOWLEDGE_SOURCE }); + const { width, height } = await knowledgeSourcePropertiesPanel.getShape(); + expect(width).toEqual("160"); + expect(height).toEqual("80"); + }); }); - test("should not decrease below minimal Knowledge Source node size", async ({ - nodes, - knowledgeSourcePropertiesPanel, - }) => { - await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: -50, yOffset: -50 }); - - await knowledgeSourcePropertiesPanel.open(); - await nodes.select({ name: DefaultNodeName.KNOWLEDGE_SOURCE }); - const { width, height } = await knowledgeSourcePropertiesPanel.getShape(); - expect(width).toEqual("160"); - expect(height).toEqual("80"); + test.describe("Resize with non default snapping", () => { + test.beforeEach(async ({ overlays, palette }) => { + await overlays.setSnapping({ horizontal: "50", vertical: "50" }); + await palette.dragNewNode({ type: NodeType.KNOWLEDGE_SOURCE, targetPosition: { x: 100, y: 100 } }); + }); + + test("should increase Knowledge Source node size", async ({ nodes, knowledgeSourcePropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: 50, yOffset: 50 }); + + await knowledgeSourcePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.KNOWLEDGE_SOURCE }); + const { width, height } = await knowledgeSourcePropertiesPanel.getShape(); + expect(width).toEqual("250"); + expect(height).toEqual("150"); + }); + + test("should decrease Knowledge Source node size", async ({ nodes, knowledgeSourcePropertiesPanel }) => { + await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: 100, yOffset: 100 }); + await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: -20, yOffset: -20 }); + + await knowledgeSourcePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.KNOWLEDGE_SOURCE }); + const { width, height } = await knowledgeSourcePropertiesPanel.getShape(); + expect(width).toEqual("250"); + expect(height).toEqual("150"); + }); + + test("should not decrease below minimal Knowledge Source node size", async ({ + nodes, + knowledgeSourcePropertiesPanel, + }) => { + await nodes.resize({ nodeName: DefaultNodeName.KNOWLEDGE_SOURCE, xOffset: -50, yOffset: -50 }); + + await knowledgeSourcePropertiesPanel.open(); + await nodes.select({ name: DefaultNodeName.KNOWLEDGE_SOURCE }); + const { width, height } = await knowledgeSourcePropertiesPanel.getShape(); + expect(width).toEqual("200"); + expect(height).toEqual("100"); + }); }); });