This is an automated email from the ASF dual-hosted git repository.
choo121600 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new df21b557ca0 fix(ui/e2e): improve Playwright test patterns in
dag-runs.spec.ts (#63199)
df21b557ca0 is described below
commit df21b557ca0374fa940498a135eaaa6da2ad875f
Author: Idris Akorede Ibrahim <[email protected]>
AuthorDate: Fri Mar 20 05:33:37 2026 +0100
fix(ui/e2e): improve Playwright test patterns in dag-runs.spec.ts (#63199)
Co-authored-by: Yeonguk Choo <[email protected]>
---
.../src/airflow/ui/tests/e2e/pages/DagRunsPage.ts | 32 ++++++++++------------
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/DagRunsPage.ts
b/airflow-core/src/airflow/ui/tests/e2e/pages/DagRunsPage.ts
index 8ace70b132e..1aab8fe84f8 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/DagRunsPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/DagRunsPage.ts
@@ -28,7 +28,7 @@ export class DagRunsPage extends BasePage {
public constructor(page: Page) {
super(page);
- this.dagRunsTable = page.locator('table, div[role="table"]');
+ this.dagRunsTable = page.getByRole("table");
}
/**
@@ -37,10 +37,10 @@ export class DagRunsPage extends BasePage {
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 });
+ await expect(this.dagRunsTable).toBeVisible({ timeout: 10_000 });
const dataLink = this.dagRunsTable.locator("a[href*='/dags/']").first();
- const noDataMessage = this.page.locator('text="No Dag Runs found"');
+ const noDataMessage = this.page.getByText("No Dag Runs found");
await expect(dataLink.or(noDataMessage)).toBeVisible({ timeout: 30_000 });
}
@@ -51,7 +51,6 @@ export class DagRunsPage extends BasePage {
public async verifyDagIdFiltering(dagIdPattern: string): Promise<void> {
await
this.navigateTo(`${DagRunsPage.dagRunsUrl}?dag_id_pattern=${encodeURIComponent(dagIdPattern)}`);
await this.page.waitForURL(/.*dag_id_pattern=.*/, { timeout: 15_000 });
- await this.page.waitForLoadState("networkidle");
const dataLinks = this.dagRunsTable.locator("a[href*='/dags/']");
@@ -59,16 +58,15 @@ export class DagRunsPage extends BasePage {
await expect(this.dagRunsTable).toBeVisible();
const rows = this.dagRunsTable.locator("tbody tr");
- const rowCount = await rows.count();
- expect(rowCount).toBeGreaterThan(0);
+ await expect(rows).not.toHaveCount(0);
+
+ const rowCount = await rows.count();
for (let i = 0; i < Math.min(rowCount, 5); i++) {
const dagIdLink = rows.nth(i).locator("a[href*='/dags/']").first();
- const dagIdText = await dagIdLink.textContent();
- expect(dagIdText).toBeTruthy();
- expect(dagIdText).toContain(dagIdPattern);
+ await expect(dagIdLink).toHaveText(new RegExp(dagIdPattern));
}
}
@@ -79,7 +77,7 @@ export class DagRunsPage extends BasePage {
const dataLinks = this.dagRunsTable.locator("a[href*='/dags/']");
await expect(dataLinks.first()).toBeVisible({ timeout: 30_000 });
- expect(await dataLinks.count()).toBeGreaterThan(0);
+ await expect(dataLinks).not.toHaveCount(0);
}
/**
@@ -93,12 +91,12 @@ export class DagRunsPage extends BasePage {
const dagIdLink = firstRow.locator("a[href*='/dags/']").first();
await expect(dagIdLink).toBeVisible();
- expect((await dagIdLink.textContent())?.trim()).toBeTruthy();
+ await expect(dagIdLink).not.toHaveText("");
const runIdLink = firstRow.locator("a[href*='/runs/']").first();
await expect(runIdLink).toBeVisible();
- expect((await runIdLink.textContent())?.trim()).toBeTruthy();
+ await expect(runIdLink).not.toHaveText("");
const stateCell = firstRow.locator("td").filter({ hasText:
/running|success|failed|queued/i });
@@ -124,7 +122,6 @@ export class DagRunsPage extends BasePage {
public async verifyStateFiltering(expectedState: string): Promise<void> {
await
this.navigateTo(`${DagRunsPage.dagRunsUrl}?state=${expectedState.toLowerCase()}`);
await this.page.waitForURL(/.*state=.*/, { timeout: 15_000 });
- await this.page.waitForLoadState("networkidle");
const dataLinks = this.dagRunsTable.locator("a[href*='/dags/']");
@@ -132,14 +129,13 @@ export class DagRunsPage extends BasePage {
await expect(this.dagRunsTable).toBeVisible();
const rows = this.dagRunsTable.locator("tbody tr");
- const rowCount = await rows.count();
- expect(rowCount).toBeGreaterThan(0);
+ await expect(rows).not.toHaveCount(0);
- for (let i = 0; i < rowCount; i++) {
- const rowText = await rows.nth(i).textContent();
+ const rowCount = await rows.count();
- expect(rowText?.toLowerCase()).toContain(expectedState.toLowerCase());
+ for (let i = 0; i < rowCount; i++) {
+ await expect(rows.nth(i)).toContainText(new RegExp(expectedState, "i"));
}
}
}