Skip to content

Commit b7664b3

Browse files
committed
Address PR review comments
1 parent a6bfee6 commit b7664b3

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

airflow-core/src/airflow/ui/tests/e2e/pages/HomePage.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,26 @@ export class HomePage extends BasePage {
5353
public constructor(page: Page) {
5454
super(page);
5555

56-
// Stats section - using the heading text
57-
this.statsSection = page.locator('text="Stats"').locator("..").locator("..");
58-
5956
// Stats cards - using link patterns that match the StatsCard component
6057
this.failedDagsCard = page.locator('a[href*="last_dag_run_state=failed"]');
6158
this.runningDagsCard = page.locator('a[href*="last_dag_run_state=running"]');
6259
this.activeDagsCard = page.locator('a[href*="paused=false"]');
6360
this.dagImportErrorsCard = page.locator('button:has-text("DAG Import Errors")');
6461

65-
// Health section - using text content matching
66-
this.healthSection = page.locator('text="Health"').locator("..").locator("..");
62+
// Stats section - using role-based selector
63+
this.statsSection = page.getByRole("heading", { name: "Stats" }).locator("..");
64+
// Health section - using role-based selector
65+
this.healthSection = page.getByRole("heading", { name: "Health" }).locator("..");
6766
this.metaDatabaseHealth = page.getByText("Metadatabase").first();
6867
this.schedulerHealth = page.getByText("Scheduler").first();
6968
this.triggererHealth = page.getByText("Triggerer").first();
7069
this.dagProcessorHealth = page.getByText("DAG Processor").first();
7170

72-
// Pool Summary section
73-
this.poolSummarySection = page.locator('text="Pool Summary"').locator("..").locator("..");
71+
// Pool Summary section - using role-based selector
72+
this.poolSummarySection = page.getByRole("heading", { name: "Pool Summary" }).locator("..");
7473

75-
// Historical Metrics section (recent runs)
76-
this.historicalMetricsSection = page.getByText("History").first().locator("..").locator("..");
74+
// Historical Metrics section (recent runs) - using role-based selector
75+
this.historicalMetricsSection = page.getByRole("heading", { name: "History" }).locator("..");
7776
this.dagRunMetrics = page.getByRole("heading", { name: /dag run/i }).first();
7877
this.taskInstanceMetrics = page.getByRole("heading", { name: /task instance/i }).first();
7978
}
@@ -169,13 +168,14 @@ export class HomePage extends BasePage {
169168
*/
170169
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
171170
private async getStatsCardCount(card: Locator): Promise<number> {
172-
try {
173-
const badgeText = await card.locator("span").first().textContent();
174-
const match = badgeText?.match(/\d+/);
171+
await card.waitFor({ state: "visible" }); // Fail fast if card doesn't exist
172+
const badgeText = await card.locator("span").first().textContent();
173+
const match = badgeText?.match(/\d+/);
175174

176-
return match ? parseInt(match[0], 10) : 0;
177-
} catch {
178-
return 0;
175+
if (!match) {
176+
throw new Error("Could not find count in stats card");
179177
}
178+
179+
return parseInt(match[0], 10);
180180
}
181181
}

airflow-core/src/airflow/ui/tests/e2e/specs/home-dashboard.spec.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,9 @@ test.describe("Dashboard Metrics Display", () => {
135135
// DAG Import Errors button only appears when there are actual import errors
136136
const isDagImportErrorsVisible = await homePage.isDagImportErrorsVisible();
137137

138-
if (isDagImportErrorsVisible) {
139-
await expect(homePage.dagImportErrorsCard).toBeVisible();
140-
}
138+
// Skip test with clear message if no import errors exist in the test environment
139+
test.skip(!isDagImportErrorsVisible, "No DAG import errors present in test environment");
141140

142-
// Stats section should always be visible regardless of import errors
143-
const isStatsVisible = await homePage.isStatsSectionVisible();
144-
145-
expect(isStatsVisible).toBe(true);
141+
await expect(homePage.dagImportErrorsCard).toBeVisible();
146142
});
147143
});

0 commit comments

Comments
 (0)