vatsrahul1001 commented on code in PR #61908:
URL: https://github.com/apache/airflow/pull/61908#discussion_r2811431015


##########
airflow-core/src/airflow/ui/tests/e2e/pages/ConfigsPage.ts:
##########
@@ -0,0 +1,95 @@
+/*!
+ * 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 type { Locator, Page } from "@playwright/test";
+
+import { BasePage } from "./BasePage";
+
+export class ConfigsPage extends BasePage {
+  public readonly forbiddenStatus: Locator;
+  public readonly heading: Locator;
+  public readonly rows: Locator;
+  public readonly table: Locator;
+
+  public constructor(page: Page) {
+    super(page);
+    this.heading = page.getByRole("heading", { name: /configuration/i });
+    this.table = page.getByTestId("table-list");
+    this.forbiddenStatus = page.getByText(/403 forbidden/i);
+    this.rows = this.table.locator("tbody tr").filter({
+      has: page.locator("td"),
+    });
+  }
+
+  public async getColumnNames(): Promise<Array<string>> {
+    return this.table.locator("thead th").allTextContents();
+  }
+
+  public async getRowCount(): Promise<number> {
+    return this.rows.count();
+  }
+
+  public async getRowDetails(index: number): Promise<{ key: string; section: 
string; value: string }> {
+    const row = this.rows.nth(index);
+    const cells = row.locator("td");
+
+    const section = await cells.nth(0).textContent();
+    const key = await cells.nth(1).textContent();
+    const value = await cells.nth(2).textContent();
+
+    return {
+      key: (key ?? "").trim(),
+      section: (section ?? "").trim(),
+      value: (value ?? "").trim(),
+    };
+  }
+
+  public async hasSectionAndKey(section: string, key: string): 
Promise<boolean> {
+    const sectionLower = section.toLowerCase();
+    const keyLower = key.toLowerCase();
+    const rowCount = await this.getRowCount();
+
+    for (let i = 0; i < rowCount; i++) {
+      const row = await this.getRowDetails(i);
+
+      if (row.section.toLowerCase() === sectionLower && row.key.toLowerCase() 
=== keyLower) {
+        return true;
+      }
+    }
+
+    return false;
+  }
+
+  public async navigate(path = "/configs"): Promise<void> {
+    await this.navigateTo(path);
+  }
+
+  public async waitForLoad(): Promise<void> {
+    await this.heading.waitFor({ state: "visible", timeout: 30_000 });
+    await this.page.waitForFunction(

Review Comment:
   We can just use
   
   `await expect(this.table.or(this.forbiddenStatus)).toBeVisible({ timeout: 
30_000 });`



##########
airflow-core/src/airflow/ui/tests/e2e/README.md:
##########
@@ -112,6 +112,12 @@ Environment variables (with defaults):
 - `TEST_USERNAME` - Username (default: `airflow`)
 - `TEST_PASSWORD` - Password (default: `airflow`)
 - `TEST_DAG_ID` - Test DAG ID (default: `example_bash_operator`)

Review Comment:
   Why do we need so many config? I think only 
`TEST_CONFIG_PAGE_EXPECTS_TABLE_DATA ` might be required



##########
airflow-core/src/airflow/ui/playwright.config.ts:
##########
@@ -24,8 +24,15 @@ export const testConfig = {
   asset: {
     name: process.env.TEST_ASSET_NAME ?? "s3://dag1/output_1.txt",
   },
-  connection: {
-    baseUrl: process.env.AIRFLOW_UI_BASE_URL ?? "http://localhost:28080";,

Review Comment:
   Why have we removed this?



##########
airflow-core/src/airflow/ui/tests/e2e/pages/ConfigsPage.ts:
##########
@@ -0,0 +1,95 @@
+/*!
+ * 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 type { Locator, Page } from "@playwright/test";
+
+import { BasePage } from "./BasePage";
+
+export class ConfigsPage extends BasePage {
+  public readonly forbiddenStatus: Locator;
+  public readonly heading: Locator;
+  public readonly rows: Locator;
+  public readonly table: Locator;
+
+  public constructor(page: Page) {
+    super(page);
+    this.heading = page.getByRole("heading", { name: /configuration/i });
+    this.table = page.getByTestId("table-list");
+    this.forbiddenStatus = page.getByText(/403 forbidden/i);
+    this.rows = this.table.locator("tbody tr").filter({
+      has: page.locator("td"),
+    });
+  }
+
+  public async getColumnNames(): Promise<Array<string>> {
+    return this.table.locator("thead th").allTextContents();
+  }
+
+  public async getRowCount(): Promise<number> {
+    return this.rows.count();
+  }
+
+  public async getRowDetails(index: number): Promise<{ key: string; section: 
string; value: string }> {
+    const row = this.rows.nth(index);
+    const cells = row.locator("td");
+
+    const section = await cells.nth(0).textContent();
+    const key = await cells.nth(1).textContent();
+    const value = await cells.nth(2).textContent();
+
+    return {
+      key: (key ?? "").trim(),
+      section: (section ?? "").trim(),
+      value: (value ?? "").trim(),
+    };
+  }
+
+  public async hasSectionAndKey(section: string, key: string): 
Promise<boolean> {

Review Comment:
   Should use filter
   
   ```
   public async hasSectionAndKey(section: string, key: string): 
Promise<boolean> {
     const row = this.rows.filter({ hasText: section }).filter({ hasText: key 
});
     return (await row.count()) > 0;
   }
   ```



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

Reply via email to