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


##########
airflow-core/src/airflow/ui/tests/e2e/pages/XComsPage.ts:
##########
@@ -0,0 +1,192 @@
+/*!
+ * 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, type Locator, type Page } from "@playwright/test";
+import { BasePage } from "tests/e2e/pages/BasePage";
+
+export class XComsPage extends BasePage {
+  public static get xcomsUrl(): string {
+    return "/xcoms";
+  }
+
+  public readonly collapseAllButton: Locator;
+  public readonly expandAllButton: Locator;
+  public readonly xcomsTable: Locator;
+
+  public constructor(page: Page) {
+    super(page);
+    this.collapseAllButton = page.getByRole("button", { name: /collapse/i });
+    this.expandAllButton = page.getByRole("button", { name: /expand/i });
+    this.xcomsTable = page.locator('table, div[role="table"]');
+  }
+
+  public async navigate(): Promise<void> {
+    await this.navigateTo(XComsPage.xcomsUrl);
+    await this.page.waitForURL(/.*xcoms/, { timeout: 15_000 });
+    await this.xcomsTable.waitFor({ state: "visible", timeout: 10_000 });
+
+    const dataLink = this.xcomsTable.locator("a[href*='/dags/']").first();
+    const noDataMessage = 
this.page.locator("text=/no.*xcom|no.*data|no.*entries/i");
+
+    await expect(dataLink.or(noDataMessage)).toBeVisible({ timeout: 30_000 });
+  }
+
+  public async verifyDagDisplayNameFiltering(dagDisplayNamePattern: string): 
Promise<void> {
+    await this.navigateTo(
+      
`${XComsPage.xcomsUrl}?dag_display_name_pattern=${encodeURIComponent(dagDisplayNamePattern)}`,
+    );
+    await this.page.waitForURL(/.*dag_display_name_pattern=.*/, { timeout: 
15_000 });
+    await this.page.waitForLoadState("networkidle");
+
+    const dataLinks = this.xcomsTable.locator("a[href*='/dags/']");
+
+    await expect(dataLinks.first()).toBeVisible({ timeout: 30_000 });
+    await expect(this.xcomsTable).toBeVisible();
+
+    const rows = this.xcomsTable.locator("tbody tr");
+    const rowCount = await rows.count();
+
+    expect(rowCount).toBeGreaterThan(0);
+
+    for (let i = 0; i < Math.min(rowCount, 3); i++) {
+      const dagIdLink = rows.nth(i).locator("a[href*='/dags/']").first();
+      const dagDisplayName = await dagIdLink.textContent();
+
+      
expect(dagDisplayName?.toLowerCase()).toContain(dagDisplayNamePattern.toLowerCase());
+    }
+  }
+
+  public async verifyExpandCollapse(): Promise<void> {
+    await this.navigate();
+
+    await expect(this.expandAllButton.first()).toBeVisible({ timeout: 5000 });
+    await this.expandAllButton.first().click();
+    await this.page.waitForTimeout(500);
+
+    await expect(this.collapseAllButton.first()).toBeVisible({ timeout: 5000 
});
+    await this.collapseAllButton.first().click();
+    await this.page.waitForTimeout(500);
+  }
+
+  public async verifyKeyPatternFiltering(keyPattern: string): Promise<void> {
+    await 
this.navigateTo(`${XComsPage.xcomsUrl}?key_pattern=${encodeURIComponent(keyPattern)}`);
+    await this.page.waitForURL(/.*key_pattern=.*/, { timeout: 15_000 });
+    await this.page.waitForLoadState("networkidle");
+
+    const dataLinks = this.xcomsTable.locator("a[href*='/dags/']");
+
+    await expect(dataLinks.first()).toBeVisible({ timeout: 30_000 });
+    await expect(this.xcomsTable).toBeVisible();
+
+    const rows = this.xcomsTable.locator("tbody tr");
+    const rowCount = await rows.count();
+
+    expect(rowCount).toBeGreaterThan(0);
+
+    for (let i = 0; i < Math.min(rowCount, 3); i++) {
+      const keyCell = rows.nth(i).locator("td").first();
+      const keyText = await keyCell.textContent();
+
+      expect(keyText?.toLowerCase()).toContain(keyPattern.toLowerCase());
+    }
+  }
+
+  public async verifyPagination(limit: number): Promise<void> {
+    await this.navigateTo(`${XComsPage.xcomsUrl}?offset=0&limit=${limit}`);
+    await this.page.waitForURL(/.*limit=/, { timeout: 10_000 });
+    await this.page.waitForLoadState("networkidle");
+    await this.xcomsTable.waitFor({ state: "visible", timeout: 10_000 });
+
+    const dataLinks = this.xcomsTable.locator("a[href*='/dags/']");
+
+    await expect(dataLinks.first()).toBeVisible({ timeout: 30_000 });
+
+    const rows = this.xcomsTable.locator("tbody tr");
+
+    expect(await rows.count()).toBeGreaterThan(0);
+
+    const paginationNav = this.page.locator('nav[aria-label="pagination"], 
[role="navigation"]');
+
+    await expect(paginationNav.first()).toBeVisible({ timeout: 10_000 });
+
+    const page1Button = this.page.getByRole("button", { name: /page 1|^1$/ });
+
+    await expect(page1Button.first()).toBeVisible({ timeout: 5000 });
+
+    const page2Button = this.page.getByRole("button", { name: /page 2|^2$/ });
+    const hasPage2 = await page2Button
+      .first()
+      .isVisible()
+      .catch(() => false);
+
+    if (hasPage2) {

Review Comment:
   Let's not have an if condition as it passes silently without testing 
pagination if there is no second page. Lets ensure beforeAll creates enough data



##########
airflow-core/src/airflow/ui/tests/e2e/specs/xcoms.spec.ts:
##########
@@ -0,0 +1,104 @@
+/*!
+ * 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 "@playwright/test";
+import { AUTH_FILE } from "playwright.config";
+import { DagsPage } from "tests/e2e/pages/DagsPage";
+import { XComsPage } from "tests/e2e/pages/XComsPage";
+
+test.describe("XComs Page", () => {
+  test.setTimeout(60_000);
+
+  let xcomsPage: XComsPage;
+  const testDagId = "example_xcom";

Review Comment:
   can we get this from config



##########
airflow-core/src/airflow/ui/tests/e2e/pages/XComsPage.ts:
##########
@@ -0,0 +1,192 @@
+/*!
+ * 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, type Locator, type Page } from "@playwright/test";
+import { BasePage } from "tests/e2e/pages/BasePage";
+
+export class XComsPage extends BasePage {
+  public static get xcomsUrl(): string {
+    return "/xcoms";
+  }
+
+  public readonly collapseAllButton: Locator;
+  public readonly expandAllButton: Locator;
+  public readonly xcomsTable: Locator;
+
+  public constructor(page: Page) {
+    super(page);
+    this.collapseAllButton = page.getByRole("button", { name: /collapse/i });
+    this.expandAllButton = page.getByRole("button", { name: /expand/i });
+    this.xcomsTable = page.locator('table, div[role="table"]');
+  }
+
+  public async navigate(): Promise<void> {
+    await this.navigateTo(XComsPage.xcomsUrl);
+    await this.page.waitForURL(/.*xcoms/, { timeout: 15_000 });
+    await this.xcomsTable.waitFor({ state: "visible", timeout: 10_000 });
+
+    const dataLink = this.xcomsTable.locator("a[href*='/dags/']").first();
+    const noDataMessage = 
this.page.locator("text=/no.*xcom|no.*data|no.*entries/i");
+
+    await expect(dataLink.or(noDataMessage)).toBeVisible({ timeout: 30_000 });
+  }
+
+  public async verifyDagDisplayNameFiltering(dagDisplayNamePattern: string): 
Promise<void> {
+    await this.navigateTo(
+      
`${XComsPage.xcomsUrl}?dag_display_name_pattern=${encodeURIComponent(dagDisplayNamePattern)}`,
+    );
+    await this.page.waitForURL(/.*dag_display_name_pattern=.*/, { timeout: 
15_000 });
+    await this.page.waitForLoadState("networkidle");
+
+    const dataLinks = this.xcomsTable.locator("a[href*='/dags/']");
+
+    await expect(dataLinks.first()).toBeVisible({ timeout: 30_000 });
+    await expect(this.xcomsTable).toBeVisible();
+
+    const rows = this.xcomsTable.locator("tbody tr");
+    const rowCount = await rows.count();
+
+    expect(rowCount).toBeGreaterThan(0);
+
+    for (let i = 0; i < Math.min(rowCount, 3); i++) {
+      const dagIdLink = rows.nth(i).locator("a[href*='/dags/']").first();
+      const dagDisplayName = await dagIdLink.textContent();
+
+      
expect(dagDisplayName?.toLowerCase()).toContain(dagDisplayNamePattern.toLowerCase());
+    }
+  }
+
+  public async verifyExpandCollapse(): Promise<void> {
+    await this.navigate();
+
+    await expect(this.expandAllButton.first()).toBeVisible({ timeout: 5000 });
+    await this.expandAllButton.first().click();
+    await this.page.waitForTimeout(500);
+
+    await expect(this.collapseAllButton.first()).toBeVisible({ timeout: 5000 
});
+    await this.collapseAllButton.first().click();
+    await this.page.waitForTimeout(500);
+  }
+
+  public async verifyKeyPatternFiltering(keyPattern: string): Promise<void> {
+    await 
this.navigateTo(`${XComsPage.xcomsUrl}?key_pattern=${encodeURIComponent(keyPattern)}`);

Review Comment:
   We are using URL parameters directly here. I think we can use UI interaction 
create to simuate real user experience



##########
airflow-core/src/airflow/ui/tests/e2e/pages/XComsPage.ts:
##########
@@ -0,0 +1,192 @@
+/*!
+ * 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, type Locator, type Page } from "@playwright/test";
+import { BasePage } from "tests/e2e/pages/BasePage";
+
+export class XComsPage extends BasePage {
+  public static get xcomsUrl(): string {
+    return "/xcoms";
+  }
+
+  public readonly collapseAllButton: Locator;
+  public readonly expandAllButton: Locator;
+  public readonly xcomsTable: Locator;
+
+  public constructor(page: Page) {
+    super(page);
+    this.collapseAllButton = page.getByRole("button", { name: /collapse/i });
+    this.expandAllButton = page.getByRole("button", { name: /expand/i });
+    this.xcomsTable = page.locator('table, div[role="table"]');
+  }
+
+  public async navigate(): Promise<void> {
+    await this.navigateTo(XComsPage.xcomsUrl);
+    await this.page.waitForURL(/.*xcoms/, { timeout: 15_000 });
+    await this.xcomsTable.waitFor({ state: "visible", timeout: 10_000 });
+
+    const dataLink = this.xcomsTable.locator("a[href*='/dags/']").first();
+    const noDataMessage = 
this.page.locator("text=/no.*xcom|no.*data|no.*entries/i");
+
+    await expect(dataLink.or(noDataMessage)).toBeVisible({ timeout: 30_000 });
+  }
+
+  public async verifyDagDisplayNameFiltering(dagDisplayNamePattern: string): 
Promise<void> {
+    await this.navigateTo(
+      
`${XComsPage.xcomsUrl}?dag_display_name_pattern=${encodeURIComponent(dagDisplayNamePattern)}`,
+    );
+    await this.page.waitForURL(/.*dag_display_name_pattern=.*/, { timeout: 
15_000 });
+    await this.page.waitForLoadState("networkidle");
+
+    const dataLinks = this.xcomsTable.locator("a[href*='/dags/']");
+
+    await expect(dataLinks.first()).toBeVisible({ timeout: 30_000 });
+    await expect(this.xcomsTable).toBeVisible();
+
+    const rows = this.xcomsTable.locator("tbody tr");
+    const rowCount = await rows.count();
+
+    expect(rowCount).toBeGreaterThan(0);
+
+    for (let i = 0; i < Math.min(rowCount, 3); i++) {
+      const dagIdLink = rows.nth(i).locator("a[href*='/dags/']").first();
+      const dagDisplayName = await dagIdLink.textContent();
+
+      
expect(dagDisplayName?.toLowerCase()).toContain(dagDisplayNamePattern.toLowerCase());
+    }
+  }
+
+  public async verifyExpandCollapse(): Promise<void> {
+    await this.navigate();
+
+    await expect(this.expandAllButton.first()).toBeVisible({ timeout: 5000 });
+    await this.expandAllButton.first().click();
+    await this.page.waitForTimeout(500);
+
+    await expect(this.collapseAllButton.first()).toBeVisible({ timeout: 5000 
});
+    await this.collapseAllButton.first().click();
+    await this.page.waitForTimeout(500);
+  }
+
+  public async verifyKeyPatternFiltering(keyPattern: string): Promise<void> {
+    await 
this.navigateTo(`${XComsPage.xcomsUrl}?key_pattern=${encodeURIComponent(keyPattern)}`);
+    await this.page.waitForURL(/.*key_pattern=.*/, { timeout: 15_000 });
+    await this.page.waitForLoadState("networkidle");
+
+    const dataLinks = this.xcomsTable.locator("a[href*='/dags/']");
+
+    await expect(dataLinks.first()).toBeVisible({ timeout: 30_000 });
+    await expect(this.xcomsTable).toBeVisible();
+
+    const rows = this.xcomsTable.locator("tbody tr");
+    const rowCount = await rows.count();
+
+    expect(rowCount).toBeGreaterThan(0);
+
+    for (let i = 0; i < Math.min(rowCount, 3); i++) {
+      const keyCell = rows.nth(i).locator("td").first();
+      const keyText = await keyCell.textContent();
+
+      expect(keyText?.toLowerCase()).toContain(keyPattern.toLowerCase());
+    }
+  }
+
+  public async verifyPagination(limit: number): Promise<void> {
+    await this.navigateTo(`${XComsPage.xcomsUrl}?offset=0&limit=${limit}`);
+    await this.page.waitForURL(/.*limit=/, { timeout: 10_000 });
+    await this.page.waitForLoadState("networkidle");
+    await this.xcomsTable.waitFor({ state: "visible", timeout: 10_000 });
+
+    const dataLinks = this.xcomsTable.locator("a[href*='/dags/']");
+
+    await expect(dataLinks.first()).toBeVisible({ timeout: 30_000 });
+
+    const rows = this.xcomsTable.locator("tbody tr");
+
+    expect(await rows.count()).toBeGreaterThan(0);
+
+    const paginationNav = this.page.locator('nav[aria-label="pagination"], 
[role="navigation"]');
+
+    await expect(paginationNav.first()).toBeVisible({ timeout: 10_000 });
+
+    const page1Button = this.page.getByRole("button", { name: /page 1|^1$/ });
+
+    await expect(page1Button.first()).toBeVisible({ timeout: 5000 });
+
+    const page2Button = this.page.getByRole("button", { name: /page 2|^2$/ });

Review Comment:
   Consider using `[data-testid="next"]` / `[data-testid="prev"]` buttons if 
available, as they're more stable selectors than page number buttons.



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