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


##########
airflow-core/src/airflow/ui/tests/e2e/pages/TaskInstancesPage.ts:
##########
@@ -0,0 +1,276 @@
+/*!
+ * 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 TaskInstancesPage extends BasePage {
+  public static get taskInstancesUrl(): string {
+    return "/task_instances";
+  }
+
+  public readonly taskInstancesTable: Locator;
+
+  public constructor(page: Page) {
+    super(page);
+    this.taskInstancesTable = page.locator('table, div[role="table"]');
+  }
+
+  /**
+   * Navigate to Task Instances page and wait for data to load
+   */
+  public async navigate(): Promise<void> {
+    await this.navigateTo(TaskInstancesPage.taskInstancesUrl);
+    await this.page.waitForURL(/.*task_instances/, { timeout: 15_000 });
+    await this.taskInstancesTable.waitFor({ state: "visible", timeout: 10_000 
});
+
+    const dataLink = 
this.taskInstancesTable.locator("a[href*='/dags/']").first();
+    const noDataMessage = this.page.locator('text="No Task Instances found"');
+
+    await expect(dataLink.or(noDataMessage)).toBeVisible({ timeout: 30_000 });
+  }
+
+  /**
+   * Verify pagination controls and navigation
+   */
+  public async verifyPagination(limit: number): Promise<void> {
+    await 
this.navigateTo(`${TaskInstancesPage.taskInstancesUrl}?offset=0&limit=${limit}`);
+    await this.page.waitForURL(/.*limit=/, { timeout: 10_000 });
+    await this.page.waitForLoadState("networkidle");
+    await this.taskInstancesTable.waitFor({ state: "visible", timeout: 10_000 
});
+
+    const dataLinks = this.taskInstancesTable.locator("a[href*='/dags/']");
+
+    await expect(dataLinks.first()).toBeVisible({ timeout: 30_000 });
+
+    const rows = this.taskInstancesTable.locator('tbody tr:not(.no-data), 
div[role="row"]:not(:first-child)');
+
+    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) {
+      await page2Button.first().click();
+      await this.page.waitForLoadState("networkidle");
+      await this.taskInstancesTable.waitFor({ state: "visible", timeout: 
10_000 });
+
+      const dataLinksPage2 = 
this.taskInstancesTable.locator("a[href*='/dags/']");
+      const noDataMessage = this.page.locator("text=/no.*data|no.*task 
instances|no.*results/i");
+
+      await 
expect(dataLinksPage2.first().or(noDataMessage.first())).toBeVisible({ timeout: 
30_000 });
+    }
+  }
+
+  /**
+   * Verify state filtering via URL parameters
+   */
+  public async verifyStateFiltering(expectedState: string): Promise<void> {
+    await 
this.navigateTo(`${TaskInstancesPage.taskInstancesUrl}?task_state=${expectedState.toLowerCase()}`);
+    await this.page.waitForURL(/.*task_state=.*/, { timeout: 15_000 });
+    await this.page.waitForLoadState("networkidle");
+
+    const dataLink = 
this.taskInstancesTable.locator("a[href*='/dags/']").first();
+
+    await expect(dataLink).toBeVisible({ timeout: 30_000 });
+    await expect(this.taskInstancesTable).toBeVisible();
+
+    const rowsAfterFilter = this.taskInstancesTable.locator(
+      'tbody tr:not(.no-data), div[role="row"]:not(:first-child)',
+    );
+    const noDataMessage = this.page.locator("text=/No.*found/i, 
text=/No.*results/i, text=/Empty/i");
+    const stateBadges = this.taskInstancesTable.locator('[class*="badge"], 
[class*="Badge"]');
+
+    await expect(stateBadges.first().or(noDataMessage.first())).toBeVisible({ 
timeout: 30_000 });
+
+    const countAfter = await rowsAfterFilter.count();
+
+    if (countAfter === 0) {

Review Comment:
   Do we need this condition?
   This silently returns if no rows found and filter test passes without even 
verifying the logic
   
   I see in our before all we are creating test data so there should always be 
data
   
   We can use this instead
   expect(countAfter, `Expected task instances with state "${expectedState}" 
but found none`).toBeGreaterThan(0);
   
   
   
   



##########
airflow-core/src/airflow/ui/tests/e2e/pages/TaskInstancesPage.ts:
##########
@@ -0,0 +1,276 @@
+/*!
+ * 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 TaskInstancesPage extends BasePage {
+  public static get taskInstancesUrl(): string {
+    return "/task_instances";
+  }
+
+  public readonly taskInstancesTable: Locator;
+
+  public constructor(page: Page) {
+    super(page);
+    this.taskInstancesTable = page.locator('table, div[role="table"]');
+  }
+
+  /**
+   * Navigate to Task Instances page and wait for data to load
+   */
+  public async navigate(): Promise<void> {
+    await this.navigateTo(TaskInstancesPage.taskInstancesUrl);
+    await this.page.waitForURL(/.*task_instances/, { timeout: 15_000 });
+    await this.taskInstancesTable.waitFor({ state: "visible", timeout: 10_000 
});
+
+    const dataLink = 
this.taskInstancesTable.locator("a[href*='/dags/']").first();
+    const noDataMessage = this.page.locator('text="No Task Instances found"');
+
+    await expect(dataLink.or(noDataMessage)).toBeVisible({ timeout: 30_000 });
+  }
+
+  /**
+   * Verify pagination controls and navigation
+   */
+  public async verifyPagination(limit: number): Promise<void> {
+    await 
this.navigateTo(`${TaskInstancesPage.taskInstancesUrl}?offset=0&limit=${limit}`);
+    await this.page.waitForURL(/.*limit=/, { timeout: 10_000 });
+    await this.page.waitForLoadState("networkidle");
+    await this.taskInstancesTable.waitFor({ state: "visible", timeout: 10_000 
});
+
+    const dataLinks = this.taskInstancesTable.locator("a[href*='/dags/']");
+
+    await expect(dataLinks.first()).toBeVisible({ timeout: 30_000 });
+
+    const rows = this.taskInstancesTable.locator('tbody tr:not(.no-data), 
div[role="row"]:not(:first-child)');
+
+    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) {
+      await page2Button.first().click();
+      await this.page.waitForLoadState("networkidle");
+      await this.taskInstancesTable.waitFor({ state: "visible", timeout: 
10_000 });
+
+      const dataLinksPage2 = 
this.taskInstancesTable.locator("a[href*='/dags/']");
+      const noDataMessage = this.page.locator("text=/no.*data|no.*task 
instances|no.*results/i");
+
+      await 
expect(dataLinksPage2.first().or(noDataMessage.first())).toBeVisible({ timeout: 
30_000 });
+    }
+  }
+
+  /**
+   * Verify state filtering via URL parameters
+   */
+  public async verifyStateFiltering(expectedState: string): Promise<void> {
+    await 
this.navigateTo(`${TaskInstancesPage.taskInstancesUrl}?task_state=${expectedState.toLowerCase()}`);
+    await this.page.waitForURL(/.*task_state=.*/, { timeout: 15_000 });
+    await this.page.waitForLoadState("networkidle");
+
+    const dataLink = 
this.taskInstancesTable.locator("a[href*='/dags/']").first();
+
+    await expect(dataLink).toBeVisible({ timeout: 30_000 });
+    await expect(this.taskInstancesTable).toBeVisible();
+
+    const rowsAfterFilter = this.taskInstancesTable.locator(
+      'tbody tr:not(.no-data), div[role="row"]:not(:first-child)',
+    );
+    const noDataMessage = this.page.locator("text=/No.*found/i, 
text=/No.*results/i, text=/Empty/i");
+    const stateBadges = this.taskInstancesTable.locator('[class*="badge"], 
[class*="Badge"]');
+
+    await expect(stateBadges.first().or(noDataMessage.first())).toBeVisible({ 
timeout: 30_000 });
+
+    const countAfter = await rowsAfterFilter.count();
+
+    if (countAfter === 0) {
+      return;
+    }
+
+    const badgeCount = await stateBadges.count();
+
+    expect(badgeCount).toBeGreaterThan(0);
+
+    for (let i = 0; i < Math.min(badgeCount, 20); i++) {
+      const badge = stateBadges.nth(i);
+      const badgeText = (await badge.textContent())?.trim().toLowerCase();
+
+      expect(badgeText).toContain(expectedState.toLowerCase());
+    }
+  }
+
+  /**
+   * Verify that different task states are visually distinct (success and 
failed)
+   */
+  public async verifyStateVisualDistinction(): Promise<void> {

Review Comment:
   This method is no longer is used in tests. Let's remove this



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