Skip to content

Commit a02fbaa

Browse files
MFWhenchoo121600Copilot
authored
fix(DagCalendarTab): improve background color retrieval and loading overlay handling (#64189)
* fix(DagCalendarTab): improve background color retrieval and loading overlay handling * fix(DagCalendarTab): update loading overlay and calendar cell visibility checks * fix(DagCalendarTab): improve background color retrieval and loading overlay handling * fix(DagCalendarTab): update loading overlay and calendar cell visibility checks * refactor: update visibility checks in DagCalendarTab * remove redundant visibility checks in DagCalendarTab * removed unrelated change and attempted to resolve merge conflict markers * Update airflow-core/src/airflow/ui/tests/e2e/pages/DagCalendarTab.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update airflow-core/src/airflow/ui/tests/e2e/pages/DagCalendarTab.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * updated getActiveCellColors to use getComputedStyle to properly return rendered color of an element * simplify child element color retrieval and improve readability * changed file mode --------- Co-authored-by: Yeonguk Choo <choo121600@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent cacc2eb commit a02fbaa

1 file changed

Lines changed: 36 additions & 16 deletions

File tree

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

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,35 @@ export class DagCalendarTab extends BasePage {
5050

5151
for (let i = 0; i < count; i++) {
5252
const cell = this.activeCells.nth(i);
53-
const bg = await cell.evaluate((el) => window.getComputedStyle(el).backgroundColor);
53+
const computedColor = await cell.evaluate((el: Element) => {
54+
const getRenderableColor = (element: Element): string => {
55+
const color = window.getComputedStyle(element).backgroundColor;
5456

55-
colors.push(bg);
57+
return color && color !== "rgba(0, 0, 0, 0)" && color !== "transparent" ? color : "";
58+
};
59+
60+
const cellColor = getRenderableColor(el);
61+
62+
if (cellColor) {
63+
return cellColor;
64+
}
65+
66+
const children = [...el.querySelectorAll("*")];
67+
68+
for (const child of children) {
69+
const childColor = getRenderableColor(child);
70+
71+
if (childColor) {
72+
return childColor;
73+
}
74+
}
75+
76+
return "";
77+
});
78+
79+
if (computedColor) {
80+
colors.push(computedColor);
81+
}
5682
}
5783

5884
return colors;
@@ -88,7 +114,7 @@ export class DagCalendarTab extends BasePage {
88114
public async navigateToCalendar(dagId: string) {
89115
await expect(async () => {
90116
await this.safeGoto(`/dags/${dagId}/calendar`);
91-
await this.page.getByTestId("dag-calendar-root").waitFor({ state: "visible", timeout: 5000 });
117+
await expect(this.page.getByTestId("dag-calendar-root")).toBeVisible({ timeout: 5000 });
92118
}).toPass({ intervals: [2000], timeout: 60_000 });
93119
await this.waitForCalendarReady();
94120
}
@@ -100,7 +126,7 @@ export class DagCalendarTab extends BasePage {
100126
public async switchToHourly() {
101127
await this.hourlyToggle.click();
102128

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

106132
public async switchToTotalView() {
@@ -112,22 +138,16 @@ export class DagCalendarTab extends BasePage {
112138
}
113139

114140
private async waitForCalendarReady(): Promise<void> {
115-
await this.page.getByTestId("dag-calendar-root").waitFor({ state: "visible", timeout: 120_000 });
141+
await expect(this.page.getByTestId("dag-calendar-root")).toBeVisible({ timeout: 120_000 });
116142

117-
await this.page.getByTestId("calendar-current-period").waitFor({ state: "visible", timeout: 120_000 });
143+
await expect(this.page.getByTestId("calendar-current-period")).toBeVisible({ timeout: 120_000 });
144+
await expect(this.page.getByTestId("calendar-grid")).toBeVisible({ timeout: 120_000 });
118145

119146
const overlay = this.page.getByTestId("calendar-loading-overlay");
120147

121-
if (await overlay.isVisible().catch(() => false)) {
122-
await overlay.waitFor({ state: "hidden", timeout: 120_000 });
123-
}
124-
125-
await this.page.getByTestId("calendar-grid").waitFor({ state: "visible", timeout: 120_000 });
126-
127-
await this.page.waitForFunction(() => {
128-
const cells = document.querySelectorAll('[data-testid="calendar-cell"]');
148+
await expect(overlay).toBeHidden({ timeout: 120_000 });
149+
const cells = this.page.getByTestId("calendar-cell");
129150

130-
return cells.length > 0;
131-
});
151+
await expect(cells.first()).toBeVisible({ timeout: 120_000 });
132152
}
133153
}

0 commit comments

Comments
 (0)