kimimgo commented on code in PR #63979:
URL: https://github.com/apache/airflow/pull/63979#discussion_r2981824179
##########
airflow-core/src/airflow/ui/tests/e2e/pages/VariablePage.ts:
##########
@@ -76,26 +76,12 @@ export class VariablePage extends BasePage {
}
private async waitForTableData(): Promise<void> {
- await this.page.waitForFunction(
- () => {
- const table = document.querySelector('[data-testid="table-list"]');
+ const noData = this.page.getByText("No variables found");
+ const firstKeyCell = this.tableRows.first().locator("td:nth-child(2)");
- if (!table) return false;
-
- if (document.body.textContent.includes("No variables found")) {
- return true;
- }
-
- const rows = table.querySelectorAll("tbody tr");
-
- if (rows.length === 0) return false;
-
- const keyCells = table.querySelectorAll("tbody tr td:nth-child(2)");
-
- return [...keyCells].some((cell) => Boolean(cell.textContent.trim()));
- },
- undefined,
- { timeout: 60_000 },
- );
+ await Promise.race([
+ noData.waitFor({ state: "visible", timeout: 60_000 }),
+ firstKeyCell.waitFor({ state: "visible", timeout: 60_000 }),
Review Comment:
Good point! The tricky part here is the `Promise.race` pattern — we need to
wait for *either* "No variables found" or actual table data, whichever appears
first. With `expect().toBeVisible()`, the losing branch would throw an
assertion error.
One approach: use `expect(noData.or(firstKeyCell)).toBeVisible()` with
Playwright's `.or()` combinator. That keeps it assertion-based while handling
both cases. Want me to make that change?
--
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]