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


##########
packages/scesim-editor/src/TestScenarioEditor.tsx:
##########


Review Comment:
   I'm not sure about the changes on this file. The `model` and `onModelChange` 
are just used on Storybook?



##########
packages/scesim-editor/stories/scesimEditorStoriesWrapper.tsx:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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 * as React from "react";
+import { useArgs } from "@storybook/preview-api";
+import { useRef, useMemo, useEffect } from "react";
+import { SceSimModel } from "@kie-tools/scesim-marshaller";
+import { TestScenarioEditor, TestScenarioEditorProps, TestScenarioEditorRef } 
from "../src/TestScenarioEditor";
+import { diff } from "deep-object-diff";
+
+export function SceSimEditorWrapper(props?: Partial<TestScenarioEditorProps>) {
+  const [args, updateArgs] = useArgs<TestScenarioEditorProps>();
+  const argsCopy = useRef(args);
+  const ref = useRef<TestScenarioEditorRef>(null);
+  const [modelArgs, setModelArgs] = React.useState<SceSimModel>(args.model);
+  const model = React.useMemo(() => props?.model ?? modelArgs, [modelArgs, 
props?.model]);
+
+  const onModelChange = useMemo(
+    () => (props?.onModelChange ? props.onModelChange : setModelArgs),
+    [props?.onModelChange]
+  );
+
+  useEffect(() => {
+    if (Object.keys(diff(argsCopy.current.model, model)).length !== 0) {
+      updateArgs({ ...argsCopy.current, model: model });
+    }
+  }, [updateArgs, model]);
+
+  useEffect(() => {
+    if (Object.keys(diff(argsCopy.current, args)).length === 0) {
+      return;
+    }
+    argsCopy.current = args;
+    if (Object.keys(diff(args.model, model)).length === 0) {
+      return;
+    }
+    onModelChange(args.model);
+  }, [args, model, onModelChange]);
+  useEffect(() => {
+    /* Simulating a call from "Foundation" code */
+    setTimeout(() => {
+      ref.current?.setContent("Untitled.scesim", "");
+    }, 1000);
+  }, [ref]);

Review Comment:
   Why this is needed? What happens when setting the ref without the 
`setTimeout`?



##########
packages/scesim-editor/stories/scesimEditorStoriesWrapper.tsx:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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 * as React from "react";
+import { useArgs } from "@storybook/preview-api";
+import { useRef, useMemo, useEffect } from "react";
+import { SceSimModel } from "@kie-tools/scesim-marshaller";
+import { TestScenarioEditor, TestScenarioEditorProps, TestScenarioEditorRef } 
from "../src/TestScenarioEditor";
+import { diff } from "deep-object-diff";
+
+export function SceSimEditorWrapper(props?: Partial<TestScenarioEditorProps>) {

Review Comment:
   The wrapper props doesn't need to be strict equal to the editor props. You 
can create a different interface for it.



##########
packages/scesim-editor/tests/e2e/features/keyboard/keyboard.spec.ts:
##########
@@ -0,0 +1,70 @@
+/*
+ * 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 { AssetType } from "../../__fixtures__/editor";
+import { AddRowPosition, Type } from "../../__fixtures__/table";
+
+test.describe("Keyboard", () => {
+  test.describe("Keyboard-Shortcuts Navigation", () => {

Review Comment:
   ```suggestion
     test.describe("Keyboard shortcuts navigation", () => {
   ```



##########
packages/scesim-editor/tests/e2e/features/keyboard/keyboard.spec.ts:
##########
@@ -0,0 +1,70 @@
+/*
+ * 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 { AssetType } from "../../__fixtures__/editor";
+import { AddRowPosition, Type } from "../../__fixtures__/table";
+
+test.describe("Keyboard", () => {
+  test.describe("Keyboard-Shortcuts Navigation", () => {
+    test("should correctly navigate the page using keyboard shortcuts", async 
({
+      editor,
+      table,
+      testScenarioTable,
+    }) => {
+      await editor.createTestScenario(AssetType.RULE);
+      await table.addRow({ targetCell: "1", position: AddRowPosition.BELOW });
+      await table.addRow({ targetCell: "1", position: AddRowPosition.BELOW });
+      await table.addRow({ targetCell: "1", position: AddRowPosition.BELOW });
+      await table.selectCell({ rowNumber: "1", columnNumber: 0 });
+      await table.navigateRight({ rowNumber: "1", columnNumber: 0, type: 
Type.KEYBOARD_SHORTCUT });
+      await 
expect(testScenarioTable.get()).toHaveScreenshot("navigation-screenshot-right.png",
 {
+        maxDiffPixels: 1000,
+      });
+      await table.navigateDown({ rowNumber: "1", columnNumber: 1, type: 
Type.KEYBOARD_SHORTCUT });
+      await 
expect(testScenarioTable.get()).toHaveScreenshot("navigation-screenshot-down.png",
 { maxDiffPixels: 1000 });
+      await table.navigateLeft({ rowNumber: "2", columnNumber: 1, type: 
Type.KEYBOARD_SHORTCUT });
+      await 
expect(testScenarioTable.get()).toHaveScreenshot("navigation-screenshot-left.png",
 { maxDiffPixels: 1000 });
+      await table.navigateUp({ rowNumber: "2", columnNumber: 0, type: 
Type.KEYBOARD_SHORTCUT });
+      await 
expect(testScenarioTable.get()).toHaveScreenshot("navigation-screenshot-up.png",
 { maxDiffPixels: 1000 });
+      await table.deselectCell({ rowNumber: "2", columnNumber: 0 });
+      await 
expect(testScenarioTable.get()).toHaveScreenshot("navigation-escaped-screenshot.png");
+    });
+  });
+
+  test.describe("Arrow Key Navigation", () => {
+    test("should correctly navigate the page using arrow keys", async ({ 
editor, table, testScenarioTable }) => {

Review Comment:
   ```suggestion
       test("should correctly navigate the table using arrow keys", async ({ 
editor, table, testScenarioTable }) => {
   ```



##########
packages/scesim-editor/tests/e2e/features/keyboard/keyboard.spec.ts:
##########
@@ -0,0 +1,70 @@
+/*
+ * 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 { AssetType } from "../../__fixtures__/editor";
+import { AddRowPosition, Type } from "../../__fixtures__/table";
+
+test.describe("Keyboard", () => {
+  test.describe("Keyboard-Shortcuts Navigation", () => {
+    test("should correctly navigate the page using keyboard shortcuts", async 
({

Review Comment:
   ```suggestion
       test("should correctly navigate the table using keyboard shortcuts", 
async ({
   ```



##########
packages/scesim-editor/tests/e2e/__fixtures__/editor.ts:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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 { Page } from "@playwright/test";
+import { SelectorPanel } from "./selectorPanel";
+
+export enum AssetType {
+  DECISION,
+  RULE,
+}
+
+export class Editor {
+  constructor(public page: Page, public selectorPanel: SelectorPanel, public 
baseURL?: string) {
+    this.page = page;
+    this.baseURL = baseURL;
+  }
+
+  public getIframeURL(iframeId: string) {
+    return `iframe.html?id=${iframeId}&viewMode=story`;
+  }
+
+  public async openStartPage() {

Review Comment:
   I guess `openEmpty` would reflect better? WDYT?



##########
packages/scesim-editor/tests/e2e/scesimEditor/backgroundTable/contextMenu.spec.ts:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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 { test, expect } from "../../__fixtures__/base";
+import { AssetType } from "../../__fixtures__/editor";
+import { AddColumnPosition } from "../../__fixtures__/table";
+
+test.describe("Background Table context menu", () => {
+  test.describe("Context menu checks", () => {
+    test.beforeEach(async ({ editor, backgroundTable, table }) => {
+      await editor.createTestScenario(AssetType.DECISION, true);
+      await table.addPropertyColumn({
+        targetCell: "PROPERTY (<Undefined>)",
+        position: AddColumnPosition.RIGHT,
+        nth: 0,
+      });
+      await backgroundTable.fill({ content: "test", column: 1 });
+    });
+
+    test("should render select context menu", async ({ contextMenu }) => {
+      await contextMenu.openOnCell({ rowNumber: "test test", columnNumber: 0 
});
+      await expect(contextMenu.getHeader({ header: "SELECTION" 
})).toBeAttached();
+      await expect(contextMenu.getHeader({ header: "SCENARIO" 
})).not.toBeAttached();
+      await expect(contextMenu.getHeader({ header: "FIELD" 
})).not.toBeAttached();
+      await expect(contextMenu.getHeader({ header: "INSTANCE" 
})).not.toBeAttached();
+    });
+
+    test("should render field context menu", async ({ contextMenu }) => {
+      await contextMenu.openOnProperty({ name: "PROPERTY (<Undefined>)", 
columnNumber: 1 });
+      await expect(contextMenu.getHeader({ header: "SELECTION" 
})).not.toBeAttached();
+      await expect(contextMenu.getHeader({ header: "SCENARIO" 
})).not.toBeAttached();
+      await expect(contextMenu.getHeader({ header: "FIELD" })).toBeAttached();
+      await expect(contextMenu.getHeader({ header: "INSTANCE" 
})).not.toBeAttached();
+    });
+
+    test("should render instance context menu", async ({ contextMenu }) => {
+      await contextMenu.openOnInstance({ name: "INSTANCE-1 (<Undefined>)" });
+      await expect(contextMenu.getHeader({ header: "SELECTION" 
})).not.toBeAttached();
+      await expect(contextMenu.getHeader({ header: "SCENARIO" 
})).not.toBeAttached();
+      await expect(contextMenu.getHeader({ header: "FIELD" 
})).not.toBeAttached();
+      await expect(contextMenu.getHeader({ header: "INSTANCE" 
})).toBeAttached();
+    });
+    test("should add and delete instance column left", async ({ table, 
backgroundTable, contextMenu }) => {

Review Comment:
   Missing enter



##########
packages/scesim-editor/tests/e2e/features/keyboard/keyboard.spec.ts:
##########
@@ -0,0 +1,70 @@
+/*
+ * 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 { AssetType } from "../../__fixtures__/editor";
+import { AddRowPosition, Type } from "../../__fixtures__/table";
+
+test.describe("Keyboard", () => {
+  test.describe("Keyboard-Shortcuts Navigation", () => {
+    test("should correctly navigate the page using keyboard shortcuts", async 
({
+      editor,
+      table,
+      testScenarioTable,
+    }) => {
+      await editor.createTestScenario(AssetType.RULE);
+      await table.addRow({ targetCell: "1", position: AddRowPosition.BELOW });
+      await table.addRow({ targetCell: "1", position: AddRowPosition.BELOW });
+      await table.addRow({ targetCell: "1", position: AddRowPosition.BELOW });
+      await table.selectCell({ rowNumber: "1", columnNumber: 0 });
+      await table.navigateRight({ rowNumber: "1", columnNumber: 0, type: 
Type.KEYBOARD_SHORTCUT });
+      await 
expect(testScenarioTable.get()).toHaveScreenshot("navigation-screenshot-right.png",
 {
+        maxDiffPixels: 1000,

Review Comment:
   Why the `maxDiffPixels` is necessary?



-- 
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