danielzhe commented on code in PR #2456:
URL: 
https://github.com/apache/incubator-kie-tools/pull/2456#discussion_r1662487963


##########
packages/boxed-expression-component/tests-e2e/api/contextExpressionElement.ts:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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 { Locator } from "@playwright/test";
+import { Monaco } from "../__fixtures__/monaco";
+
+import { ExpressionElementEntry } from "./expressionContainer";
+
+export class ContextExpressionElement {
+  constructor(
+    private locator: Locator,
+    private monaco: Monaco
+  ) {}
+
+  public expressionsContainers() {
+    return this.locator.getByTestId("expression-container");
+  }
+
+  public entry(index: number) {
+    return new ExpressionElementEntry(this.expressionsContainers().nth(index), 
this.monaco);
+  }
+
+  async addEntry() {
+    await this.locator
+      .getByRole("cell", { name: "ContextEntry-1 (<Undefined>)" })
+      .nth(0)
+      .hover({
+        position: {
+          x: 0,
+          y: 0,
+        },
+      });
+    await this.locator.getByRole("cell", { name: "ContextEntry-1 
(<Undefined>)" }).nth(0).locator("svg").click();
+  }

Review Comment:
   This is an WIP, not a finished work.



##########
packages/boxed-expression-component/tests-e2e/api/filterExpressionElement.ts:
##########
@@ -0,0 +1,58 @@
+/*
+ * 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 { Locator } from "@playwright/test";
+import { Monaco } from "../__fixtures__/monaco";
+import { ExpressionElementEntry } from "./expressionContainer";
+
+export class FilterExpressionElement {
+  constructor(
+    private locator: Locator,
+    private monaco: Monaco
+  ) {}
+
+  get in() {
+    return new ExpressionElementEntry(
+      
this.locator.getByTestId("kie-tools--boxed-expression-component--filter-collection-in").nth(0),
+      this.monaco
+    );
+  }
+
+  get match() {
+    return new ExpressionElementEntry(
+      
this.locator.getByTestId("kie-tools--boxed-expression-component--filter-collection-match").nth(0),
+      this.monaco
+    );
+  }
+
+  public async fill(args: { collectionIn: any[]; collectionMatch: any }) {
+    for (let i = 0; i < args.collectionIn.length; i++) {
+      await this.monaco.fill({
+        monacoParentLocator: 
this.locator.getByTestId("kie-tools--boxed-expression-component--filter-collection-in"),
+        content: args.collectionIn[i],
+        nth: i,
+      });
+    }
+
+    await this.monaco.fill({
+      monacoParentLocator: 
this.locator.getByTestId("kie-tools--boxed-expression-component--filter-collection-match"),
+      content: args.collectionMatch,
+    });
+  }

Review Comment:
   We are using `fill` to fill Literal Expressions, which are, by definition, 
single cells where the user can write feel expressions. Can you explain again 
what is the issue? Sorry, I don't understand this comment.  @jomarko 



##########
packages/boxed-expression-component/tests-e2e/boxedExpressions/filter/filterExpression.spec.ts:
##########
@@ -41,53 +41,51 @@ test.describe("Create Boxed Filter", () => {
     await expect(page.getByRole("columnheader", { name: "Expression Name 
(boolean)" })).toBeVisible();
   });
 
-  test("should correctly reset a nested filter", async ({ 
boxedExpressionEditor, page, stories }) => {
+  test("should correctly reset a nested filter", async ({ bee, page, stories 
}) => {
     await stories.openBoxedFilter("nested");
 
-    await 
boxedExpressionEditor.resetFilter(page.getByTestId("expression-row-0"));
+    await bee.expression.asContext().entry(0).expression.header.reset();
 
-    await 
expect(boxedExpressionEditor.getContainer()).toHaveScreenshot("boxed-filter-nested-reset.png");
+    await 
expect(bee.getContainer()).toHaveScreenshot("boxed-filter-nested-reset.png");
   });
 
-  test("should correctly create a nested filter", async ({ 
boxedExpressionEditor, page, stories }) => {
+  test("should correctly create a nested filter", async ({ bee, page, stories 
}) => {

Review Comment:
   Yes. I'm going to finish the API first, then write new tests.
   I was just showing you an example. 



##########
packages/boxed-expression-component/tests-e2e/api/decisionTableExpressionElement.ts:
##########
@@ -0,0 +1,260 @@
+/*
+ * 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 { Locator } from "@playwright/test";
+import { Monaco } from "../__fixtures__/monaco";
+import { ExpressionCell } from "./expressionContainer";
+
+export class DecisionTableExpressionElement {
+  constructor(
+    private locator: Locator,
+    private monaco: Monaco
+  ) {}
+
+  public async fill(args: { startAtCell: number; tableData: any[][] }) {
+    let cellNumber = args.startAtCell;
+    for (const row of args.tableData) {
+      for (const cellData of row) {
+        if (cellData === "-") {
+          cellNumber++;
+          continue;
+        }
+        await this.monaco.fill({ monacoParentLocator: this.locator, content: 
cellData, nth: cellNumber });
+        cellNumber++;
+      }
+      cellNumber++;
+    }
+  }
+
+  /**
+   * Get the cell at the specific coordinate inside the Decision Table.
+   * The first index is 1, like seen in the screen, NOT zero.
+   * @param coordinate The coordinate (row x column). The first index is 1.
+   */
+  cellAt(coordinate: { row: number; column: number }) {
+    return new ExpressionCell(
+      this.locator
+        .getByTestId(`expression-row-${coordinate.row - 1}`)
+        .getByTestId(`expression-column-${coordinate.column}`),
+      this.monaco
+    );
+  }
+
+  async addInputAtStart() {
+    await this.addInputAtIndex(0);
+  }
+
+  async addInputAtEnd() {
+    await this.addInputAtIndex(await this.locator.locator(".input").count());
+  }
+
+  async addInputAtIndex(index: number) {
+    if (index === (await this.locator.locator(".input").count())) {
+      const bb = await this.locator
+        .locator(".input")
+        .nth(index - 1)
+        .boundingBox();
+      await this.locator
+        .locator(".input")
+        .nth(index - 1)
+        .hover({
+          position: {
+            x: (bb?.width ?? 0) / 2,
+            y: 0,
+          },
+        });
+      await this.locator
+        .locator(".input")
+        .nth(index - 1)
+        .locator("svg")
+        .click();
+    } else {
+      await this.locator
+        .locator(".input")
+        .nth(index)
+        .hover({
+          position: {
+            x: 0,
+            y: 0,
+          },
+        });
+      await this.locator.locator(".input").nth(index).locator("svg").click();
+    }
+  }
+
+  async addRow() {
+    await this.locator
+      .getByRole("cell", { name: "1", exact: true })
+      .nth(0)
+      .hover({
+        position: {
+          x: 0,
+          y: 0,
+        },
+      });
+    await this.locator.getByRole("cell", { name: "1", exact: true 
}).nth(0).locator("svg").click();
+  }
+
+  async addAnnotationAtStart() {
+    await this.addAnnotationAtIndex(0);
+  }
+
+  async addAnnotationAtEnd() {
+    await this.addAnnotationAtIndex(await 
this.locator.locator(".annotation").count());
+  }
+
+  async addAnnotationAtIndex(index: number) {
+    if (index === (await this.locator.locator(".annotation").count())) {
+      const bb = await this.locator
+        .locator(".annotation")
+        .nth(index - 1)
+        .boundingBox();
+      await this.locator
+        .locator(".annotation")
+        .nth(index - 1)
+        .hover({
+          position: {
+            x: (bb?.width ?? 0) / 2,
+            y: 0,
+          },
+        });
+      await this.locator
+        .locator(".annotation")
+        .nth(index - 1)
+        .locator("svg")
+        .click();
+    } else {
+      await this.locator
+        .locator(".annotation")
+        .nth(index)
+        .hover({
+          position: {
+            x: 0,
+            y: 0,
+          },
+        });
+      await 
this.locator.locator(".annotation").nth(index).locator("svg").click();
+    }
+  }
+
+  async addOutputAtStart() {
+    await this.addOutputAtIndex(0);
+  }
+
+  async addOutputAtEnd() {
+    await this.addOutputAtIndex(await this.locator.locator(".output").count());
+  }
+
+  // Consider the following scenario:
+  //
+  //  Expression Name
+  //   (<Undefined>)
+  // -------------------
+  // output-1 | output-2
+  //
+  // They're all outputs cells. So:
+  // locator(".output").count() = 3
+  // Expression Name Cell       = [0]
+  // output-1 cell              = [1]
+  // output-2 cell              = [2]
+  //
+  // So the header of group (Expression Name) is not considered from the user 
perspective,
+  // that's why we need to do the calculations bellow to find the right place 
where user really
+  // wants to add the output element.
+  async addOutputAtIndex(index: number) {
+    if ((await this.locator.locator(".output").count()) === 1) {
+      await this.addOutputFromHeaderGroupElementAtIndex(index);
+    } else if (index === (await this.locator.locator(".output").count())) {
+      // output-1 | output-2 | output-3
+      // index = 3
+      // user wants:
+      // output-1 | output-2 | output-3 | NEW-OUTPUT
+      await this.addOutputAtRightOfIndex(index - 1);
+    } else if (index + 1 === (await this.locator.locator(".output").count())) {
+      // output-1 | output-2 | output-3
+      // index = 2
+      // user wants:
+      // output-1 | output-2 | NEW-OUTPUT | output-3
+      await this.addOutputAtLeftOfIndex(index);
+    } else {
+      // output-1 | output-2 | output-3
+      // index = 1
+      // user wants:
+      // output-1 | NEW-OUTPUT | output-2 | output-3
+      await this.addOutputAtLeftOfIndex(index + 1);
+      // this is the same thing as await this.addOutputAtRightOfIndex(index);
+      // We can not use this.addOutputAtRightOfIndex(index) because index===0
+      // internally is the group element (Expression Name Cell).
+    }
+  }
+
+  private async addOutputAtRightOfIndex(index: number) {
+    const bb = await this.locator.locator(".output").nth(index).boundingBox();
+    await this.locator
+      .locator(".output")
+      .nth(index)
+      .hover({
+        position: {
+          x: (bb?.width ?? 0) / 2,
+          y: 0,
+        },
+      });
+    await this.locator.locator(".output").nth(index).locator("svg").click();
+  }
+
+  private async addOutputAtLeftOfIndex(index: number) {
+    await this.locator
+      .locator(".output")
+      .nth(index)
+      .hover({
+        position: {
+          x: 0,
+          y: 0,
+        },
+      });
+    await this.locator.locator(".output").nth(index).locator("svg").click();
+  }
+
+  private async addOutputFromHeaderGroupElementAtIndex(index: number) {

Review Comment:
   Yes, we don't have nothing to context menu yet.



##########
packages/boxed-expression-component/tests-e2e/api/functionExpressionElement.ts:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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 { Locator } from "@playwright/test";
+import { Monaco } from "../__fixtures__/monaco";
+import { ExpressionElementEntry } from "./expressionContainer";
+
+export class FunctionExpressionElement {
+  constructor(
+    private locator: Locator,
+    private monaco: Monaco
+  ) {}
+
+  async addEntry() {
+    await this.locator.getByRole("cell", { name: "1" }).nth(0).hover();
+    await this.locator.getByRole("cell", { name: "1" 
}).nth(0).locator("svg").click();
+  }

Review Comment:
   We can rename it.



##########
packages/boxed-expression-component/tests-e2e/api/invocationExpressionElement.ts:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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 { Locator } from "@playwright/test";
+import { Monaco } from "../__fixtures__/monaco";
+import { ExpressionElementEntry } from "./expressionContainer";
+
+export class InvocationExpressionElement {

Review Comment:
   WIP. 
   Check the ticket, there are a lot of tests that will be done and the API 
will evolve as they are getting implemented.
   https://github.com/apache/incubator-kie-issues/issues/1369



##########
packages/boxed-expression-component/tests-e2e/boxedExpressions/boxedExpressionHeader.spec.ts:
##########
@@ -36,19 +36,19 @@ test.describe("Boxed expression header", () => {
     await expect(page.getByText("Select expression")).toBeAttached();
   });
 
-  test("should copy, reset and paste expression", async ({ 
boxedExpressionEditor, page, clipboard }) => {
+  test("should copy, reset and paste expression", async ({ bee, page, 
clipboard }) => {
     await page.getByTestId("logic-type-button-test-id").click();
     clipboard.use();
     await page.getByRole("menuitem", { name: "copy" }).click();
     await page.getByTestId("logic-type-button-test-id").click();
     await page.getByRole("menuitem", { name: "Reset" }).click();
-    await boxedExpressionEditor.pasteToSelectExpression();
+    await bee.pasteToSelectExpression();

Review Comment:
   Yes. It is not done. See the ticket:
   https://github.com/apache/incubator-kie-issues/issues/1369



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