ljmotta commented on code in PR #2494:
URL: 
https://github.com/apache/incubator-kie-tools/pull/2494#discussion_r1697003156


##########
packages/dmn-editor/tests-e2e/__fixtures__/base.ts:
##########


Review Comment:
   We already can change tabs using the `editor.changeTab`



##########
packages/dmn-editor/tests-e2e/__fixtures__/diagram.ts:
##########
@@ -51,4 +51,16 @@ export class Diagram {
     await this.page.getByLabel("Tweak the shape of the input data 
node").getByText("Alternative").click();
     await this.get().getByTitle("Select or edit DRD").click();
   }
+
+  public async zoomIn(clicks: { clicks: number }) {
+    await this.get().getByTestId("rf__controls").getByTitle("zoom in").click({ 
clickCount: clicks.clicks });
+  }
+
+  public async zoomOut(clicks: { clicks: number }) {
+    await this.get().getByTestId("rf__controls").getByLabel("zoom 
out").click({ clickCount: clicks.clicks });
+  }
+
+  public async fitView() {
+    await this.get().getByTestId("rf__controls").getByLabel("fit 
view").click();
+  }

Review Comment:
   Please, do not use React Flow data-testids. This is the same principle of a 
third party class. We don't have control over it.



##########
packages/dmn-editor/tests-e2e/zoomDiagram.spec.ts:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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, test } from "./__fixtures__/base";
+import { NodeType } from "./__fixtures__/nodes";
+import { Tab } from "./__fixtures__/tabs";
+
+test.beforeEach(async ({ editor }) => {
+  await editor.open();
+});
+
+test.describe("Zoom and Panning Diagram", () => {
+  test("should zoom in diagram", async ({ nodes, palette, diagram, 
multipleNodesPropertiesPanel }) => {
+    await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 
100, y: 10 } });
+    await diagram.resetFocus();
+    await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 
100, y: 110 } });
+    await diagram.resetFocus();
+    await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 
100, y: 210 } });
+    await diagram.zoomIn({ clicks: 1 });
+    await expect(diagram.get()).toHaveScreenshot("zoom-in-diagram.png");
+  });
+
+  test("should zoom out diagram", async ({ nodes, palette, diagram, 
multipleNodesPropertiesPanel }) => {
+    await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 
100, y: 10 } });
+    await diagram.resetFocus();
+    await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 
100, y: 110 } });
+    await diagram.resetFocus();
+    await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 
100, y: 210 } });
+    await diagram.zoomOut({ clicks: 2 });
+    await expect(diagram.get()).toHaveScreenshot("zoom-out-diagram.png");
+  });
+
+  test("should fit to view diagram", async ({ nodes, palette, diagram, 
multipleNodesPropertiesPanel }) => {
+    await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 
10, y: 10 } });
+    await diagram.resetFocus();
+    await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 
400, y: 400 } });
+    await diagram.resetFocus();
+    await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 
200, y: 200 } });
+    await diagram.zoomIn({ clicks: 2 });
+    await diagram.fitView();
+    await expect(diagram.get()).toHaveScreenshot("fit-to-view-diagram.png");
+  });
+
+  test("should keep view settings after swap tabs", async ({ palette, diagram, 
tabs, page }) => {
+    await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 
100, y: 100 } });
+    await diagram.resetFocus();
+    await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 
200, y: 200 } });
+    await diagram.resetFocus();
+    await palette.dragNewNode({ type: NodeType.DECISION, targetPosition: { x: 
200, y: 300 } });
+    await diagram.zoomOut({ clicks: 3 });
+    await page.mouse.move(500, 500);
+    await page.mouse.down();
+    await page.mouse.move(300, 300);
+    await page.mouse.up();

Review Comment:
   Why this is necessary?



##########
packages/dmn-editor/tests-e2e/__fixtures__/diagram.ts:
##########
@@ -51,4 +51,16 @@ export class Diagram {
     await this.page.getByLabel("Tweak the shape of the input data 
node").getByText("Alternative").click();
     await this.get().getByTitle("Select or edit DRD").click();
   }
+
+  public async zoomIn(clicks: { clicks: number }) {
+    await this.get().getByTestId("rf__controls").getByTitle("zoom in").click({ 
clickCount: clicks.clicks });
+  }
+
+  public async zoomOut(clicks: { clicks: number }) {
+    await this.get().getByTestId("rf__controls").getByLabel("zoom 
out").click({ clickCount: clicks.clicks });
+  }

Review Comment:
   For this case, we would call the function arguments object as `args`, 
avoiding the `clicks.clicks`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to