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


##########
packages/boxed-expression-component/tests-e2e/__fixtures__/boxedExpression.ts:
##########
@@ -17,20 +17,30 @@
  * under the License.
  */
 
-import { Locator, Page } from "@playwright/test";
+import { Page } from "@playwright/test";
 import { Monaco } from "./monaco";
 
+import { ExpressionContainer } from "../api/expressionContainer";
+import { SelectExpressionMenu } from "../api/expressions/selectExpressionMenu";
+
 export class BoxedExpressionEditor {
+  private readonly _selectExpressionMenu: SelectExpressionMenu;
+
   constructor(
     public page: Page,
     private monaco: Monaco,
     public baseURL?: string
   ) {
     this.page = page;
+    this._selectExpressionMenu = new SelectExpressionMenu(page);
+  }
+
+  get selectExpressionMenu(): SelectExpressionMenu {
+    return this._selectExpressionMenu;
   }
 
-  public async select(from: Page | Locator = this.page) {
-    await from.getByText("Select expression").click();
+  get expression() {
+    return new 
ExpressionContainer(this.page.getByTestId("expression-container").nth(0), 
this.monaco);

Review Comment:
   It's using a `data-testid` without the narrowed scope.



##########
packages/boxed-expression-component/tests-e2e/api/expressions/contextExpressionElement.ts:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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 { ChildExpression } from "../expressionContainer";
+import { NameAndDataTypeCell } from "../nameAndDataTypeCell";
+
+export class ContextExpressionElement {
+  constructor(
+    private locator: Locator,
+    private monaco: Monaco
+  ) {}
+
+  public entry(index: number) {
+    return new ContextExpressionEntry(
+      
this.locator.getByTestId(`kie-tools--bee--expression-row-${index}`).nth(0),
+      this.monaco
+    );
+  }
+
+  get result() {
+    return new ChildExpression(this.locator.locator(`.additional-row`).nth(0), 
this.monaco);

Review Comment:
   As mentioned on the previous review we should avoid class locators. Can't we 
use a `data-testid` for this case?



##########
packages/boxed-expression-component/tests-e2e/api/nameAndDataTypeCell.ts:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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 { ContextMenu } from "./expressionContainer";
+
+export class NameAndDataTypeCell {
+  constructor(private locator: Locator) {}
+
+  async open() {
+    await this.locator.nth(0).click();
+  }
+
+  async setName(params: { name: string; close: boolean }) {
+    await this.locator.getByRole("textbox").fill(params.name);
+    if (params.close) {
+      await this.locator.getByRole("textbox").press("Enter");
+    }
+  }
+
+  async setDataType(params: { dataType: string; close: boolean }) {
+    await this.locator.locator(".pf-c-select").click();
+    await this.locator.locator(".pf-m-search").nth(0).fill(params.dataType);
+    await 
this.locator.getByRole("group").nth(0).getByRole("option").nth(0).click();
+    if (params.close) {
+      await this.locator.page().keyboard.press("Enter");
+    }
+  }
+
+  async getName() {
+    return await 
this.locator.locator(".expression-info-name").nth(0).innerText();
+  }
+
+  async getDataType() {
+    return await 
this.locator.locator(".expression-info-data-type").nth(0).innerText();
+  }

Review Comment:
   `class` locators.



##########
packages/boxed-expression-component/tests-e2e/api/expressionContainer.ts:
##########
@@ -0,0 +1,182 @@
+/*
+ * 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 { ContextExpressionElement } from 
"./expressions/contextExpressionElement";
+import { Monaco } from "../__fixtures__/monaco";
+import { LiteralExpressionElement } from 
"./expressions/literalExpressionElement";
+import { ExpressionHeader } from "./expressionHeader";
+import { SelectExpressionMenu } from "./expressions/selectExpressionMenu";
+import { DecisionTableExpressionElement } from 
"./expressions/decisionTableExpressionElement";
+import { FilterExpressionElement } from 
"./expressions/filterExpressionElement";
+import { RelationExpressionElement } from 
"./expressions/relationExpressionElement";
+import { ListExpressionElement } from "./expressions/listExpressionElement";
+import { ForExpressionElement } from "./expressions/forExpressionElement";
+import { EveryExpressionElement } from "./expressions/everyExpressionElement";
+import { SomeExpressionElement } from "./expressions/someExpressionElement";
+import { ConditionalExpressionElement } from 
"./expressions/conditionalExpressionElement";
+import { FunctionExpressionElement } from 
"./expressions/functionExpressionElement";
+import { InvocationExpressionElement } from 
"./expressions/invocationExpressionElement";
+import { NameAndDataTypeCell } from "./nameAndDataTypeCell";
+
+export class ExpressionContainer {
+  constructor(
+    protected locator: Locator,
+    protected monaco: Monaco
+  ) {}
+
+  get header() {
+    return new ExpressionHeader(this.locator);
+  }
+
+  asLiteral() {
+    return new LiteralExpressionElement(this.locator, this.monaco);
+  }
+
+  asRelation() {
+    return new RelationExpressionElement(this.locator, this.monaco);
+  }
+
+  asContext() {
+    return new ContextExpressionElement(this.locator, this.monaco);
+  }
+
+  asDecisionTable() {
+    return new DecisionTableExpressionElement(this.locator, this.monaco);
+  }
+
+  asList() {
+    return new ListExpressionElement(this.locator, this.monaco);
+  }
+
+  asInvocation() {
+    return new InvocationExpressionElement(this.locator, this.monaco);
+  }
+
+  asFunction() {
+    return new FunctionExpressionElement(this.locator, this.monaco);
+  }
+
+  asConditional() {
+    return new ConditionalExpressionElement(this.locator, this.monaco);
+  }
+
+  asFor() {
+    return new ForExpressionElement(this.locator, this.monaco);
+  }
+
+  asEvery() {
+    return new EveryExpressionElement(this.locator, this.monaco);
+  }
+
+  asSome() {
+    return new SomeExpressionElement(this.locator, this.monaco);
+  }
+
+  asFilter() {
+    return new FilterExpressionElement(this.locator, this.monaco);
+  }
+
+  get contextMenu() {
+    return new ContextMenu(this.locator.nth(0));
+  }
+
+  async isEmpty() {
+    return (await 
this.locator.nth(0).locator(">.logic-type-not-present").count()) === 1;
+  }
+}
+
+export class ExpressionCell {
+  constructor(
+    private locator: Locator,
+    private monaco: Monaco
+  ) {}
+
+  async fill(content: string) {
+    return await this.monaco.fill({ monacoParentLocator: this.locator, 
content: content });
+  }
+
+  get content() {
+    return this.locator.nth(0);
+  }
+
+  get contextMenu() {
+    return new ContextMenu(this.locator);
+  }
+}
+
+export class ContextMenu {
+  constructor(private locator: Locator) {}
+
+  public async open() {
+    await this.locator.nth(0).click({ button: "right" });
+  }
+
+  heading(sectionName: string) {
+    return this.locator.page().getByRole("heading", { name: sectionName });
+  }
+
+  option(option: string) {
+    return 
this.locator.page().locator(".context-menu-container").getByRole("menuitem", {
+      name: option,
+      exact: true,
+    });
+  }
+
+  button(option: string) {
+    return 
this.locator.page().locator(".context-menu-container").getByRole("button", { 
name: option, exact: true });
+  }
+
+  radio(option: string) {
+    return 
this.locator.page().locator(".context-menu-container").getByRole("radio", { 
name: option, exact: true });
+  }
+}

Review Comment:
   same.



##########
packages/boxed-expression-component/tests-e2e/api/expressions/decisionTableExpressionElement.ts:
##########
@@ -0,0 +1,327 @@
+/*
+ * 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";
+import { NameAndDataTypeCell } from "../nameAndDataTypeCell";
+
+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(`kie-tools--bee--expression-row-${coordinate.row - 1}`)
+        .getByTestId(`kie-tools--bee--expression-column-${coordinate.column}`),
+      this.monaco
+    );
+  }
+
+  get hitTableSelector() {
+    return new HitTableSelector(this.locator.getByRole("columnheader").nth(0));
+  }
+
+  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 addRowAtTop() {

Review Comment:
   Why we don't have a `addRowAtTopOfIndex`?



##########
packages/boxed-expression-component/src/expressions/LiteralExpression/LiteralExpression.tsx:
##########
@@ -209,7 +209,7 @@ export function LiteralExpression({
   }, []);
 
   return (
-    <div className={`literal-expression`}>
+    <div className={`literal-expression`} 
data-testid={`literal-expression-${id}`}>

Review Comment:
   This is still missing the narrowed `data-testid` scope.



##########
packages/boxed-expression-component/tests-e2e/boxedExpressions/filter/populate.spec.ts:
##########
@@ -20,7 +20,7 @@
 import { test, expect } from "../../__fixtures__/base";
 
 test.describe("Populate Boxed Filter", () => {
-  test("should correctly create a Rebooked Flights filter", async ({ stories, 
page, boxedExpressionEditor }) => {
+  test("should correctly create a Rebooked Flights filter", async ({ stories, 
page, bee }) => {

Review Comment:
   It's not using the new API.
   
   



##########
packages/boxed-expression-component/stories/getDefaultBoxedExpressionForStories.ts:
##########
@@ -253,6 +257,66 @@ export function getDefaultBoxedExpressionForStories({
     };
     widthsById.set(filterExpression["@_id"]!, [FILTER_EXPRESSION_MIN_WIDTH]);
     return filterExpression;
+  } else if (logicType === "conditional") {
+    const conditionalExpression: BoxedConditional = {
+      __$$element: "conditional",
+      "@_id": generateUuid(),
+      if: {
+        "@_id": generateUuid(),
+        expression: undefined as any,

Review Comment:
   Here is still with `as any`, making it different than the other expressions 
that use the `undefined!` 



##########
packages/boxed-expression-component/tests-e2e/api/expressions/filterExpressionElement.ts:
##########


Review Comment:
   The `data-testid` here uses another pattern. It uses 
`kie-tools--boxed-expression-component--` instead of `kie-tools--bee--` of 
another files. Please stick with one.



##########
packages/boxed-expression-component/tests-e2e/boxedExpressions/context/populate.spec.ts:
##########
@@ -17,14 +17,14 @@
  * under the License.
  */
 
-import { test, expect } from "../../__fixtures__/base";
+import { expect, test } from "../../__fixtures__/base";
 import { TestAnnotations } from "@kie-tools/playwright-base/annotations";
 
 test.describe("Populate Boxed Context", () => {
   test("should correctly create pre-bureau risk category boxed context", async 
({

Review Comment:
   It's not using the new API.



##########
packages/boxed-expression-component/tests-e2e/api/expressions/decisionTableExpressionElement.ts:
##########


Review Comment:
   This file has several `class` locators. The previous comment applies for 
this entire file. Why can't we use `data-testid` locators?



##########
packages/boxed-expression-component/tests-e2e/api/expressionContainer.ts:
##########
@@ -0,0 +1,182 @@
+/*
+ * 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 { ContextExpressionElement } from 
"./expressions/contextExpressionElement";
+import { Monaco } from "../__fixtures__/monaco";
+import { LiteralExpressionElement } from 
"./expressions/literalExpressionElement";
+import { ExpressionHeader } from "./expressionHeader";
+import { SelectExpressionMenu } from "./expressions/selectExpressionMenu";
+import { DecisionTableExpressionElement } from 
"./expressions/decisionTableExpressionElement";
+import { FilterExpressionElement } from 
"./expressions/filterExpressionElement";
+import { RelationExpressionElement } from 
"./expressions/relationExpressionElement";
+import { ListExpressionElement } from "./expressions/listExpressionElement";
+import { ForExpressionElement } from "./expressions/forExpressionElement";
+import { EveryExpressionElement } from "./expressions/everyExpressionElement";
+import { SomeExpressionElement } from "./expressions/someExpressionElement";
+import { ConditionalExpressionElement } from 
"./expressions/conditionalExpressionElement";
+import { FunctionExpressionElement } from 
"./expressions/functionExpressionElement";
+import { InvocationExpressionElement } from 
"./expressions/invocationExpressionElement";
+import { NameAndDataTypeCell } from "./nameAndDataTypeCell";
+
+export class ExpressionContainer {
+  constructor(
+    protected locator: Locator,
+    protected monaco: Monaco
+  ) {}
+
+  get header() {
+    return new ExpressionHeader(this.locator);
+  }
+
+  asLiteral() {
+    return new LiteralExpressionElement(this.locator, this.monaco);
+  }
+
+  asRelation() {
+    return new RelationExpressionElement(this.locator, this.monaco);
+  }
+
+  asContext() {
+    return new ContextExpressionElement(this.locator, this.monaco);
+  }
+
+  asDecisionTable() {
+    return new DecisionTableExpressionElement(this.locator, this.monaco);
+  }
+
+  asList() {
+    return new ListExpressionElement(this.locator, this.monaco);
+  }
+
+  asInvocation() {
+    return new InvocationExpressionElement(this.locator, this.monaco);
+  }
+
+  asFunction() {
+    return new FunctionExpressionElement(this.locator, this.monaco);
+  }
+
+  asConditional() {
+    return new ConditionalExpressionElement(this.locator, this.monaco);
+  }
+
+  asFor() {
+    return new ForExpressionElement(this.locator, this.monaco);
+  }
+
+  asEvery() {
+    return new EveryExpressionElement(this.locator, this.monaco);
+  }
+
+  asSome() {
+    return new SomeExpressionElement(this.locator, this.monaco);
+  }
+
+  asFilter() {
+    return new FilterExpressionElement(this.locator, this.monaco);
+  }
+
+  get contextMenu() {
+    return new ContextMenu(this.locator.nth(0));
+  }
+
+  async isEmpty() {
+    return (await 
this.locator.nth(0).locator(">.logic-type-not-present").count()) === 1;

Review Comment:
   `class` locator



##########
packages/boxed-expression-component/tests-e2e/boxedExpressions/context/contextExpression.spec.ts:
##########
@@ -17,17 +17,17 @@
  * under the License.
  */
 
-import { test, expect } from "../../__fixtures__/base";
+import { expect, test } from "../../__fixtures__/base";
 
 test.describe("Create Boxed Context", () => {
-  test("should render expression correctly", async ({ boxedExpressionEditor, 
stories, page }) => {
+  test("should render expression correctly", async ({ bee, stories, page }) => 
{
     await stories.openBoxedContext();
     await expect(page.getByRole("columnheader", { name: "Expression Name 
(<Undefined>)" })).toBeAttached();
     await expect(page.getByRole("cell", { name: "ContextEntry-1 (<Undefined>)" 
})).toBeAttached();
     await expect(page.getByRole("cell", { name: "<result>" })).toBeAttached();
     await expect(page.getByText("Select expression")).toHaveCount(2);
     await expect(page.getByRole("columnheader")).toHaveCount(1);
     await expect(page.getByRole("cell")).toHaveCount(4);
-    await 
expect(boxedExpressionEditor.getContainer()).toHaveScreenshot("boxed-context.png");
+    await expect(bee.getContainer()).toHaveScreenshot("boxed-context.png");
   });
 });

Review Comment:
   It's not using the new API.



##########
packages/boxed-expression-component/tests-e2e/api/expressionContainer.ts:
##########
@@ -0,0 +1,182 @@
+/*
+ * 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 { ContextExpressionElement } from 
"./expressions/contextExpressionElement";
+import { Monaco } from "../__fixtures__/monaco";
+import { LiteralExpressionElement } from 
"./expressions/literalExpressionElement";
+import { ExpressionHeader } from "./expressionHeader";
+import { SelectExpressionMenu } from "./expressions/selectExpressionMenu";
+import { DecisionTableExpressionElement } from 
"./expressions/decisionTableExpressionElement";
+import { FilterExpressionElement } from 
"./expressions/filterExpressionElement";
+import { RelationExpressionElement } from 
"./expressions/relationExpressionElement";
+import { ListExpressionElement } from "./expressions/listExpressionElement";
+import { ForExpressionElement } from "./expressions/forExpressionElement";
+import { EveryExpressionElement } from "./expressions/everyExpressionElement";
+import { SomeExpressionElement } from "./expressions/someExpressionElement";
+import { ConditionalExpressionElement } from 
"./expressions/conditionalExpressionElement";
+import { FunctionExpressionElement } from 
"./expressions/functionExpressionElement";
+import { InvocationExpressionElement } from 
"./expressions/invocationExpressionElement";
+import { NameAndDataTypeCell } from "./nameAndDataTypeCell";
+
+export class ExpressionContainer {
+  constructor(
+    protected locator: Locator,
+    protected monaco: Monaco
+  ) {}
+
+  get header() {
+    return new ExpressionHeader(this.locator);
+  }
+
+  asLiteral() {
+    return new LiteralExpressionElement(this.locator, this.monaco);
+  }
+
+  asRelation() {
+    return new RelationExpressionElement(this.locator, this.monaco);
+  }
+
+  asContext() {
+    return new ContextExpressionElement(this.locator, this.monaco);
+  }
+
+  asDecisionTable() {
+    return new DecisionTableExpressionElement(this.locator, this.monaco);
+  }
+
+  asList() {
+    return new ListExpressionElement(this.locator, this.monaco);
+  }
+
+  asInvocation() {
+    return new InvocationExpressionElement(this.locator, this.monaco);
+  }
+
+  asFunction() {
+    return new FunctionExpressionElement(this.locator, this.monaco);
+  }
+
+  asConditional() {
+    return new ConditionalExpressionElement(this.locator, this.monaco);
+  }
+
+  asFor() {
+    return new ForExpressionElement(this.locator, this.monaco);
+  }
+
+  asEvery() {
+    return new EveryExpressionElement(this.locator, this.monaco);
+  }
+
+  asSome() {
+    return new SomeExpressionElement(this.locator, this.monaco);
+  }
+
+  asFilter() {
+    return new FilterExpressionElement(this.locator, this.monaco);
+  }
+
+  get contextMenu() {
+    return new ContextMenu(this.locator.nth(0));
+  }
+
+  async isEmpty() {
+    return (await 
this.locator.nth(0).locator(">.logic-type-not-present").count()) === 1;
+  }
+}
+
+export class ExpressionCell {
+  constructor(
+    private locator: Locator,
+    private monaco: Monaco
+  ) {}
+
+  async fill(content: string) {
+    return await this.monaco.fill({ monacoParentLocator: this.locator, 
content: content });
+  }
+
+  get content() {
+    return this.locator.nth(0);
+  }
+
+  get contextMenu() {
+    return new ContextMenu(this.locator);
+  }
+}
+
+export class ContextMenu {
+  constructor(private locator: Locator) {}
+
+  public async open() {
+    await this.locator.nth(0).click({ button: "right" });
+  }
+
+  heading(sectionName: string) {
+    return this.locator.page().getByRole("heading", { name: sectionName });
+  }
+
+  option(option: string) {
+    return 
this.locator.page().locator(".context-menu-container").getByRole("menuitem", {
+      name: option,
+      exact: true,
+    });
+  }
+
+  button(option: string) {
+    return 
this.locator.page().locator(".context-menu-container").getByRole("button", { 
name: option, exact: true });
+  }
+
+  radio(option: string) {
+    return 
this.locator.page().locator(".context-menu-container").getByRole("radio", { 
name: option, exact: true });
+  }
+}
+
+export class ChildExpression {
+  private readonly _expression: ExpressionContainer;
+
+  public constructor(
+    private locator: Locator,
+    monaco: Monaco
+  ) {
+    this._expression = new 
ExpressionContainer(this.locator.getByTestId("expression-container").nth(0), 
monaco);
+  }
+
+  get expression() {
+    return this._expression;
+  }
+
+  get selectExpressionMenu() {
+    return new 
SelectExpressionMenu(this.locator.getByTestId("expression-container").nth(0));
+  }
+}

Review Comment:
   missing narrowed scope



##########
packages/boxed-expression-component/tests-e2e/boxedExpressions/context/contextMenu.spec.ts:
##########
@@ -17,122 +17,130 @@
  * under the License.
  */
 
-import { test, expect } from "../../__fixtures__/base";
-import { TestAnnotations } from "@kie-tools/playwright-base/annotations";
+import { expect, test } from "../../__fixtures__/base";
 
 test.describe("Boxed Context context menu", () => {
   test.describe("context entry control", () => {
-    test.beforeEach(async ({ stories, page, monaco, boxedExpressionEditor }) 
=> {
+    test.beforeEach(async ({ stories }) => {
       await stories.openBoxedContext();
-      await boxedExpressionEditor.selectBoxedLiteral(page.getByRole("row", { 
name: "ContextEntry-1 (<Undefined>)" }));
-      await monaco.fill({ monacoParentLocator: page, content: '"test"' });
     });
 
-    test("should't render selection context menu", async ({ page }) => {
-      await page.getByRole("cell", { name: "ContextEntry-1" }).click({ button: 
"right" });
-      await expect(page.getByRole("heading", { name: "CONTEXT ENTRY" 
})).toBeAttached();
-      await expect(page.getByRole("heading", { name: "SELECTION" 
})).toBeAttached();
+    test("shouldn't render selection context menu", async ({ bee }) => {
+      const entry = bee.expression.asContext().entry(0);
+      await entry.selectExpressionMenu.selectLiteral();
+      await entry.expression.asLiteral().fill("test");
+
+      await entry.variable.contextMenu.open();
+
+      await expect(entry.variable.contextMenu.heading("CONTEXT 
ENTRY")).toBeAttached();
+      await 
expect(entry.variable.contextMenu.heading("SELECTION")).toBeAttached();
     });
 
-    test("shouldn't render context entry context menu", async ({ page }) => {
-      await page.getByRole("columnheader", { name: "Expression Name 
(<Undefined>)" }).click({ button: "right" });
-      await expect(page.getByRole("heading", { name: "CONTEXT ENTRY" 
})).not.toBeAttached();
-      await expect(page.getByRole("heading", { name: "SELECTION" 
})).toBeAttached();
-      await expect(page.getByRole("heading", { name: "COLUMNS" 
})).not.toBeAttached();
-      await page.keyboard.press("Escape");
+    test("shouldn't render context entry context menu", async ({ page, bee }) 
=> {
+      const expressionHeaderCell = 
bee.expression.asContext().expressionHeaderCell;
+      await 
bee.expression.asContext().entry(0).selectExpressionMenu.selectLiteral();
+      await expressionHeaderCell.contextMenu.open();
 
-      await page.getByTestId("monaco-container").click({ button: "right" });
-      await expect(page.getByRole("heading", { name: "CONTEXT ENTRY" 
})).not.toBeAttached();
-      await expect(page.getByRole("heading", { name: "SELECTION" 
})).toBeAttached();
-      await expect(page.getByRole("heading", { name: "COLUMNS" 
})).not.toBeAttached();
+      await expect(expressionHeaderCell.contextMenu.heading("CONTEXT 
ENTRY")).not.toBeAttached();
+      await 
expect(expressionHeaderCell.contextMenu.heading("SELECTION")).toBeAttached();
+      await 
expect(expressionHeaderCell.contextMenu.heading("COLUMNS")).not.toBeAttached();
+
+      const entry = bee.expression.asContext().entry(0);

Review Comment:
   We couldn't create only one variable for this case? On the start of the test 
`const contextExpression = bee.expression.asContext()`.



##########
packages/boxed-expression-component/tests-e2e/boxedExpressions/decisionTable/decisionTableExpression.spec.ts:
##########
@@ -17,28 +17,24 @@
  * under the License.
  */
 
-import { test, expect } from "../../__fixtures__/base";
+import { expect, test } from "../../__fixtures__/base";
 
 test.describe("Create Decision table", () => {
   test.beforeEach(async ({ stories }) => {
     await stories.openDecisionTable();
   });
 
-  test("should render expression correctly", async ({ boxedExpressionEditor, 
page }) => {
+  test("should render expression correctly", async ({ bee, page }) => {

Review Comment:
   It's not using the new API.



##########
packages/boxed-expression-component/tests-e2e/boxedExpressions/decisionTable/contextMenu.spec.ts:
##########


Review Comment:
   Each test creates a few different variables. Why not use `const 
decisionTable = bee.expression.asDecisionTable()` at the top of the test, and 
the operations and assertions use this `decisionTable`?



##########
packages/boxed-expression-component/tests-e2e/boxedExpressions/filter/filterExpression.spec.ts:
##########
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-import { test, expect } from "../../__fixtures__/base";
+import { expect, test } from "../../__fixtures__/base";
 
 test.describe("Create Boxed Filter", () => {
   test("should rename a filter", async ({ page, stories }) => {

Review Comment:
   It's not using the new API.
   
   



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