Skip to content

Commit 348bb0c

Browse files
committed
Improve Playwright test patterns in dag-calendar-tab #63409
1 parent b91394a commit 348bb0c

File tree

2 files changed

+10
-26
lines changed

2 files changed

+10
-26
lines changed

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

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ export class DagCalendarTab extends BasePage {
5858
return colors;
5959
}
6060

61-
public async getActiveCellCount(): Promise<number> {
62-
return this.activeCells.count();
63-
}
64-
6561
public async getManualRunStates(): Promise<Array<string>> {
6662
const count = await this.activeCells.count();
6763
const states: Array<string> = [];
@@ -88,7 +84,7 @@ export class DagCalendarTab extends BasePage {
8884
public async navigateToCalendar(dagId: string) {
8985
await expect(async () => {
9086
await this.safeGoto(`/dags/${dagId}/calendar`);
91-
await this.page.getByTestId("dag-calendar-root").waitFor({ state: "visible", timeout: 5000 });
87+
await expect(this.page.getByTestId("dag-calendar-root")).toBeVisible({ timeout: 5000 });
9288
}).toPass({ intervals: [2000], timeout: 60_000 });
9389
await this.waitForCalendarReady();
9490
}
@@ -100,7 +96,7 @@ export class DagCalendarTab extends BasePage {
10096
public async switchToHourly() {
10197
await this.hourlyToggle.click();
10298

103-
await this.page.getByTestId("calendar-hourly-view").waitFor({ state: "visible", timeout: 30_000 });
99+
await expect(this.page.getByTestId("calendar-hourly-view")).toBeVisible({ timeout: 30_000 });
104100
}
105101

106102
public async switchToTotalView() {
@@ -112,22 +108,14 @@ export class DagCalendarTab extends BasePage {
112108
}
113109

114110
private async waitForCalendarReady(): Promise<void> {
115-
await this.page.getByTestId("dag-calendar-root").waitFor({ state: "visible", timeout: 120_000 });
116-
117-
await this.page.getByTestId("calendar-current-period").waitFor({ state: "visible", timeout: 120_000 });
111+
await expect(this.page.getByTestId("dag-calendar-root")).toBeVisible({ timeout: 120_000 });
118112

119-
const overlay = this.page.getByTestId("calendar-loading-overlay");
120-
121-
if (await overlay.isVisible().catch(() => false)) {
122-
await overlay.waitFor({ state: "hidden", timeout: 120_000 });
123-
}
113+
await expect(this.page.getByTestId("calendar-current-period")).toBeVisible({ timeout: 120_000 });
124114

125-
await this.page.getByTestId("calendar-grid").waitFor({ state: "visible", timeout: 120_000 });
115+
await expect(this.page.getByTestId("calendar-loading-overlay")).toBeHidden({ timeout: 120_000 });
126116

127-
await this.page.waitForFunction(() => {
128-
const cells = document.querySelectorAll('[data-testid="calendar-cell"]');
117+
await expect(this.page.getByTestId("calendar-grid")).toBeVisible({ timeout: 120_000 });
129118

130-
return cells.length > 0;
131-
});
119+
await expect(this.calendarCells.first()).toBeVisible({ timeout: 120_000 });
132120
}
133121
}

airflow-core/src/airflow/ui/tests/e2e/specs/dag-calendar-tab.spec.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ test.describe("DAG Calendar Tab", () => {
104104
test("verify active cells appear for DAG runs", async () => {
105105
await calendar.switchToHourly();
106106

107-
const count = await calendar.getActiveCellCount();
108-
109-
expect(count).toBeGreaterThan(0);
107+
await expect(calendar.activeCells.first()).toBeVisible();
110108
});
111109

112110
test("verify manual runs are detected", async () => {
@@ -150,13 +148,11 @@ test.describe("DAG Calendar Tab", () => {
150148
test("failed view reduces active cells", async () => {
151149
await calendar.switchToHourly();
152150

153-
const totalCount = await calendar.getActiveCellCount();
151+
const totalCount = await calendar.activeCells.count();
154152

155153
await calendar.switchToFailedView();
156154

157-
const failedCount = await calendar.getActiveCellCount();
158-
159-
expect(failedCount).toBeLessThan(totalCount);
155+
await expect.poll(async () => calendar.activeCells.count(), { timeout: 10_000 }).toBeLessThan(totalCount);
160156
});
161157

162158
test.fixme("color scale changes between total and failed view", async () => {

0 commit comments

Comments
 (0)