vatsrahul1001 commented on code in PR #59919: URL: https://github.com/apache/airflow/pull/59919#discussion_r2663819011
########## airflow-core/src/airflow/ui/tests/e2e/pages/DagRunsPage.ts: ########## @@ -0,0 +1,173 @@ +/*! + * 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"; + +/** + * Page Object for the DAG Runs page (/dag_runs) + */ +export class DagRunsPage extends BasePage { + public static get dagRunsUrl(): string { + return "/dag_runs"; + } + + public readonly dagRunsTable: Locator; + + public constructor(page: Page) { + super(page); + this.dagRunsTable = page.locator('table, div[role="table"]'); + } + + /** + * Navigate to DAG Runs page + */ + public async navigate(): Promise<void> { + await this.navigateTo(DagRunsPage.dagRunsUrl); + await this.page.waitForURL(/.*dag_runs/, { timeout: 15_000 }); + await this.dagRunsTable.waitFor({ state: "visible", timeout: 10_000 }); + + // Wait for data to load - check if we have rows or "No Dag Runs found" message + const rows = this.dagRunsTable.locator('tbody tr:not(.no-data), div[role="row"]:not(:first-child)'); + const noDataMessage = this.page.locator('text="No Dag Runs found"'); + + await Promise.race([ + rows + .first() + .waitFor({ state: "visible", timeout: 10_000 }) + .catch(() => { + // Ignore error - either rows or no data message will appear + }), + noDataMessage.waitFor({ state: "visible", timeout: 10_000 }).catch(() => { + // Ignore error - either rows or no data message will appear + }), + ]); + } + + /** + * Verify that DAG runs exist in the table + */ + public async verifyDagRunsExist(): Promise<void> { + const rows = this.dagRunsTable.locator('tbody tr:not(.no-data), div[role="row"]:not(:first-child)'); + + expect(await rows.count()).toBeGreaterThan(0); + } + + /** + * Verify that filtering works + */ + public async verifyFilteringWorks(): Promise<void> { + const addFilterButton = this.page.locator( + 'button:has-text("Filter"), button:has-text("Add Filter"), button[aria-label*="filter" i]', + ); + + await expect(addFilterButton.first()).toBeVisible({ timeout: 5000 }); + await addFilterButton.first().click(); + + await this.page.waitForTimeout(1000); + + const stateFilterOption = this.page.locator(':text("State")').first(); + + await expect(stateFilterOption).toBeVisible({ timeout: 5000 }); + + await stateFilterOption.click(); + await this.page.waitForTimeout(500); + + await expect(this.dagRunsTable).toBeVisible(); Review Comment: We are not verifying filtering results here. We should check that the filter works ########## airflow-core/src/airflow/ui/tests/e2e/specs/dag-runs.spec.ts: ########## @@ -0,0 +1,48 @@ +/*! + * 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 { test } from "@playwright/test"; +import { DagRunsPage } from "tests/e2e/pages/DagRunsPage"; + +test.describe("DAG Runs Page", () => { + let dagRunsPage: DagRunsPage; + + test.beforeEach(({ page }) => { + dagRunsPage = new DagRunsPage(page); + }); + + test("should display the DAG runs table with data", async () => { + await dagRunsPage.navigate(); + await dagRunsPage.verifyDagRunsExist(); + }); + + test("should display run details: run ID, state, and dates", async () => { + await dagRunsPage.navigate(); + await dagRunsPage.verifyRunDetailsDisplay(); + }); + + test("should display different run states with visual badges", async () => { Review Comment: Let's remove this test and we can cover states check in filter tests ########## airflow-core/src/airflow/ui/tests/e2e/specs/dag-runs.spec.ts: ########## @@ -0,0 +1,48 @@ +/*! + * 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 { test } from "@playwright/test"; +import { DagRunsPage } from "tests/e2e/pages/DagRunsPage"; + +test.describe("DAG Runs Page", () => { + let dagRunsPage: DagRunsPage; + + test.beforeEach(({ page }) => { + dagRunsPage = new DagRunsPage(page); + }); + + test("should display the DAG runs table with data", async () => { + await dagRunsPage.navigate(); + await dagRunsPage.verifyDagRunsExist(); + }); + + test("should display run details: run ID, state, and dates", async () => { + await dagRunsPage.navigate(); + await dagRunsPage.verifyRunDetailsDisplay(); + }); + + test("should display different run states with visual badges", async () => { + await dagRunsPage.navigate(); + await dagRunsPage.verifyStateVisualDistinction(); + }); + + test("should have filtering functionality", async () => { Review Comment: As mentioned [here](https://github.com/apache/airflow/pull/59919#issuecomment-3713306224). We should filter and check whether filter is applied correctly or not. Let's filter with dag_id(Create runs for different dag_id in beforeAll) and state(create run with failed state in before all ) -- 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]
