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


##########
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:
   Because it was not used in any test and I didn't notice I didn't do it.



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