vatsrahul1001 commented on code in PR #60514: URL: https://github.com/apache/airflow/pull/60514#discussion_r2727047149
########## airflow-core/src/airflow/ui/tests/e2e/pages/TaskInstancesPage.ts: ########## @@ -0,0 +1,188 @@ +/*! + * 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) { Review Comment: Silently passes if there is not enough data. I think we should not have this condition. As we are already creating data in beforeAll -- 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]
