You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by bb...@apache.org on 2026/04/15 14:21:21 UTC
(airflow) branch main updated: E2E: resilient page objects with toPass pattern and simple spec refactoring (#64666)
This is an automated email from the ASF dual-hosted git repository.
bbovenzi 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 7aee753be6b E2E: resilient page objects with toPass pattern and simple spec refactoring (#64666)
7aee753be6b is described below
commit 7aee753be6ba94e5db0ff32721b95334c3a93f90
Author: Yeonguk Choo <ch...@gmail.com>
AuthorDate: Wed Apr 15 23:21:12 2026 +0900
E2E: resilient page objects with toPass pattern and simple spec refactoring (#64666)
---
.../airflow/ui/tests/e2e/fixtures/calendar-data.ts | 27 +-
.../src/airflow/ui/tests/e2e/fixtures/data.ts | 7 +-
.../airflow/ui/tests/e2e/pages/AssetDetailPage.ts | 10 +-
.../airflow/ui/tests/e2e/pages/AssetListPage.ts | 5 +-
.../src/airflow/ui/tests/e2e/pages/BackfillPage.ts | 9 +-
.../src/airflow/ui/tests/e2e/pages/BasePage.ts | 9 +-
.../ui/tests/e2e/pages/ConfigurationPage.ts | 6 +-
.../airflow/ui/tests/e2e/pages/ConnectionsPage.ts | 236 ++++----------
.../airflow/ui/tests/e2e/pages/DagCalendarTab.ts | 19 +-
.../src/airflow/ui/tests/e2e/pages/DagRunsPage.ts | 51 +--
.../airflow/ui/tests/e2e/pages/DagRunsTabPage.ts | 44 ++-
.../src/airflow/ui/tests/e2e/pages/DagsPage.ts | 342 ++++++++-------------
.../src/airflow/ui/tests/e2e/pages/EventsPage.ts | 44 ++-
.../src/airflow/ui/tests/e2e/pages/GridPage.ts | 8 +-
.../src/airflow/ui/tests/e2e/pages/HomePage.ts | 29 +-
.../src/airflow/ui/tests/e2e/pages/LoginPage.ts | 14 +-
.../src/airflow/ui/tests/e2e/pages/PluginsPage.ts | 5 +-
.../src/airflow/ui/tests/e2e/pages/PoolsPage.ts | 20 +-
.../airflow/ui/tests/e2e/pages/ProvidersPage.ts | 29 +-
.../ui/tests/e2e/pages/RequiredActionsPage.ts | 294 +++++++++++++-----
.../airflow/ui/tests/e2e/pages/TaskInstancePage.ts | 6 +-
.../ui/tests/e2e/pages/TaskInstancesPage.ts | 56 ++--
.../src/airflow/ui/tests/e2e/pages/VariablePage.ts | 29 +-
.../src/airflow/ui/tests/e2e/pages/XComsPage.ts | 26 +-
.../src/airflow/ui/tests/e2e/specs/asset.spec.ts | 81 ++---
.../ui/tests/e2e/specs/configuration.spec.ts | 23 +-
.../ui/tests/e2e/specs/dag-audit-log.spec.ts | 51 +--
.../ui/tests/e2e/specs/dag-calendar-tab.spec.ts | 145 +++------
.../ui/tests/e2e/specs/dag-code-tab.spec.ts | 26 +-
.../ui/tests/e2e/specs/dag-grid-view.spec.ts | 47 +--
.../ui/tests/e2e/specs/dag-runs-tab.spec.ts | 72 ++---
.../airflow/ui/tests/e2e/specs/dag-runs.spec.ts | 127 +-------
.../airflow/ui/tests/e2e/specs/dag-tasks.spec.ts | 138 ++++-----
.../airflow/ui/tests/e2e/specs/dags-list.spec.ts | 124 ++++----
.../airflow/ui/tests/e2e/specs/events-page.spec.ts | 73 +----
.../ui/tests/e2e/specs/home-dashboard.spec.ts | 53 +---
.../src/airflow/ui/tests/e2e/specs/plugins.spec.ts | 21 +-
.../airflow/ui/tests/e2e/specs/providers.spec.ts | 45 +--
.../ui/tests/e2e/specs/task-instances.spec.ts | 137 +--------
.../airflow/ui/tests/e2e/specs/task-logs.spec.ts | 78 ++---
.../src/airflow/ui/tests/e2e/specs/xcoms.spec.ts | 67 +---
.../src/airflow/ui/tests/e2e/utils/health.ts | 67 ----
42 files changed, 1039 insertions(+), 1661 deletions(-)
diff --git a/airflow-core/src/airflow/ui/tests/e2e/fixtures/calendar-data.ts b/airflow-core/src/airflow/ui/tests/e2e/fixtures/calendar-data.ts
index 080f46be2f0..6ef2d58d68c 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/fixtures/calendar-data.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/fixtures/calendar-data.ts
@@ -20,15 +20,13 @@
/**
* Calendar data fixture — creates success + failed DAG runs for calendar tests.
*/
-
-/* eslint-disable react-hooks/rules-of-hooks -- Playwright's `use` is not a React Hook. */
import dayjs from "dayjs";
import { testConfig } from "playwright.config";
import { test as base } from "tests/e2e/fixtures";
import {
apiCreateDagRun,
- safeCleanupDagRun,
apiSetDagRunState,
+ safeCleanupDagRun,
uniqueRunId,
waitForDagReady,
} from "tests/e2e/utils/test-helpers";
@@ -63,20 +61,31 @@ export const test = base.extend<Record<never, never>, { calendarRunsData: Calend
const failedRunId = uniqueRunId("cal_failed");
try {
- await apiCreateDagRun(authenticatedRequest, dagId, {
+ const actualSuccessRunId = await apiCreateDagRun(authenticatedRequest, dagId, {
dag_run_id: successRunId,
logical_date: successIso,
});
- createdRunIds.push(successRunId);
- await apiSetDagRunState(authenticatedRequest, { dagId, runId: successRunId, state: "success" });
- await apiCreateDagRun(authenticatedRequest, dagId, {
+ createdRunIds.push(actualSuccessRunId);
+ await apiSetDagRunState(authenticatedRequest, {
+ dagId,
+ runId: actualSuccessRunId,
+ state: "success",
+ });
+
+ const actualFailedRunId = await apiCreateDagRun(authenticatedRequest, dagId, {
dag_run_id: failedRunId,
logical_date: failedIso,
});
- createdRunIds.push(failedRunId);
- await apiSetDagRunState(authenticatedRequest, { dagId, runId: failedRunId, state: "failed" });
+ createdRunIds.push(actualFailedRunId);
+ await apiSetDagRunState(authenticatedRequest, {
+ dagId,
+ runId: actualFailedRunId,
+ state: "failed",
+ });
+
+ // eslint-disable-next-line react-hooks/rules-of-hooks
await use({ dagId });
} finally {
for (const runId of createdRunIds) {
diff --git a/airflow-core/src/airflow/ui/tests/e2e/fixtures/data.ts b/airflow-core/src/airflow/ui/tests/e2e/fixtures/data.ts
index 4c8537f45e9..af7573d93d1 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/fixtures/data.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/fixtures/data.ts
@@ -85,13 +85,14 @@ async function createAndSetupDagRun(
const offsetMs = options.parallelIndex * 7_200_000;
const logicalDate = options.logicalDate ?? new Date(Date.now() - offsetMs).toISOString();
- await apiCreateDagRun(request, dagId, {
+ const actualRunId = await apiCreateDagRun(request, dagId, {
dag_run_id: runId,
logical_date: logicalDate,
});
- await apiSetDagRunState(request, { dagId, runId, state: options.state });
- return { dagId, logicalDate, runId };
+ await apiSetDagRunState(request, { dagId, runId: actualRunId, state: options.state });
+
+ return { dagId, logicalDate, runId: actualRunId };
}
async function cleanupMultipleRuns(
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/AssetDetailPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/AssetDetailPage.ts
index 964774e6a80..ecd414fd6ef 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/AssetDetailPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/AssetDetailPage.ts
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { expect, type Page } from "@playwright/test";
+import { expect, type Locator, type Page } from "@playwright/test";
import { BasePage } from "./BasePage";
@@ -33,12 +33,12 @@ export class AssetDetailPage extends BasePage {
await this.page.getByRole("link", { exact: true, name }).click();
}
- public async goto(): Promise<void> {
- await this.navigateTo(AssetDetailPage.url);
+ public getHeading(name: string): Locator {
+ return this.page.getByRole("heading", { name });
}
- public async verifyAssetDetails(name: string): Promise<void> {
- await expect(this.page.getByRole("heading", { name })).toBeVisible();
+ public async goto(): Promise<void> {
+ await this.navigateTo(AssetDetailPage.url);
}
public async verifyProducingTasks(): Promise<void> {
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/AssetListPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/AssetListPage.ts
index 2b9ab8ee6e0..19300a33024 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/AssetListPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/AssetListPage.ts
@@ -43,7 +43,10 @@ export class AssetListPage extends BasePage {
}
public async navigate(): Promise<void> {
- await this.navigateTo("/assets");
+ await expect(async () => {
+ await this.navigateTo("/assets");
+ await this.page.waitForURL(/.*assets/, { timeout: 10_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
public async openFirstAsset(): Promise<string> {
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/BackfillPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/BackfillPage.ts
index 322bf6790d6..b73d78c24f5 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/BackfillPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/BackfillPage.ts
@@ -395,8 +395,13 @@ export class BackfillPage extends BasePage {
}
public async openFilterMenu(): Promise<void> {
- await this.getFilterButton().click();
- await expect(this.page.getByRole("menu")).toBeVisible({ timeout: 5000 });
+ await expect(async () => {
+ if (!(await this.page.getByRole("menu").isVisible())) {
+ await this.getFilterButton().click();
+ }
+ await expect(this.page.getByRole("menu")).toBeVisible({ timeout: 3000 });
+ await this.page.getByRole("menuitem").first().click({ timeout: 3000, trial: true });
+ }).toPass({ intervals: [1000], timeout: 15_000 });
}
public async pauseBackfillViaApi(backfillId: number): Promise<boolean> {
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/BasePage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/BasePage.ts
index 968b62b1e73..90c459e614a 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/BasePage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/BasePage.ts
@@ -18,7 +18,6 @@
*/
import { expect } from "@playwright/test";
import type { Page, Locator } from "@playwright/test";
-import { waitForServerReady } from "tests/e2e/utils/health";
/**
* Base Page Object
@@ -54,12 +53,6 @@ export class BasePage {
}
public async navigateTo(path: string): Promise<void> {
- await this.safeGoto(path, { waitUntil: "domcontentloaded" });
- }
-
- /** Health-checked navigation. Subclasses should use this instead of `this.page.goto()`. */
- protected async safeGoto(path: string, options?: Parameters<Page["goto"]>[1]): Promise<void> {
- await waitForServerReady(this.page);
- await this.page.goto(path, options);
+ await this.page.goto(path, { waitUntil: "domcontentloaded" });
}
}
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/ConfigurationPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/ConfigurationPage.ts
index 69afd62bc4c..d6b74c030b5 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/ConfigurationPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/ConfigurationPage.ts
@@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+import { expect } from "@playwright/test";
import type { Locator, Page } from "@playwright/test";
import { BasePage } from "./BasePage";
@@ -38,7 +39,10 @@ export class ConfigurationPage extends BasePage {
}
public async navigate(): Promise<void> {
- await this.navigateTo("/configs");
+ await expect(async () => {
+ await this.navigateTo("/configs");
+ await this.page.waitForURL(/.*configs/, { timeout: 10_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
public async waitForLoad(): Promise<void> {
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/ConnectionsPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/ConnectionsPage.ts
index cf43c60195d..b5920db3eb8 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/ConnectionsPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/ConnectionsPage.ts
@@ -18,6 +18,7 @@
*/
import { expect, type Locator, type Page } from "@playwright/test";
import { BasePage } from "tests/e2e/pages/BasePage";
+import { waitForStableRowCount } from "tests/e2e/utils/test-helpers";
type ConnectionDetails = {
conn_type: string;
@@ -32,7 +33,6 @@ type ConnectionDetails = {
};
export class ConnectionsPage extends BasePage {
- // Page URLs
public static get connectionsListUrl(): string {
return "/connections";
}
@@ -42,10 +42,8 @@ export class ConnectionsPage extends BasePage {
public readonly connectionForm: Locator;
public readonly connectionIdHeader: Locator;
public readonly connectionIdInput: Locator;
- // Core page elements
public readonly connectionsTable: Locator;
public readonly connectionTypeHeader: Locator;
- public readonly connectionTypeSelect: Locator;
public readonly descriptionInput: Locator;
public readonly emptyState: Locator;
public readonly hostHeader: Locator;
@@ -60,58 +58,51 @@ export class ConnectionsPage extends BasePage {
public readonly schemaInput: Locator;
public readonly searchInput: Locator;
public readonly successAlert: Locator;
- // Sorting and filtering
public readonly tableHeader: Locator;
public readonly testConnectionButton: Locator;
public constructor(page: Page) {
super(page);
- // Table elements (Chakra UI DataTable)
- this.connectionsTable = page.locator('[role="grid"], table');
- this.emptyState = page.locator("text=/No connection found!/i");
+ this.connectionsTable = page.getByRole("grid").or(page.locator("table"));
+ this.emptyState = page.getByText(/no connection found/i);
- // Action buttons
this.addButton = page.getByRole("button", { name: "Add Connection" });
- this.testConnectionButton = page.locator('button:has-text("Test")');
+ this.testConnectionButton = page.getByRole("button", { name: /^test$/i });
this.saveButton = page.getByRole("button", { name: /^save$/i });
- // Form inputs (Chakra UI inputs)
- this.connectionForm = page.locator('[data-scope="dialog"][data-part="content"]');
+ // Scoped via input[name] because Chakra UI forms may lack
+ // associated <label> elements, making getByLabel unreliable.
+ this.connectionForm = page.getByRole("dialog");
this.connectionIdInput = page.locator('input[name="connection_id"]').first();
- this.connectionTypeSelect = page.getByRole("combobox").first();
this.hostInput = page.locator('input[name="host"]').first();
this.portInput = page.locator('input[name="port"]').first();
this.loginInput = page.locator('input[name="login"]').first();
- this.passwordInput = page.locator('input[name="password"], input[type="password"]').first();
+ this.passwordInput = page.locator('input[name="password"]').first();
this.schemaInput = page.locator('input[name="schema"]').first();
- // Try multiple possible selectors
this.descriptionInput = page.locator('[name="description"]').first();
- // Alerts
- this.successAlert = page.locator('[data-scope="toast"][data-part="root"]');
+ // Alerts — scoped to the notification region to avoid Monaco editor's role="alert" elements
+ this.successAlert = page.getByRole("region", { name: /notifications/i }).getByRole("status");
- // Delete confirmation dialog
- this.confirmDeleteButton = page.locator('button:has-text("Delete")').first();
+ // Button text is "Yes, Delete" (not just "Delete")
+ this.confirmDeleteButton = page.getByRole("button", { name: /yes, delete/i });
this.rowsPerPageSelect = page.locator("select");
- // Sorting and filtering
- this.tableHeader = page.locator('[role="columnheader"]').first();
- this.connectionIdHeader = page.locator("th:has-text('Connection ID')").first();
- this.connectionTypeHeader = page.locator('th:has-text("Connection Type")').first();
- this.hostHeader = page.locator('th:has-text("Host")').first();
- this.searchInput = page.locator('input[placeholder*="Search"], input[placeholder*="search"]').first();
+ // columnheader accessible name is "sort" (from inner button), so filter by text instead.
+ this.tableHeader = page.getByRole("columnheader").first();
+ this.connectionIdHeader = page.getByRole("columnheader").filter({ hasText: "Connection ID" });
+ this.connectionTypeHeader = page.getByRole("columnheader").filter({ hasText: "Connection Type" });
+ this.hostHeader = page.getByRole("columnheader").filter({ hasText: /^Host$/ });
+ this.searchInput = page.getByPlaceholder(/search/i);
}
- // Click the Add button to create a new connection
public async clickAddButton(): Promise<void> {
await expect(this.addButton).toBeVisible({ timeout: 5000 });
await expect(this.addButton).toBeEnabled({ timeout: 5000 });
await this.addButton.click();
- // Wait for form to load
await expect(this.connectionForm).toBeVisible({ timeout: 10_000 });
}
- // Click edit button for a specific connection
public async clickEditButton(connectionId: string): Promise<void> {
const row = await this.findConnectionRow(connectionId);
@@ -127,23 +118,16 @@ export class ConnectionsPage extends BasePage {
await expect(this.connectionForm).toBeVisible({ timeout: 10_000 });
}
- // Check if a connection exists in the current view
public async connectionExists(connectionId: string): Promise<boolean> {
- const emptyState = await this.page
- .locator("text=No connection found!")
- .isVisible({ timeout: 1000 })
- .catch(() => false);
+ const emptyState = await this.emptyState.isVisible({ timeout: 1000 }).catch(() => false);
if (emptyState) {
return false;
}
- const row = await this.findConnectionRow(connectionId);
- const visible = row !== null;
- return visible;
+ return (await this.findConnectionRow(connectionId)) !== undefined;
}
- // Create a new connection with full workflow
public async createConnection(details: ConnectionDetails): Promise<void> {
await this.clickAddButton();
await this.fillConnectionForm(details);
@@ -151,41 +135,29 @@ export class ConnectionsPage extends BasePage {
await this.waitForConnectionsListLoad();
}
- // Delete a connection by connection ID
public async deleteConnection(connectionId: string): Promise<void> {
- // await this.navigate();
const row = await this.findConnectionRow(connectionId);
if (!row) {
throw new Error(`Connection ${connectionId} not found`);
}
- // Find delete button in the row
- await this.page.evaluate(() => {
- const backdrops = document.querySelectorAll<HTMLElement>('[data-scope="dialog"][data-part="backdrop"]');
-
- backdrops.forEach((backdrop) => {
- const { state } = backdrop.dataset;
-
- if (state === "closed") {
- backdrop.remove();
- }
- });
- });
const deleteButton = row.getByRole("button", { name: "Delete Connection" });
await expect(deleteButton).toBeVisible({ timeout: 10_000 });
await expect(deleteButton).toBeEnabled({ timeout: 5000 });
- await deleteButton.click();
- await expect(this.confirmDeleteButton).toBeVisible({ timeout: 10_000 });
+ await expect(async () => {
+ await deleteButton.click({ timeout: 5000 });
+ await expect(this.confirmDeleteButton).toBeVisible({ timeout: 5000 });
+ }).toPass({ intervals: [2000], timeout: 30_000 });
+
await expect(this.confirmDeleteButton).toBeEnabled({ timeout: 5000 });
await this.confirmDeleteButton.click();
await expect(this.emptyState).toBeVisible({ timeout: 5000 });
}
- // Edit a connection by connection ID
public async editConnection(connectionId: string, updates: Partial<ConnectionDetails>): Promise<void> {
const row = await this.findConnectionRow(connectionId);
@@ -194,38 +166,29 @@ export class ConnectionsPage extends BasePage {
}
await this.clickEditButton(connectionId);
-
- // Wait for form to load
await expect(this.connectionIdInput).toBeVisible({ timeout: 10_000 });
-
- // Fill the fields that need updating
await this.fillConnectionForm(updates);
await this.saveConnection();
}
- // Fill connection form with details
public async fillConnectionForm(details: Partial<ConnectionDetails>): Promise<void> {
if (details.connection_id !== undefined && details.connection_id !== "") {
await this.connectionIdInput.fill(details.connection_id);
}
if (details.conn_type !== undefined && details.conn_type !== "") {
- // Click the select field to open the dropdown
- const selectCombobox = this.page.getByRole("combobox").first();
+ const selectInput = this.connectionForm.locator('[role="combobox"]').first();
- await expect(selectCombobox).toBeEnabled({ timeout: 25_000 });
+ await expect(async () => {
+ await expect(selectInput).toBeEnabled({ timeout: 10_000 });
+ await selectInput.click({ force: true, timeout: 5000 });
+ }).toPass({ intervals: [2000, 3000], timeout: 120_000 });
- await selectCombobox.click({ timeout: 10_000 });
+ await this.page.keyboard.type(details.conn_type);
- // Wait for options to appear and click the matching option
const option = this.page.getByRole("option", { name: new RegExp(details.conn_type, "i") }).first();
- await option.click({ timeout: 2000 }).catch(() => {
- // If option click fails, try typing in the input
- if (details.conn_type !== undefined && details.conn_type !== "") {
- void this.page.keyboard.type(details.conn_type);
- }
- });
+ await option.click({ timeout: 10_000 });
}
if (details.host !== undefined && details.host !== "") {
@@ -259,14 +222,14 @@ export class ConnectionsPage extends BasePage {
}
if (details.extra !== undefined && details.extra !== "") {
- const extraAccordion = this.page.locator('button:has-text("Extra Fields JSON")').first();
+ const extraAccordion = this.page.getByRole("button", { name: /extra fields json/i });
const accordionVisible = await extraAccordion.isVisible({ timeout: 5000 }).catch(() => false);
if (accordionVisible) {
await extraAccordion.click();
const monacoEditor = this.page.locator(".monaco-editor").first();
- await monacoEditor.waitFor({ state: "visible", timeout: 5000 });
+ await monacoEditor.waitFor({ state: "visible", timeout: 30_000 });
// Set value via Monaco API to avoid auto-closing bracket/quote issues with keyboard input
await monacoEditor.evaluate((container, value) => {
@@ -287,65 +250,35 @@ export class ConnectionsPage extends BasePage {
}
}, details.extra);
- // Click outside to trigger blur
await this.connectionIdInput.click();
}
}
}
- // Get connection count from current page
public async getConnectionCount(): Promise<number> {
const ids = await this.getConnectionIds();
return ids.length;
}
- // Get all connection IDs from the current page
public async getConnectionIds(): Promise<Array<string>> {
- await expect(this.page.locator("tbody tr").first()).toBeVisible({ timeout: 5000 });
-
- let stableRowCount = 0;
-
- await expect
- .poll(
- async () => {
- const count1 = await this.page.locator("tbody tr").count();
-
- await this.page.evaluate(() => new Promise((r) => setTimeout(r, 200)));
- const count2 = await this.page.locator("tbody tr").count();
-
- if (count1 === count2 && count1 > 0) {
- stableRowCount = count1;
-
- return true;
- }
-
- return false;
- },
- { intervals: [100, 200, 500], timeout: 10_000 },
- )
- .toBeTruthy()
- .catch(() => {
- // If timeout, just use current count
- stableRowCount = 0;
- });
+ const rowLocator = this.page.locator("tbody tr");
+ const stableRowCount = await waitForStableRowCount(rowLocator, { timeout: 10_000 }).catch(() => 0);
if (stableRowCount === 0) {
return [];
}
- let rows = this.page.locator("tbody tr");
const connectionIds: Array<string> = [];
- // Process all rows
for (let i = 0; i < stableRowCount; i++) {
try {
- const row = rows.nth(i);
+ const row = rowLocator.nth(i);
const cells = row.locator("td");
const cellCount = await cells.count();
if (cellCount > 1) {
- // Connection ID is typically in the second cell (after checkbox)
+ // Second cell (after checkbox) contains the connection ID.
const idCell = cells.nth(1);
const text = await idCell.textContent({ timeout: 3000 });
@@ -354,7 +287,6 @@ export class ConnectionsPage extends BasePage {
}
}
} catch {
- // Skip rows that can't be read
continue;
}
}
@@ -362,67 +294,60 @@ export class ConnectionsPage extends BasePage {
return connectionIds;
}
- // Navigate to Connections list page
public async navigate(): Promise<void> {
- await this.navigateTo(ConnectionsPage.connectionsListUrl);
- await this.waitForConnectionsListLoad();
+ await expect(async () => {
+ await this.navigateTo(ConnectionsPage.connectionsListUrl);
+ await this.waitForConnectionsListLoad();
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
- // Save the connection form
public async saveConnection(): Promise<void> {
await expect(this.saveButton).toBeVisible({ timeout: 10_000 });
await expect(this.saveButton).toBeEnabled({ timeout: 5000 });
await this.saveButton.click();
- // Wait for either redirect OR success message
await Promise.race([
this.page.waitForURL("**/connections", { timeout: 10_000 }),
- this.successAlert.waitFor({ state: "visible", timeout: 10_000 }),
+ this.successAlert.waitFor({ state: "visible", timeout: 30_000 }),
]);
+
+ // Ensure the dialog is fully closed before proceeding.
+ // Ark UI may leave the backdrop element in the DOM with data-state="closed",
+ // but it is non-interactive (pointer-events: none) and does not block clicks.
+ await expect(this.connectionForm).toBeHidden({ timeout: 10_000 });
}
- // Search for connections using the search input
public async searchConnections(searchTerm: string): Promise<void> {
- await (searchTerm === "" ? this.searchInput.clear() : this.searchInput.fill(searchTerm));
+ await expect(async () => {
+ await this.searchInput.fill(searchTerm);
+ await expect(this.searchInput).toHaveValue(searchTerm);
+ }).toPass({ intervals: [1000, 2000], timeout: 30_000 });
- // Wait for search to complete by checking results stability
await expect
.poll(
async () => {
const ids = await this.getConnectionIds();
-
- // If we expect no results
const isEmptyVisible = await this.emptyState.isVisible().catch(() => false);
if (isEmptyVisible) {
return ids.length === 0;
}
- // If we expect results, verify they match the search term
if (ids.length === 0) {
- return false; // Still loading
+ return false;
}
if (searchTerm === "") {
- // Get count twice to ensure it's stable
- const count1 = ids.length;
-
- await this.page.evaluate(() => new Promise((r) => setTimeout(r, 200)));
- const count2 = await this.getConnectionIds().then((allIds) => allIds.length);
-
- // Stable when count doesn't change
- return count1 === count2 && count1 > 0;
+ return ids.length > 0;
}
- // All visible IDs should contain the search term (case-insensitive)
return ids.every((id) => id.toLowerCase().includes(searchTerm.toLowerCase()));
},
- { message: "Search results did not match search term", timeout: 20_000 },
+ { message: "Search results did not match search term", timeout: 30_000 },
)
.toBeTruthy();
}
- // Verify connection details are displayed in the list
public async verifyConnectionInList(connectionId: string, expectedType: string): Promise<void> {
const row = await this.findConnectionRow(connectionId);
@@ -436,25 +361,23 @@ export class ConnectionsPage extends BasePage {
expect(rowText).toContain(expectedType);
}
- private async findConnectionRow(connectionId: string): Promise<Locator | null> {
- // Try search first (faster)
+ private async findConnectionRow(connectionId: string): Promise<Locator | undefined> {
const hasSearch = await this.searchInput.isVisible({ timeout: 500 }).catch(() => false);
if (hasSearch) {
return await this.findConnectionRowUsingSearch(connectionId);
}
- return null;
+ return undefined;
}
- private async findConnectionRowUsingSearch(connectionId: string): Promise<Locator | null> {
+ private async findConnectionRowUsingSearch(connectionId: string): Promise<Locator | undefined> {
await this.searchConnections(connectionId);
- // Check if table is visible (without throwing)
const isTableVisible = await this.connectionsTable.isVisible({ timeout: 5000 }).catch(() => false);
if (!isTableVisible) {
- return null;
+ return undefined;
}
const row = this.page.locator("tbody tr").filter({ hasText: connectionId }).first();
@@ -462,51 +385,26 @@ export class ConnectionsPage extends BasePage {
const rowExists = await row.isVisible({ timeout: 3000 }).catch(() => false);
if (!rowExists) {
- return null;
+ return undefined;
}
return row;
}
- // Wait for connections list to fully load
private async waitForConnectionsListLoad(): Promise<void> {
- await expect(this.page).toHaveURL(/\/connections/, { timeout: 3000 });
+ await expect(this.page).toHaveURL(/\/connections/, { timeout: 10_000 });
await this.page.waitForLoadState("domcontentloaded");
const table = this.connectionsTable;
- // Wait for either table or empty state
await expect(table.or(this.emptyState)).toBeVisible({ timeout: 10_000 });
- // If table exists, wait for rows
- if (await table.isVisible().catch(() => false)) {
- await this.page
- .locator("tbody tr")
- .first()
- .waitFor({ state: "visible", timeout: 10_000 })
- .catch(() => {
- // No rows found
- });
-
- // Wait for row count to stabilize
- await expect
- .poll(
- async () => {
- const count1 = await this.page.locator("tbody tr").count();
-
- if (count1 === 0) return true;
-
- await this.page.evaluate(() => new Promise((r) => setTimeout(r, 300)));
- const count2 = await this.page.locator("tbody tr").count();
-
- return count1 === count2;
- },
- { timeout: 15_000 },
- )
- .toBeTruthy()
- .catch(() => {
- // Timeout - proceed anyway
- });
+ const isTableVisible = await table.isVisible();
+
+ if (isTableVisible) {
+ const firstRow = this.page.locator("tbody tr").first();
+
+ await expect(firstRow.or(this.emptyState)).toBeVisible({ timeout: 15_000 });
}
}
}
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/DagCalendarTab.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/DagCalendarTab.ts
index 79e00c22266..77b6d465864 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/DagCalendarTab.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/DagCalendarTab.ts
@@ -95,13 +95,15 @@ export class DagCalendarTab extends BasePage {
for (let i = 0; i < count; i++) {
const cell = this.activeCells.nth(i);
+ // Firefox sometimes fails to trigger tooltips on hover.
+ // Retry the hover + tooltip visibility check to handle this.
let text = "";
await expect(async () => {
await cell.hover({ force: true });
await expect(this.tooltip).toBeVisible({ timeout: 3000 });
text = ((await this.tooltip.textContent()) ?? "").toLowerCase();
- }).toPass({ intervals: [500], timeout: 20_000 });
+ }).toPass({ intervals: [1000], timeout: 20_000 });
if (text.includes("success")) states.push("success");
if (text.includes("failed")) states.push("failed");
@@ -111,32 +113,29 @@ export class DagCalendarTab extends BasePage {
return states;
}
- public async navigateToCalendar(dagId: string) {
+ public async navigateToCalendar(dagId: string): Promise<void> {
await expect(async () => {
- await this.safeGoto(`/dags/${dagId}/calendar`);
+ await this.page.goto(`/dags/${dagId}/calendar`);
await expect(this.page.getByTestId("dag-calendar-root")).toBeVisible({ timeout: 5000 });
}).toPass({ intervals: [2000], timeout: 60_000 });
await this.waitForCalendarReady();
}
- public async switchToFailedView() {
+ public async switchToFailedView(): Promise<void> {
await this.failedToggle.click();
}
- public async switchToHourly() {
+ public async switchToHourly(): Promise<void> {
await this.hourlyToggle.click();
await expect(this.page.getByTestId("calendar-hourly-view")).toBeVisible({ timeout: 30_000 });
+ await this.waitForCalendarReady();
}
- public async switchToTotalView() {
+ public async switchToTotalView(): Promise<void> {
await this.totalToggle.click();
}
- public async verifyMonthGridRendered() {
- await this.waitForCalendarReady();
- }
-
private async waitForCalendarReady(): Promise<void> {
await expect(this.page.getByTestId("dag-calendar-root")).toBeVisible({ timeout: 120_000 });
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 1aab8fe84f8..bec63358e25 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/DagRunsPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/DagRunsPage.ts
@@ -35,26 +35,30 @@ export class DagRunsPage extends BasePage {
* Navigate to DAG Runs page and wait for data to load
*/
public async navigate(): Promise<void> {
- await this.navigateTo(DagRunsPage.dagRunsUrl);
- await this.page.waitForURL(/.*dag_runs/, { timeout: 15_000 });
- await expect(this.dagRunsTable).toBeVisible({ timeout: 10_000 });
+ await expect(async () => {
+ await this.navigateTo(DagRunsPage.dagRunsUrl);
+ await this.page.waitForURL(/.*dag_runs/, { timeout: 15_000 });
+ await expect(this.dagRunsTable).toBeVisible({ timeout: 10_000 });
- const dataLink = this.dagRunsTable.locator("a[href*='/dags/']").first();
- const noDataMessage = this.page.getByText("No Dag Runs found");
+ const dataLink = this.dagRunsTable.locator("a[href*='/dags/']").first();
+ const noDataMessage = this.page.getByText("No Dag Runs found");
- await expect(dataLink.or(noDataMessage)).toBeVisible({ timeout: 30_000 });
+ await expect(dataLink.or(noDataMessage)).toBeVisible({ timeout: 15_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
/**
* Verify DAG ID filtering via URL parameters
*/
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 expect(async () => {
+ await this.navigateTo(`${DagRunsPage.dagRunsUrl}?dag_id_pattern=${encodeURIComponent(dagIdPattern)}`);
+ await this.page.waitForURL(/.*dag_id_pattern=.*/, { timeout: 10_000 });
- const dataLinks = this.dagRunsTable.locator("a[href*='/dags/']");
+ const dataLinks = this.dagRunsTable.locator("a[href*='/dags/']");
- await expect(dataLinks.first()).toBeVisible({ timeout: 30_000 });
+ await expect(dataLinks.first()).toBeVisible({ timeout: 15_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
await expect(this.dagRunsTable).toBeVisible();
const rows = this.dagRunsTable.locator("tbody tr");
@@ -119,23 +123,32 @@ export class DagRunsPage extends BasePage {
/**
* Verify state filtering via URL parameters
*/
- public async verifyStateFiltering(expectedState: string): Promise<void> {
- await this.navigateTo(`${DagRunsPage.dagRunsUrl}?state=${expectedState.toLowerCase()}`);
- await this.page.waitForURL(/.*state=.*/, { timeout: 15_000 });
+ public async verifyStateFiltering(expectedState: string, dagIdPattern?: string): Promise<void> {
+ await expect(async () => {
+ const params = new URLSearchParams({ state: expectedState.toLowerCase() });
- const dataLinks = this.dagRunsTable.locator("a[href*='/dags/']");
+ if (dagIdPattern !== undefined) {
+ params.set("dag_id_pattern", dagIdPattern);
+ }
+ await this.navigateTo(`${DagRunsPage.dagRunsUrl}?${params.toString()}`);
+ await this.page.waitForURL(/.*state=.*/, { timeout: 10_000 });
- await expect(dataLinks.first()).toBeVisible({ timeout: 30_000 });
+ const dataLinks = this.dagRunsTable.locator("a[href*='/dags/']");
+
+ await expect(dataLinks.first()).toBeVisible({ timeout: 15_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
await expect(this.dagRunsTable).toBeVisible();
const rows = this.dagRunsTable.locator("tbody tr");
await expect(rows).not.toHaveCount(0);
- const rowCount = await rows.count();
+ await expect(async () => {
+ const rowCount = await rows.count();
- for (let i = 0; i < rowCount; i++) {
- await expect(rows.nth(i)).toContainText(new RegExp(expectedState, "i"));
- }
+ for (let i = 0; i < rowCount; i++) {
+ await expect(rows.nth(i)).toContainText(new RegExp(expectedState, "i"));
+ }
+ }).toPass({ intervals: [1000], timeout: 15_000 });
}
}
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/DagRunsTabPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/DagRunsTabPage.ts
index d60b73a73f6..f6b4a820401 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/DagRunsTabPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/DagRunsTabPage.ts
@@ -60,15 +60,11 @@ export class DagRunsTabPage extends BasePage {
currentUrl.searchParams.set("state", state.toLowerCase());
- const responsePromise = this.page.waitForResponse(
- (response) => response.url().includes("dagRuns") && response.request().method() === "GET",
- { timeout: 15_000 },
- );
-
- await this.navigateTo(currentUrl.pathname + currentUrl.search);
- await responsePromise;
- await expect(this.page).toHaveURL(/.*state=.*/, { timeout: 15_000 });
- await this.waitForRunsTableToLoad();
+ await expect(async () => {
+ await this.navigateTo(currentUrl.pathname + currentUrl.search);
+ await expect(this.page).toHaveURL(/.*state=.*/, { timeout: 10_000 });
+ await this.waitForRunsTableToLoad();
+ }).toPass({ intervals: [2000], timeout: 30_000 });
}
public async markRunAs(state: "failed" | "success"): Promise<void> {
@@ -122,12 +118,14 @@ export class DagRunsTabPage extends BasePage {
}
public async navigateToRunDetails(dagId: string, runId: string): Promise<void> {
- await this.navigateTo(`/dags/${dagId}/runs/${runId}`);
- await expect(this.page).toHaveURL(
- new RegExp(`/dags/${DagRunsTabPage.escapeRegExp(dagId)}/runs/${DagRunsTabPage.escapeRegExp(runId)}`),
- { timeout: 15_000 },
- );
- await expect(this.markRunAsButton).toBeVisible({ timeout: 15_000 });
+ await expect(async () => {
+ await this.navigateTo(`/dags/${dagId}/runs/${runId}`);
+ await expect(this.page).toHaveURL(
+ new RegExp(`/dags/${DagRunsTabPage.escapeRegExp(dagId)}/runs/${DagRunsTabPage.escapeRegExp(runId)}`),
+ { timeout: 15_000 },
+ );
+ await expect(this.markRunAsButton).toBeVisible({ timeout: 15_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
public async searchByRunIdPattern(pattern: string): Promise<void> {
@@ -135,15 +133,11 @@ export class DagRunsTabPage extends BasePage {
currentUrl.searchParams.set("run_id_pattern", pattern);
- const responsePromise = this.page.waitForResponse(
- (response) => response.url().includes("dagRuns") && response.request().method() === "GET",
- { timeout: 15_000 },
- );
-
- await this.navigateTo(currentUrl.pathname + currentUrl.search);
- await responsePromise;
- await expect(this.page).toHaveURL(/.*run_id_pattern=.*/, { timeout: 15_000 });
- await this.waitForRunsTableToLoad();
+ await expect(async () => {
+ await this.navigateTo(currentUrl.pathname + currentUrl.search);
+ await expect(this.page).toHaveURL(/.*run_id_pattern=.*/, { timeout: 10_000 });
+ await this.waitForRunsTableToLoad();
+ }).toPass({ intervals: [2000], timeout: 30_000 });
}
public async triggerDagRun(): Promise<string | undefined> {
@@ -233,7 +227,7 @@ export class DagRunsTabPage extends BasePage {
}
public async waitForRunsTableToLoad(): Promise<void> {
- await expect(this.runsTable).toBeVisible({ timeout: 10_000 });
+ await expect(this.runsTable).toBeVisible({ timeout: 30_000 });
const firstRow = this.tableRows.first();
const noDataMessage = this.page.getByText(/no.*dag.*runs.*found/i);
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/DagsPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/DagsPage.ts
index 2b6b0ef043f..4ffcc0a330e 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/DagsPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/DagsPage.ts
@@ -25,7 +25,6 @@ import type { DAGRunResponse } from "openapi/requests/types.gen";
* Dags Page Object
*/
export class DagsPage extends BasePage {
- // Page URLs
public static get dagsListUrl(): string {
return "/dags";
}
@@ -40,7 +39,6 @@ export class DagsPage extends BasePage {
public readonly runningFilter: Locator;
public readonly searchBox: Locator;
public readonly searchInput: Locator;
- public readonly stateElement: Locator;
public readonly successFilter: Locator;
public readonly tableViewButton: Locator;
public readonly triggerButton: Locator;
@@ -55,16 +53,14 @@ export class DagsPage extends BasePage {
this.triggerButton = page.getByTestId("trigger-dag-button");
// Scoped to the dialog so we never accidentally click the page-level trigger.
this.confirmButton = page.getByRole("dialog").getByRole("button", { name: "Trigger" });
- this.stateElement = page.getByTestId("dag-run-state");
+
this.searchBox = page.getByRole("textbox", { name: /search/i });
this.searchInput = page.getByPlaceholder("Search DAGs");
this.operatorFilter = page.getByTestId("operator-filter");
this.triggerRuleFilter = page.getByTestId("trigger-rule-filter");
this.retriesFilter = page.getByTestId("retries-filter");
- // View toggle buttons
this.cardViewButton = page.getByRole("button", { name: "Show card view" });
this.tableViewButton = page.getByRole("button", { name: "Show table view" });
- // Status filter buttons
this.successFilter = page.getByRole("button", { name: "Success" });
this.failedFilter = page.getByRole("button", { name: "Failed" });
this.runningFilter = page.getByRole("button", { name: "Running" });
@@ -73,7 +69,6 @@ export class DagsPage extends BasePage {
this.needsReviewFilter = page.getByTestId("dags-needs-review-filter");
}
- // URL builders for dynamic paths
public static getDagDetailUrl(dagName: string): string {
return `/dags/${dagName}`;
}
@@ -90,8 +85,10 @@ export class DagsPage extends BasePage {
.waitForResponse((resp: Response) => resp.url().includes("/api/v2/dags") && resp.status() === 200, {
timeout: 10_000,
})
- .catch(() => {
- /* API response may be cached */
+ .catch((error: unknown) => {
+ if (error instanceof Error && !error.message.includes("Timeout")) {
+ throw error;
+ }
});
// Click the clear button instead of programmatically clearing the input.
@@ -129,8 +126,10 @@ export class DagsPage extends BasePage {
.waitForResponse((resp: Response) => resp.url().includes("/api/v2/dags") && resp.status() === 200, {
timeout: 10_000,
})
- .catch(() => {
- // Some filters are applied client-side and don't trigger a network request.
+ .catch((error: unknown) => {
+ if (error instanceof Error && !error.message.includes("Timeout")) {
+ throw error;
+ }
});
await filterMap[status].click();
@@ -141,19 +140,29 @@ export class DagsPage extends BasePage {
await this.selectDropdownOption(this.triggerRuleFilter, rule);
}
+ /**
+ * Get a locator for a specific Dag link in the list (card or table view).
+ */
+ public getDagLink(dagId: string): Locator {
+ // Card view locator OR table view locator — only one will be visible.
+ return this.page
+ .locator('[data-testid="dag-id"]')
+ .filter({ hasText: dagId })
+ .or(this.page.locator('[data-testid="table-list"] tbody tr td a').filter({ hasText: dagId }));
+ }
+
/**
* Get all Dag links from the list
*/
public async getDagLinks(): Promise<Array<string>> {
await this.waitForDagList();
- // Check which view is active
const cardList = this.page.locator('[data-testid="card-list"]');
const isCardView = await cardList.isVisible();
const links = isCardView
? await this.page.locator('[data-testid="dag-id"]').all()
- : await this.page.locator('[data-testid="table-list"] tbody tr td:nth-child(2) a').all();
+ : await this.page.getByTestId("table-list").locator('tbody td a[href*="/dags/"]').all();
const hrefs: Array<string> = [];
@@ -174,13 +183,12 @@ export class DagsPage extends BasePage {
public async getDagNames(): Promise<Array<string>> {
await this.waitForDagList();
- // Check which view is active
const cardList = this.page.locator('[data-testid="card-list"]');
const isCardView = await cardList.isVisible();
const dagLinks = isCardView
? this.page.locator('[data-testid="dag-id"]')
- : this.page.locator('[data-testid="table-list"] tbody tr td:nth-child(2) a');
+ : this.page.getByTestId("table-list").locator('tbody td a[href*="/dags/"]');
const texts = await dagLinks.allTextContents();
@@ -193,32 +201,39 @@ export class DagsPage extends BasePage {
public async getDagsCount(): Promise<number> {
await this.waitForDagList();
- // Check which view is active
const cardList = this.page.locator('[data-testid="card-list"]');
const isCardView = await cardList.isVisible();
if (isCardView) {
- // Card view: count dag-id elements
return this.page.locator('[data-testid="dag-id"]').count();
}
- // Table view: count table body rows
- return this.page.locator('[data-testid="table-list"] tbody tr').count();
+ return this.page.getByTestId("table-list").locator("tbody tr").count();
}
public async getFilterOptions(filter: Locator): Promise<Array<string>> {
- await filter.click();
+ const state = await filter.getAttribute("data-state");
+
+ if (state === "open") {
+ await this.page.keyboard.press("Escape");
+ await expect(filter).toHaveAttribute("data-state", "closed", { timeout: 5000 });
+ }
+
+ await expect(async () => {
+ await filter.click({ timeout: 5000 });
+ await expect(filter).toHaveAttribute("data-state", "open", { timeout: 5000 });
+ }).toPass({ intervals: [1000, 2000], timeout: 15_000 });
const controlsId = await filter.getAttribute("aria-controls");
const dropdown =
controlsId === null
- ? this.page.locator('div[role="listbox"]').first()
+ ? this.page.locator('div[role="listbox"][data-state="open"]').first()
: this.page.locator(`[id="${controlsId}"]`);
-
- await expect(dropdown).toBeVisible({ timeout: 5000 });
const options = dropdown.locator('div[role="option"]');
+ await expect(options.first()).toBeVisible({ timeout: 10_000 });
+
const count = await options.count();
const dataValues: Array<string> = [];
@@ -230,12 +245,10 @@ export class DagsPage extends BasePage {
}
}
- await this.page.keyboard.press("Escape");
- // Wait for the dropdown to close. On WebKit, the listbox may stay in the DOM
- // with data-state="closed", while on other browsers it may be removed entirely.
- await expect(dropdown)
- .toBeHidden({ timeout: 5000 })
- .catch(() => expect(dropdown).toHaveAttribute("data-state", "closed", { timeout: 1000 }));
+ // Click outside to dismiss — Escape is unreliable on WebKit.
+ await this.page.locator("body").click({ position: { x: 0, y: 0 } });
+
+ await expect(dropdown.and(this.page.locator('[data-state="open"]'))).toBeHidden({ timeout: 5000 });
return dataValues;
}
@@ -244,38 +257,44 @@ export class DagsPage extends BasePage {
* Navigate to Dags list page
*/
public async navigate(): Promise<void> {
- // Set up API listener before navigation
- const responsePromise = this.page
- .waitForResponse((resp: Response) => resp.url().includes("/api/v2/dags") && resp.status() === 200, {
- timeout: 60_000,
- })
- .catch(() => {
- /* API might fail or timeout */
- });
-
- await this.navigateTo(DagsPage.dagsListUrl);
-
- // Wait for initial API response
- await responsePromise;
- await this.waitForDagList();
+ await expect(async () => {
+ await this.navigateTo(DagsPage.dagsListUrl);
+ await this.waitForDagList();
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
/**
* Navigate to Dag detail page
*/
public async navigateToDagDetail(dagName: string): Promise<void> {
- await this.navigateTo(DagsPage.getDagDetailUrl(dagName));
+ await expect(async () => {
+ await this.page.goto(DagsPage.getDagDetailUrl(dagName), { waitUntil: "domcontentloaded" });
+
+ const hydrationSignal = this.page
+ .getByRole("heading", { name: dagName })
+ .or(this.page.locator(`[data-testid="dag-name"]:has-text("${dagName}")`))
+ .first();
+
+ await expect(hydrationSignal).toBeVisible({ timeout: 10_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
+ }
+
+ /**
+ * Navigate to details tab and wait for heading to appear
+ */
+ public async navigateToDagDetails(dagName: string): Promise<void> {
+ await expect(async () => {
+ await this.page.goto(`/dags/${dagName}/details`, { waitUntil: "domcontentloaded" });
+ await expect(this.page.getByRole("heading", { name: dagName })).toBeVisible({ timeout: 30_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
public async navigateToDagTasks(dagId: string): Promise<void> {
await expect(async () => {
- await this.safeGoto(`/dags/${dagId}/tasks`);
- await expect(
- this.page
- .locator("th")
- .filter({ hasText: /^Operator$/ })
- .first(),
- ).toBeVisible({ timeout: 30_000 });
+ await this.page.goto(`/dags/${dagId}/tasks`, { waitUntil: "domcontentloaded" });
+ await expect(this.page.getByRole("columnheader", { name: "Operator" })).toBeVisible({
+ timeout: 30_000,
+ });
}).toPass({ intervals: [2000], timeout: 60_000 });
}
@@ -289,8 +308,10 @@ export class DagsPage extends BasePage {
.waitForResponse((resp: Response) => resp.url().includes("/dags") && resp.status() === 200, {
timeout: 30_000,
})
- .catch(() => {
- /* API might be cached */
+ .catch((error: unknown) => {
+ if (error instanceof Error && !error.message.includes("Timeout")) {
+ throw error;
+ }
});
await this.searchInput.fill(searchTerm);
@@ -321,22 +342,20 @@ export class DagsPage extends BasePage {
* Switch to card view
*/
public async switchToCardView(): Promise<void> {
- // Wait for the button to be visible and enabled
await expect(this.cardViewButton).toBeVisible({ timeout: 30_000 });
await expect(this.cardViewButton).toBeEnabled({ timeout: 10_000 });
await this.cardViewButton.click();
- await this.verifyCardViewVisible();
+ await this.waitForCardView();
}
/**
* Switch to table view
*/
public async switchToTableView(): Promise<void> {
- // Wait for the button to be visible and enabled
await expect(this.tableViewButton).toBeVisible({ timeout: 30_000 });
await expect(this.tableViewButton).toBeEnabled({ timeout: 10_000 });
await this.tableViewButton.click();
- await this.verifyTableViewVisible();
+ await this.waitForTableView();
}
/**
@@ -353,143 +372,59 @@ export class DagsPage extends BasePage {
}
/**
- * Verify card view is visible
+ * Wait for card view to be visible
*/
- public async verifyCardViewVisible(): Promise<void> {
+ public async waitForCardView(): Promise<void> {
await expect(this.page.locator('[data-testid="card-list"]')).toBeVisible({ timeout: 10_000 });
}
/**
- * Navigate to details tab and verify Dag details are displayed correctly
+ * Wait for DAG list to be rendered (card view, table view, or empty state).
*/
- public async verifyDagDetails(dagName: string): Promise<void> {
- await expect(async () => {
- await this.safeGoto(`/dags/${dagName}/details`, { waitUntil: "domcontentloaded" });
- await expect(this.page.getByRole("heading", { name: dagName })).toBeVisible({ timeout: 30_000 });
- }).toPass({ intervals: [2000], timeout: 60_000 });
- }
-
- /**
- * Verify if a specific Dag exists in the list
- */
- public async verifyDagExists(dagId: string): Promise<void> {
- await this.waitForDagList();
-
- // Check which view is active
- const cardList = this.page.locator('[data-testid="card-list"]');
- const isCardView = await cardList.isVisible();
-
- const dagLink = isCardView
- ? this.page.locator('[data-testid="dag-id"]').filter({ hasText: dagId })
- : this.page.locator('[data-testid="table-list"] tbody tr td a').filter({ hasText: dagId });
-
- await expect(dagLink).toBeVisible({ timeout: 10_000 });
- }
-
- public async verifyDagRunStatus(dagName: string, dagRunId: string | null): Promise<void> {
- if (dagRunId === null || dagRunId === "") {
- return;
- }
-
- await this.safeGoto(DagsPage.getDagRunDetailsUrl(dagName, dagRunId), {
- timeout: 15_000,
- waitUntil: "domcontentloaded",
- });
-
- await expect
- .poll(
- async () => {
- await expect(this.stateElement).toBeVisible({ timeout: 30_000 });
-
- const status = await this.getCurrentDagRunStatus();
-
- if (status === "failed") {
- throw new Error(`Dag run failed: ${dagRunId}`);
- }
-
- if (status !== "success") {
- await this.page.reload({ waitUntil: "domcontentloaded" });
- }
-
- return status;
- },
- {
- intervals: [10_000],
- message: `Dag run did not complete within the allowed time: ${dagRunId}`,
- timeout: 7 * 60 * 1000,
- },
- )
- .toBe("success");
- }
+ public async waitForDagList(): Promise<void> {
+ // Wait for actual rendered content — not skeletons, not bare table rows.
+ // Card view: dag-id links only render after data loads.
+ const dagCard = this.page.locator('[data-testid="dag-id"]').first();
+ const dagLink = this.page.locator('tbody td a[href*="/dags/"]').first();
+ const noDagFound = this.page.getByText(/no dag/i);
- /**
- * Verify that the Dags list is visible
- */
- public async verifyDagsListVisible(): Promise<void> {
- await this.waitForDagList();
+ await expect(dagCard.or(dagLink).or(noDagFound)).toBeVisible({ timeout: 60_000 });
}
/**
- * Verify table view is visible
+ * Wait for table view to be visible
*/
- public async verifyTableViewVisible(): Promise<void> {
+ public async waitForTableView(): Promise<void> {
await expect(this.page.locator("table")).toBeVisible({ timeout: 10_000 });
}
- private async getCurrentDagRunStatus(): Promise<string> {
- try {
- const statusText = await this.stateElement.textContent().catch(() => "");
- const status = statusText?.trim() ?? "";
-
- switch (status) {
- case "Failed":
- return "failed";
- case "Queued":
- return "queued";
- case "Running":
- return "running";
- case "Success":
- return "success";
- default:
- return "unknown";
- }
- } catch {
- return "unknown";
- }
- }
-
private async handleTriggerDialog(): Promise<string | null> {
- const responsePromise = this.page
- .waitForResponse(
- (response: Response) => {
- const url = response.url();
- const method = response.request().method();
-
- return (
- method === "POST" && Boolean(url.includes("dagRuns")) && Boolean(!url.includes("hitlDetails"))
- );
- },
- { timeout: 10_000 },
- )
- .catch(() => undefined);
-
await expect(this.confirmButton).toBeVisible({ timeout: 8000 });
await expect(this.confirmButton).toBeEnabled({ timeout: 10_000 });
+
+ const responsePromise = this.page.waitForResponse(
+ (response: Response) => {
+ const url = response.url();
+ const method = response.request().method();
+
+ return method === "POST" && Boolean(url.includes("dagRuns")) && Boolean(!url.includes("hitlDetails"));
+ },
+ { timeout: 30_000 },
+ );
+
await this.confirmButton.click();
const apiResponse = await responsePromise;
- if (apiResponse) {
- try {
- const responseBody = await apiResponse.text();
- const responseJson = JSON.parse(responseBody) as DAGRunResponse;
+ try {
+ const responseBody = await apiResponse.text();
+ const responseJson = JSON.parse(responseBody) as DAGRunResponse;
- if (Boolean(responseJson.dag_run_id)) {
- return responseJson.dag_run_id;
- }
- } catch {
- // Response parsing failed
+ if (Boolean(responseJson.dag_run_id)) {
+ return responseJson.dag_run_id;
}
+ } catch {
+ // Response parsing failed — return null so caller can handle.
}
// eslint-disable-next-line unicorn/no-null
@@ -497,65 +432,28 @@ export class DagsPage extends BasePage {
}
private async selectDropdownOption(filter: Locator, value: string): Promise<void> {
- await filter.click();
-
- const option = this.page.locator(`div[role="option"][data-value="${value}"]`);
-
- await expect(option).toBeVisible({ timeout: 5000 });
- await option.click();
-
- // Ensure the dropdown closes after selection. Chakra Select may not auto-close
- // reliably across browsers, so press Escape as a fallback.
- const listbox = this.page.locator('div[role="listbox"]');
+ await expect(async () => {
+ // Dismiss any open dropdown/overlay before clicking the target filter.
+ const currentState = await filter.getAttribute("data-state");
- await expect(listbox)
- .toBeHidden({ timeout: 5000 })
- .catch(async () => {
+ if (currentState === "open") {
await this.page.keyboard.press("Escape");
await expect(filter).toHaveAttribute("data-state", "closed", { timeout: 5000 });
- });
- }
-
- /**
- * Wait for DAG list to be rendered
- */
- private async waitForDagList(): Promise<void> {
- // Define multiple possible UI states: Card View, Table View, or Empty State.
- // Use regex (/no dag/i) to handle case and singular/plural variations
- // (e.g. "No Dag found", "No Dags found", "NO DAG FOUND").
- const cardList = this.page.locator('[data-testid="card-list"]');
- const tableList = this.page.locator('[data-testid="table-list"]');
- const noDagFound = this.page.getByText(/no dag/i);
- const fallbackTable = this.page.locator("table");
-
- // Wait for any of these elements to appear
- await expect(cardList.or(tableList).or(noDagFound).or(fallbackTable)).toBeVisible({
- timeout: 30_000,
- });
+ }
- // If empty state is shown, consider the list as successfully rendered
- if (await noDagFound.isVisible().catch(() => false)) {
- return;
- }
+ await filter.click({ timeout: 5000 });
+ await expect(filter).toHaveAttribute("data-state", "open", { timeout: 5000 });
- // Wait for loading to complete (skeletons to disappear)
- const skeleton = this.page.locator('[data-testid="skeleton"]');
+ const option = this.page.locator(`div[role="option"][data-value="${value}"]`);
- await expect(skeleton).toHaveCount(0, { timeout: 30_000 });
+ await expect(option).toBeVisible({ timeout: 5000 });
+ await option.click();
- // Now wait for actual DAG content based on current view
- const isCardView = await cardList.isVisible().catch(() => false);
+ if ((await filter.getAttribute("aria-expanded")) === "true") {
+ await this.page.keyboard.press("Escape");
+ }
- if (isCardView) {
- // Card view: wait for dag-id elements
- await expect(this.page.locator('[data-testid="dag-id"]').first()).toBeVisible({ timeout: 30_000 });
- } else {
- // Table view: prefer table-list testid, fallback to any <table> element
- const rowsInTableList = tableList.locator("tbody tr");
-
- await ((await rowsInTableList.count().catch(() => 0)) > 0
- ? expect(rowsInTableList.first()).toBeVisible({ timeout: 30_000 })
- : expect(fallbackTable.locator("tbody tr").first()).toBeVisible({ timeout: 30_000 }));
- }
+ await expect(filter).toHaveAttribute("data-state", "closed", { timeout: 5000 });
+ }).toPass({ intervals: [1000, 2000], timeout: 30_000 });
}
}
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/EventsPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/EventsPage.ts
index 5c72b431311..1fbf080b07d 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/EventsPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/EventsPage.ts
@@ -52,11 +52,12 @@ export class EventsPage extends BasePage {
public async addFilter(filterName: string): Promise<void> {
const filterButton = this.page.getByTestId("add-filter-button");
+ await expect(filterButton).toBeVisible({ timeout: 30_000 });
await filterButton.click();
const filterMenu = this.page.getByRole("menu");
- await expect(filterMenu).toBeVisible({ timeout: 10_000 });
+ await expect(filterMenu).toBeVisible({ timeout: 30_000 });
const menuItem = filterMenu.getByRole("menuitem", { name: filterName });
@@ -114,17 +115,19 @@ export class EventsPage extends BasePage {
}
public async navigate(): Promise<void> {
- await this.navigateTo("/events");
- await this.waitForTableLoad();
+ await expect(async () => {
+ await this.navigateTo("/events");
+ await this.waitForTableLoad();
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
public async navigateToAuditLog(dagId: string): Promise<void> {
await expect(async () => {
- await this.safeGoto(EventsPage.getEventsUrl(dagId), {
+ await this.page.goto(EventsPage.getEventsUrl(dagId), {
timeout: 10_000,
waitUntil: "domcontentloaded",
});
- await this.eventsTable.waitFor({ state: "visible", timeout: 5000 });
+ await expect(this.eventsTable).toBeVisible({ timeout: 10_000 });
}).toPass({ intervals: [2000], timeout: 60_000 });
await this.waitForTableLoad();
}
@@ -142,12 +145,41 @@ export class EventsPage extends BasePage {
.locator("input")
.first();
- await expect(filterInput).toBeVisible({ timeout: 10_000 });
+ await expect(filterInput).toBeVisible({ timeout: 30_000 });
await filterInput.fill(value);
+
+ const responsePromise = this.page.waitForResponse(
+ (res) => res.url().includes("/api/v2/eventLogs") && res.ok(),
+ { timeout: 30_000 },
+ );
+
await filterInput.press("Enter");
+ await responsePromise;
await this.waitForTableLoad();
}
+ public async verifyFilterMenuHasOptions(): Promise<void> {
+ const filterButton = this.page.getByTestId("add-filter-button");
+
+ await expect(filterButton).toBeVisible();
+ await filterButton.click();
+
+ const filterMenu = this.page.getByRole("menu");
+
+ await expect(filterMenu).toBeVisible({ timeout: 5000 });
+
+ const textSearchOptions = this.page.getByRole("menuitem").filter({
+ hasText: /DAG ID|Event Type|User/,
+ });
+
+ const textSearchOptionsCount = await textSearchOptions.count();
+
+ expect(textSearchOptionsCount).toBeGreaterThan(0);
+ await expect(textSearchOptions.first()).toBeVisible();
+
+ await this.page.keyboard.press("Escape");
+ }
+
public async verifyLogEntriesWithData(): Promise<void> {
await expect(this.tableRows).not.toHaveCount(0);
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/GridPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/GridPage.ts
index 6a043568ab5..27c62782b97 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/GridPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/GridPage.ts
@@ -87,9 +87,13 @@ export class GridPage extends BasePage {
const firstCell = this.gridCells.first();
await expect(firstCell).toBeVisible();
- await firstCell.hover();
- await expect(this.page.getByRole("tooltip").first()).toBeVisible({ timeout: 10_000 });
+ // Firefox may not trigger the tooltip on the first hover attempt.
+ await expect(async () => {
+ await this.page.mouse.move(0, 0);
+ await firstCell.hover();
+ await expect(this.page.getByRole("tooltip").first()).toBeVisible({ timeout: 5000 });
+ }).toPass({ intervals: [1000, 2000], timeout: 15_000 });
}
public async waitForGridToLoad(): Promise<void> {
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/HomePage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/HomePage.ts
index 672a6fab612..6bb209ba99e 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/HomePage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/HomePage.ts
@@ -23,7 +23,6 @@ import { BasePage } from "tests/e2e/pages/BasePage";
* Home/Dashboard Page Object
*/
export class HomePage extends BasePage {
- // Page URLs
public static get homeUrl(): string {
return "/";
}
@@ -34,18 +33,14 @@ export class HomePage extends BasePage {
public readonly dagRunMetrics: Locator;
public readonly failedDagsCard: Locator;
- // Health section elements
public readonly healthSection: Locator;
- // Historical Metrics section (recent runs)
public readonly historicalMetricsSection: Locator;
public readonly metaDatabaseHealth: Locator;
- // Pool Summary section
public readonly poolSummarySection: Locator;
public readonly runningDagsCard: Locator;
public readonly schedulerHealth: Locator;
- // Dashboard Stats elements
public readonly statsSection: Locator;
public readonly taskInstanceMetrics: Locator;
public readonly triggererHealth: Locator;
@@ -53,25 +48,24 @@ export class HomePage extends BasePage {
public constructor(page: Page) {
super(page);
- // Stats cards - using link patterns that match the StatsCard component
- this.failedDagsCard = page.locator('a[href*="last_dag_run_state=failed"]');
- this.runningDagsCard = page.locator('a[href*="last_dag_run_state=running"]');
- this.activeDagsCard = page.locator('a[href*="paused=false"]');
+ // Stats cards - using link role with accessible name. The card text includes the label
+ // (e.g. "Failed", "Running", "Active") so getByRole("link") with name is reliable.
+ // If the accessible name only renders as a number, fall back to href-based selectors.
+ this.failedDagsCard = page.getByRole("link", { name: /failed/i });
+ this.runningDagsCard = page.getByRole("link", { name: /running/i });
+ this.activeDagsCard = page.getByRole("link", { name: /active/i });
this.dagImportErrorsCard = page.getByRole("button", { name: "DAG Import Errors" });
- // Stats section - using role-based selector
+ // Navigate to parent via ".." since there are no ARIA landmark/region roles on these sections.
this.statsSection = page.getByRole("heading", { name: "Stats" }).locator("..");
- // Health section - using role-based selector
this.healthSection = page.getByRole("heading", { name: "Health" }).locator("..");
this.metaDatabaseHealth = page.getByText("Metadatabase").first();
this.schedulerHealth = page.getByText("Scheduler").first();
this.triggererHealth = page.getByText("Triggerer").first();
this.dagProcessorHealth = page.getByText("DAG Processor").first();
- // Pool Summary section - using role-based selector
this.poolSummarySection = page.getByRole("heading", { name: "Pool Summary" }).locator("..");
- // Historical Metrics section (recent runs) - using role-based selector
this.historicalMetricsSection = page.getByRole("heading", { name: "History" }).locator("..");
this.dagRunMetrics = page.getByRole("heading", { name: /dag run/i }).first();
this.taskInstanceMetrics = page.getByRole("heading", { name: /task instance/i }).first();
@@ -113,14 +107,19 @@ export class HomePage extends BasePage {
* Navigate to Home/Dashboard page
*/
public async navigate(): Promise<void> {
- await this.navigateTo(HomePage.homeUrl);
+ await expect(async () => {
+ await this.navigateTo(HomePage.homeUrl);
+ await expect(this.welcomeHeading).toBeVisible({ timeout: 10_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
/**
- * Wait for dashboard to fully load
+ * Wait for dashboard to fully load including stats data
*/
public async waitForDashboardLoad(): Promise<void> {
await expect(this.welcomeHeading).toBeVisible({ timeout: 30_000 });
+ await expect(this.statsSection).toBeVisible({ timeout: 30_000 });
+ await expect(this.activeDagsCard).toBeVisible({ timeout: 30_000 });
}
/**
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/LoginPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/LoginPage.ts
index eda41657f83..b3d0381bb1d 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/LoginPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/LoginPage.ts
@@ -24,7 +24,6 @@ import { BasePage } from "tests/e2e/pages/BasePage";
* Login Page Object
*/
export class LoginPage extends BasePage {
- // Page URLs
public static get loginUrl(): string {
return "/auth/login";
}
@@ -37,11 +36,11 @@ export class LoginPage extends BasePage {
public constructor(page: Page) {
super(page);
- this.usernameInput = page.locator('input[name="username"]');
- this.passwordInput = page.locator('input[name="password"]');
+ this.usernameInput = page.getByRole("textbox", { name: /username/i });
+ this.passwordInput = page.getByLabel(/password/i);
// Support both SimpleAuthManager and FabAuthManager login buttons
- this.loginButton = page.locator('button[type="submit"], input[type="submit"]');
- this.errorMessage = page.locator('span:has-text("Invalid credentials")');
+ this.loginButton = page.getByRole("button", { name: /sign in|log in|submit/i });
+ this.errorMessage = page.getByText("Invalid credentials");
}
public async expectLoginSuccess(): Promise<void> {
@@ -83,7 +82,10 @@ export class LoginPage extends BasePage {
public async navigate(): Promise<void> {
await this.maximizeBrowser();
- await this.navigateTo(LoginPage.loginUrl);
+ await expect(async () => {
+ await this.navigateTo(LoginPage.loginUrl);
+ await expect(this.loginButton).toBeVisible({ timeout: 10_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
public async navigateAndLogin(username: string, password: string): Promise<void> {
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/PluginsPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/PluginsPage.ts
index 08eaa97c593..636048b8949 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/PluginsPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/PluginsPage.ts
@@ -39,7 +39,10 @@ export class PluginsPage extends BasePage {
}
public async navigate(): Promise<void> {
- await this.navigateTo("/plugins");
+ await expect(async () => {
+ await this.navigateTo("/plugins");
+ await this.page.waitForURL(/.*plugins/, { timeout: 10_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
public async waitForLoad(): Promise<void> {
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/PoolsPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/PoolsPage.ts
index 6271374b343..605ac8cca70 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/PoolsPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/PoolsPage.ts
@@ -68,10 +68,6 @@ export class PoolsPage extends BasePage {
await saveButton.click();
await responsePromise;
- await Promise.any([
- expect(dialog).toBeHidden({ timeout: 10_000 }),
- expect(dialog).toHaveAttribute("data-state", "closed", { timeout: 10_000 }),
- ]);
}
public async deletePool(poolName: string): Promise<void> {
@@ -93,10 +89,6 @@ export class PoolsPage extends BasePage {
await confirmDeleteButton.click();
await responsePromise;
- await Promise.any([
- expect(confirmDialog).toBeHidden({ timeout: 10_000 }),
- expect(confirmDialog).toHaveAttribute("data-state", "closed", { timeout: 10_000 }),
- ]);
}
public async editPoolSlots(poolName: string, newSlots: number): Promise<void> {
@@ -125,10 +117,6 @@ export class PoolsPage extends BasePage {
await saveButton.click();
await responsePromise;
- await Promise.any([
- expect(dialog).toBeHidden({ timeout: 10_000 }),
- expect(dialog).toHaveAttribute("data-state", "closed", { timeout: 10_000 }),
- ]);
}
public getPoolCard(poolName: string): Locator {
@@ -136,9 +124,11 @@ export class PoolsPage extends BasePage {
}
public async navigate(): Promise<void> {
- await this.navigateTo(PoolsPage.poolsUrl);
- await this.page.waitForURL("**/pools", { timeout: 15_000 });
- await expect(this.cardList).toBeVisible({ timeout: 15_000 });
+ await expect(async () => {
+ await this.navigateTo(PoolsPage.poolsUrl);
+ await this.page.waitForURL("**/pools", { timeout: 15_000 });
+ await expect(this.addPoolButton).toBeVisible({ timeout: 15_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
public async verifyPoolExists(poolName: string): Promise<void> {
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/ProvidersPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/ProvidersPage.ts
index f87d9f72a6b..a894f225f34 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/ProvidersPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/ProvidersPage.ts
@@ -44,14 +44,35 @@ export class ProvidersPage extends BasePage {
return this.rows.nth(index).locator("td").nth(2);
}
+ public async getRowCount(): Promise<number> {
+ return this.rows.count();
+ }
+
+ public async getRowDetails(index: number): Promise<{
+ description: string;
+ packageName: string;
+ version: string;
+ }> {
+ const packageName = ((await this.packageLinkAt(index).textContent()) ?? "").trim();
+ const version = ((await this.versionCellAt(index).textContent()) ?? "").trim();
+ const description = ((await this.descriptionCellAt(index).textContent()) ?? "").trim();
+
+ return { description, packageName, version };
+ }
+
public async navigate(): Promise<void> {
- await this.navigateTo("/providers");
+ await expect(async () => {
+ await this.navigateTo("/providers");
+ await this.page.waitForURL(/.*providers/, { timeout: 10_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
public async navigateFromAdminMenu(): Promise<void> {
- await this.navigateTo("/");
- await this.adminMenuButton.click();
- await expect(this.providersMenuItem).toBeVisible();
+ await expect(async () => {
+ await this.navigateTo("/");
+ await this.adminMenuButton.click();
+ await expect(this.providersMenuItem).toBeVisible({ timeout: 10_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
await this.providersMenuItem.click();
}
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/RequiredActionsPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/RequiredActionsPage.ts
index db04ec56cc9..c3e619998c7 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/RequiredActionsPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/RequiredActionsPage.ts
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { expect, type Locator, type Page } from "@playwright/test";
+import { expect, type APIRequestContext, type Locator, type Page } from "@playwright/test";
+import { testConfig } from "playwright.config";
import { BasePage } from "./BasePage";
import { DagsPage } from "./DagsPage";
@@ -26,8 +27,12 @@ export class RequiredActionsPage extends BasePage {
public readonly emptyStateMessage: Locator;
public readonly pageHeading: Locator;
- public constructor(page: Page) {
+ // Standalone API context — page.request degrades after many navigations in WebKit.
+ private readonly apiRequest: APIRequestContext;
+
+ public constructor(page: Page, apiRequest?: APIRequestContext) {
super(page);
+ this.apiRequest = apiRequest ?? page.request;
this.pageHeading = page.getByRole("heading").filter({ hasText: /required action/i });
this.actionsTable = page.getByTestId("table-list");
this.emptyStateMessage = page.getByText(/no required actions found/i);
@@ -53,43 +58,70 @@ export class RequiredActionsPage extends BasePage {
}
public async navigateToRequiredActionsPage(): Promise<void> {
- await this.navigateTo(RequiredActionsPage.getRequiredActionsUrl());
- await expect(this.pageHeading).toBeVisible({ timeout: 10_000 });
+ await expect(async () => {
+ await this.navigateTo(RequiredActionsPage.getRequiredActionsUrl());
+ await expect(this.pageHeading).toBeVisible({ timeout: 10_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
- public async runHITLFlowWithApproval(dagId: string): Promise<void> {
- await this.runHITLFlow(dagId, true);
+ public async runHITLFlowWithApproval(dagId: string): Promise<string> {
+ return this.runHITLFlow(dagId, true);
}
- public async runHITLFlowWithRejection(dagId: string): Promise<void> {
- await this.runHITLFlow(dagId, false);
+ public async runHITLFlowWithRejection(dagId: string): Promise<string> {
+ return this.runHITLFlow(dagId, false);
}
private async clickButtonAndWaitForHITLResponse(button: Locator): Promise<void> {
- const responsePromise = this.page.waitForResponse(
- (res) => res.url().includes("hitlDetails") && res.request().method() === "PATCH",
- { timeout: 30_000 },
- );
+ await expect(async () => {
+ const responsePromise = this.page.waitForResponse(
+ (res) => res.url().includes("hitlDetails") && res.request().method() === "PATCH",
+ { timeout: 30_000 },
+ );
- await button.click();
- await responsePromise;
+ await button.click();
+ const response = await responsePromise;
+
+ expect(response.ok(), `HITL PATCH failed with status ${response.status()}`).toBeTruthy();
+ }).toPass({ intervals: [3000, 5000], timeout: 60_000 });
}
private async clickOnTaskInGrid(dagRunId: string, taskId: string): Promise<void> {
const taskLocator = this.page.getByTestId(`grid-${dagRunId}-${taskId}`);
- await expect(taskLocator).toBeVisible({ timeout: 5000 });
- await taskLocator.click();
- }
+ await expect(async () => {
+ const gridDataLoaded = this.page.waitForResponse((res) => res.url().includes("/grid") && res.ok(), {
+ timeout: 30_000,
+ });
- private async handleApprovalTask(dagId: string, dagRunId: string, approve: boolean): Promise<void> {
- await this.waitForTaskState(dagRunId, { expectedState: "Deferred", taskId: "valid_input_and_options" });
+ await this.page.reload({ waitUntil: "domcontentloaded" });
+ await gridDataLoaded;
+ await expect(taskLocator).toBeVisible({ timeout: 20_000 });
+ await this.page.mouse.move(0, 0);
+ await taskLocator.click({ timeout: 5000 });
+ }).toPass({ intervals: [5000, 10_000, 15_000], timeout: 120_000 });
+ }
+
+ private async clickRequiredActionLink(): Promise<void> {
const requiredActionLink = this.page.getByRole("link", { name: /required action/i });
await expect(requiredActionLink).toBeVisible({ timeout: 30_000 });
+
await requiredActionLink.click();
+ // Use a specific URL pattern to avoid matching intermediate router states.
+ await this.page.waitForURL(/\/dags\/.*\/runs\/.*\/tasks\//, { timeout: 30_000 });
+ }
+
+ private async handleApprovalTask(dagId: string, dagRunId: string, approve: boolean): Promise<void> {
+ await this.waitForTaskState(dagId, dagRunId, {
+ expectedState: "Deferred",
+ taskId: "valid_input_and_options",
+ });
+
+ await this.clickRequiredActionLink();
+
const buttonName = approve ? "Approve" : "Reject";
const actionButton = this.page.getByTestId(`hitl-option-${buttonName}`);
@@ -104,34 +136,37 @@ export class RequiredActionsPage extends BasePage {
await expect(actionButton).toBeEnabled({ timeout: 10_000 });
await this.clickButtonAndWaitForHITLResponse(actionButton);
- await this.safeGoto(`/dags/${dagId}/runs/${dagRunId}`);
- await this.waitForTaskState(dagRunId, { expectedState: "Success", taskId: "valid_input_and_options" });
+ await this.page.goto(`/dags/${dagId}/runs/${dagRunId}`);
+ await this.waitForTaskState(dagId, dagRunId, {
+ expectedState: "Success",
+ taskId: "valid_input_and_options",
+ });
}
private async handleBranchTask(dagId: string, dagRunId: string): Promise<void> {
- await this.waitForTaskState(dagRunId, { expectedState: "Deferred", taskId: "choose_a_branch_to_run" });
-
- const requiredActionLink = this.page.getByRole("link", { name: /required action/i });
+ await this.waitForTaskState(dagId, dagRunId, {
+ expectedState: "Deferred",
+ taskId: "choose_a_branch_to_run",
+ });
- await expect(requiredActionLink).toBeVisible({ timeout: 30_000 });
- await requiredActionLink.click();
+ await this.clickRequiredActionLink();
const branchButton = this.page.getByTestId("hitl-option-task_1");
await expect(branchButton).toBeVisible({ timeout: 30_000 });
await this.clickButtonAndWaitForHITLResponse(branchButton);
- await this.safeGoto(`/dags/${dagId}/runs/${dagRunId}`);
- await this.waitForTaskState(dagRunId, { expectedState: "Success", taskId: "choose_a_branch_to_run" });
+ await this.page.goto(`/dags/${dagId}/runs/${dagRunId}`);
+ await this.waitForTaskState(dagId, dagRunId, {
+ expectedState: "Success",
+ taskId: "choose_a_branch_to_run",
+ });
}
private async handleWaitForInputTask(dagId: string, dagRunId: string): Promise<void> {
- await this.waitForTaskState(dagRunId, { expectedState: "Deferred", taskId: "wait_for_input" });
-
- const requiredActionLink = this.page.getByRole("link", { name: /required action/i });
+ await this.waitForTaskState(dagId, dagRunId, { expectedState: "Deferred", taskId: "wait_for_input" });
- await expect(requiredActionLink).toBeVisible({ timeout: 30_000 });
- await requiredActionLink.click();
+ await this.clickRequiredActionLink();
const informationInput = this.page.getByRole("textbox");
@@ -143,21 +178,23 @@ export class RequiredActionsPage extends BasePage {
await expect(okButton).toBeVisible({ timeout: 10_000 });
await this.clickButtonAndWaitForHITLResponse(okButton);
- await this.safeGoto(`/dags/${dagId}/runs/${dagRunId}`);
- await this.waitForTaskState(dagRunId, { expectedState: "Success", taskId: "wait_for_input" });
+ await this.page.goto(`/dags/${dagId}/runs/${dagRunId}`);
+ await this.waitForTaskState(dagId, dagRunId, { expectedState: "Success", taskId: "wait_for_input" });
}
private async handleWaitForMultipleOptionsTask(dagId: string, dagRunId: string): Promise<void> {
- await this.waitForTaskState(dagRunId, { expectedState: "Deferred", taskId: "wait_for_multiple_options" });
-
- const requiredActionLink = this.page.getByRole("link", { name: /required action/i });
-
- await expect(requiredActionLink).toBeVisible({ timeout: 30_000 });
- await requiredActionLink.click();
+ await this.waitForTaskState(dagId, dagRunId, {
+ expectedState: "Deferred",
+ taskId: "wait_for_multiple_options",
+ });
const multiSelectContainer = this.page.getByRole("combobox", { name: /select one or multiple values/i });
- await expect(multiSelectContainer).toBeVisible({ timeout: 30_000 });
+ await expect(async () => {
+ await this.clickRequiredActionLink();
+ await expect(multiSelectContainer).toBeVisible({ timeout: 15_000 });
+ }).toPass({ intervals: [5000], timeout: 60_000 });
+
await multiSelectContainer.click();
await this.page.getByRole("option", { name: "option 4" }).click();
@@ -169,28 +206,28 @@ export class RequiredActionsPage extends BasePage {
await expect(respondButton).toBeVisible({ timeout: 10_000 });
await this.clickButtonAndWaitForHITLResponse(respondButton);
- await this.safeGoto(`/dags/${dagId}/runs/${dagRunId}`);
- await this.waitForTaskState(dagRunId, { expectedState: "Success", taskId: "wait_for_multiple_options" });
+ await this.page.goto(`/dags/${dagId}/runs/${dagRunId}`);
+ await this.waitForTaskState(dagId, dagRunId, {
+ expectedState: "Success",
+ taskId: "wait_for_multiple_options",
+ });
}
private async handleWaitForOptionTask(dagId: string, dagRunId: string): Promise<void> {
- await this.waitForTaskState(dagRunId, { expectedState: "Deferred", taskId: "wait_for_option" });
+ await this.waitForTaskState(dagId, dagRunId, { expectedState: "Deferred", taskId: "wait_for_option" });
- const requiredActionLink = this.page.getByRole("link", { name: /required action/i });
-
- await expect(requiredActionLink).toBeVisible({ timeout: 30_000 });
- await requiredActionLink.click();
+ await this.clickRequiredActionLink();
const optionButton = this.page.getByTestId("hitl-option-option 1");
await expect(optionButton).toBeVisible({ timeout: 30_000 });
await this.clickButtonAndWaitForHITLResponse(optionButton);
- await this.safeGoto(`/dags/${dagId}/runs/${dagRunId}`);
- await this.waitForTaskState(dagRunId, { expectedState: "Success", taskId: "wait_for_option" });
+ await this.page.goto(`/dags/${dagId}/runs/${dagRunId}`);
+ await this.waitForTaskState(dagId, dagRunId, { expectedState: "Success", taskId: "wait_for_option" });
}
- private async runHITLFlow(dagId: string, approve: boolean): Promise<void> {
+ private async runHITLFlow(dagId: string, approve: boolean): Promise<string> {
const dagsPage = new DagsPage(this.page);
const dagRunId = await dagsPage.triggerDag(dagId);
@@ -199,13 +236,12 @@ export class RequiredActionsPage extends BasePage {
throw new Error("Failed to trigger DAG - dagRunId is null");
}
- await this.safeGoto(`/dags/${dagId}/runs/${dagRunId}`);
- await this.waitForDagRunState("Running");
+ await this.waitForDagRunState(dagId, dagRunId, "Running");
- await this.waitForTaskState(dagRunId, {
+ await this.waitForTaskState(dagId, dagRunId, {
expectedState: "Success",
taskId: "wait_for_default_option",
- timeout: 60_000,
+ timeout: 120_000,
});
await this.handleWaitForInputTask(dagId, dagRunId);
@@ -221,53 +257,151 @@ export class RequiredActionsPage extends BasePage {
}
await this.verifyFinalTaskStates(dagId, dagRunId, approve);
+
+ return dagRunId;
}
private async verifyFinalTaskStates(dagId: string, dagRunId: string, approved: boolean): Promise<void> {
- await this.safeGoto(`/dags/${dagId}/runs/${dagRunId}`);
+ await this.page.goto(`/dags/${dagId}/runs/${dagRunId}`);
if (approved) {
- await this.waitForTaskState(dagRunId, { expectedState: "Success", taskId: "task_1" });
- await this.waitForTaskState(dagRunId, { expectedState: "Skipped", taskId: "task_2", timeout: 30_000 });
- await this.waitForTaskState(dagRunId, { expectedState: "Skipped", taskId: "task_3", timeout: 30_000 });
+ await this.waitForTaskState(dagId, dagRunId, { expectedState: "Success", taskId: "task_1" });
+ await this.waitForTaskState(dagId, dagRunId, {
+ expectedState: "Skipped",
+ taskId: "task_2",
+ timeout: 30_000,
+ });
+ await this.waitForTaskState(dagId, dagRunId, {
+ expectedState: "Skipped",
+ taskId: "task_3",
+ timeout: 30_000,
+ });
} else {
- await this.waitForTaskState(dagRunId, {
+ await this.waitForTaskState(dagId, dagRunId, {
expectedState: "Skipped",
taskId: "choose_a_branch_to_run",
timeout: 30_000,
});
- await this.waitForTaskState(dagRunId, { expectedState: "Skipped", taskId: "task_1", timeout: 30_000 });
- await this.waitForTaskState(dagRunId, { expectedState: "Skipped", taskId: "task_2", timeout: 30_000 });
- await this.waitForTaskState(dagRunId, { expectedState: "Skipped", taskId: "task_3", timeout: 30_000 });
+ await this.waitForTaskState(dagId, dagRunId, {
+ expectedState: "Skipped",
+ taskId: "task_1",
+ timeout: 30_000,
+ });
+ await this.waitForTaskState(dagId, dagRunId, {
+ expectedState: "Skipped",
+ taskId: "task_2",
+ timeout: 30_000,
+ });
+ await this.waitForTaskState(dagId, dagRunId, {
+ expectedState: "Skipped",
+ taskId: "task_3",
+ timeout: 30_000,
+ });
}
await this.navigateToRequiredActionsPage();
await expect(this.actionsTable).toBeVisible({ timeout: 10_000 });
}
- private async waitForDagRunState(expectedState: string): Promise<void> {
- await expect(async () => {
- await this.page.reload();
- const detailsPanel = this.page.locator("#details-panel");
- const stateBadge = detailsPanel.getByTestId("state-badge").first();
+ private async waitForDagRunState(dagId: string, runId: string, expectedState: string): Promise<void> {
+ const { baseUrl } = testConfig.connection;
+
+ await expect
+ .poll(
+ async () => {
+ try {
+ const response = await this.apiRequest.get(`${baseUrl}/api/v2/dags/${dagId}/dagRuns/${runId}`, {
+ timeout: 30_000,
+ });
+
+ if (!response.ok()) {
+ return "unknown";
+ }
+
+ const data = (await response.json()) as { state: string };
+
+ return data.state;
+ } catch {
+ // Transient network/timeout errors — let expect.poll retry.
+ return "unknown";
+ }
+ },
+ {
+ intervals: [5000],
+ message: `DAG run ${runId} did not reach state "${expectedState}"`,
+ timeout: 120_000,
+ },
+ )
+ .toBe(expectedState.toLowerCase());
+
+ // toPass handles transient states between API response and page render.
+ await this.page.goto(`/dags/${dagId}/runs/${runId}`);
+ const detailsPanel = this.page.locator("#details-panel");
+ const stateBadge = detailsPanel.getByTestId("state-badge").first();
- await expect(stateBadge).toContainText(expectedState, { timeout: 5000 });
- }).toPass({ timeout: 180_000 });
+ await expect(async () => {
+ await expect(stateBadge).toBeVisible({ timeout: 5000 });
+ await expect(stateBadge).toContainText(new RegExp(expectedState, "i"), { timeout: 5000 });
+ }).toPass({ intervals: [2000], timeout: 30_000 });
}
private async waitForTaskState(
+ dagId: string,
dagRunId: string,
options: { expectedState: string; taskId: string; timeout?: number },
): Promise<void> {
- await expect(async () => {
- await this.page.reload();
-
- await this.clickOnTaskInGrid(dagRunId, options.taskId);
+ const { baseUrl } = testConfig.connection;
+
+ const terminalStates = new Set(["success", "failed", "skipped", "removed", "upstream_failed"]);
+
+ await expect
+ .poll(
+ async () => {
+ try {
+ const response = await this.apiRequest.get(
+ `${baseUrl}/api/v2/dags/${dagId}/dagRuns/${dagRunId}/taskInstances/${options.taskId}`,
+ { timeout: 30_000 },
+ );
+
+ if (!response.ok()) {
+ return "unknown";
+ }
+
+ const data = (await response.json()) as { state: string };
+ const { state } = data;
+ const expected = options.expectedState.toLowerCase();
+
+ if (state !== expected && terminalStates.has(state)) {
+ throw new Error(
+ `Task ${options.taskId} reached terminal state "${state}" instead of "${expected}"`,
+ );
+ }
+
+ return state;
+ } catch (error) {
+ if (error instanceof Error && error.message.includes("terminal state")) {
+ throw error;
+ }
+
+ return "unknown";
+ }
+ },
+ {
+ intervals: [5000],
+ message: `Task ${options.taskId} did not reach state "${options.expectedState}"`,
+ timeout: options.timeout ?? 120_000,
+ },
+ )
+ .toBe(options.expectedState.toLowerCase());
+
+ await this.clickOnTaskInGrid(dagRunId, options.taskId);
+
+ const detailsPanel = this.page.locator("#details-panel");
+ const stateBadge = detailsPanel.getByTestId("state-badge").first();
- const detailsPanel = this.page.locator("#details-panel");
- const stateBadge = detailsPanel.getByTestId("state-badge").first();
-
- await expect(stateBadge).toContainText(options.expectedState, { timeout: 5000 });
- }).toPass({ timeout: options.timeout ?? 120_000 });
+ await expect(async () => {
+ await expect(stateBadge).toBeVisible({ timeout: 5000 });
+ await expect(stateBadge).toContainText(new RegExp(options.expectedState, "i"), { timeout: 5000 });
+ }).toPass({ intervals: [2000], timeout: 30_000 });
}
}
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/TaskInstancePage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/TaskInstancePage.ts
index b64cdd61087..7aff1a20a8b 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/TaskInstancePage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/TaskInstancePage.ts
@@ -40,7 +40,11 @@ export class TaskInstancePage extends BasePage {
}
public async navigateToTaskInstance(dagId: string, runId: string, taskId: string): Promise<void> {
- await this.navigateTo(`/dags/${dagId}/runs/${runId}/tasks/${taskId}`);
+ await expect(async () => {
+ await this.navigateTo(`/dags/${dagId}/runs/${runId}/tasks/${taskId}`);
+ // #details-panel content depends on chained API calls that can be slow on WebKit.
+ await expect(this.page.locator("#details-panel")).toBeVisible({ timeout: 10_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
public async triggerDagAndWaitForSuccess(dagId: string): Promise<void> {
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/TaskInstancesPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/TaskInstancesPage.ts
index 42a8f3cae3d..5da2b8b2e3e 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/TaskInstancesPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/TaskInstancesPage.ts
@@ -28,19 +28,21 @@ export class TaskInstancesPage extends BasePage {
public constructor(page: Page) {
super(page);
- this.taskInstancesTable = page.locator('table, div[role="table"]');
+ this.taskInstancesTable = page.getByRole("table");
}
/**
* Navigate to Task Instances page and wait for data to load
*/
public async navigate(): Promise<void> {
- await this.navigateTo(TaskInstancesPage.taskInstancesUrl);
- await this.page.waitForURL(/.*task_instances/, { timeout: 15_000 });
- await this.taskInstancesTable.waitFor({ state: "visible", timeout: 30_000 });
+ await expect(async () => {
+ await this.navigateTo(TaskInstancesPage.taskInstancesUrl);
+ await this.page.waitForURL(/.*task_instances/, { timeout: 15_000 });
+ await expect(this.taskInstancesTable).toBeVisible({ timeout: 10_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
- const dataLink = this.taskInstancesTable.locator("a[href*='/dags/']").first();
- const noDataMessage = this.page.locator('text="No Task Instances found"');
+ const dataLink = this.taskInstancesTable.getByRole("link").first();
+ const noDataMessage = this.page.getByText("No Task Instances found");
await expect(dataLink.or(noDataMessage)).toBeVisible({ timeout: 30_000 });
}
@@ -48,20 +50,27 @@ export class TaskInstancesPage extends BasePage {
/**
* Verify state filtering via URL parameters
*/
- public async verifyStateFiltering(expectedState: string): Promise<void> {
- await this.navigateTo(`${TaskInstancesPage.taskInstancesUrl}?task_state=${expectedState.toLowerCase()}`);
- await this.page.waitForURL(/.*task_state=.*/, { timeout: 15_000 });
- await this.page.waitForLoadState("networkidle");
+ public async verifyStateFiltering(expectedState: string, dagId?: string): Promise<void> {
+ const params = new URLSearchParams({ task_state: expectedState.toLowerCase() });
- const dataLink = this.taskInstancesTable.locator("a[href*='/dags/']").first();
+ if (dagId !== undefined) {
+ params.set("dag_id", dagId);
+ }
+ await expect(async () => {
+ await this.navigateTo(`${TaskInstancesPage.taskInstancesUrl}?${params.toString()}`);
+ await this.page.waitForURL(/.*task_state=.*/, { timeout: 15_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
+
+ const dataLink = this.taskInstancesTable.getByRole("link").first();
await expect(dataLink).toBeVisible({ timeout: 30_000 });
await expect(this.taskInstancesTable).toBeVisible();
- const rowsAfterFilter = this.taskInstancesTable.locator(
- 'tbody tr:not(.no-data), div[role="row"]:not(:first-child)',
- );
- const noDataMessage = this.page.locator("text=/No.*found/i, text=/No.*results/i, text=/Empty/i");
+ // getByRole("row") returns all rows including the header; filter to data rows only.
+ const rowsAfterFilter = this.taskInstancesTable
+ .getByRole("row")
+ .filter({ hasNot: this.taskInstancesTable.getByRole("columnheader") });
+ const noDataMessage = this.page.getByText(/no .* found|no .* results/i);
const stateBadges = this.taskInstancesTable.locator('[class*="badge"], [class*="Badge"]');
await expect(stateBadges.first().or(noDataMessage.first())).toBeVisible({ timeout: 30_000 });
@@ -89,21 +98,21 @@ export class TaskInstancesPage extends BasePage {
* Verify that task instance details are displayed correctly
*/
public async verifyTaskDetailsDisplay(): Promise<void> {
- const firstRow = this.taskInstancesTable.locator("tbody tr, div[role='row']:not(:first-child)").first();
+ const firstRow = this.taskInstancesTable.getByRole("row").nth(1);
- const dagIdLink = firstRow.locator("a[href*='/dags/']").first();
+ const dagIdLink = firstRow.getByRole("link").first();
if ((await dagIdLink.count()) > 0) {
await expect(dagIdLink).toBeVisible();
expect((await dagIdLink.textContent())?.trim()).toBeTruthy();
}
- const allCells = firstRow.locator('td, div[role="cell"]');
+ const allCells = firstRow.getByRole("cell");
const cellCount = await allCells.count();
expect(cellCount).toBeGreaterThan(1);
- const runIdLink = firstRow.locator("a[href*='/runs/']").first();
+ const runIdLink = firstRow.getByRole("link").nth(1);
if ((await runIdLink.count()) > 0) {
await expect(runIdLink).toBeVisible();
@@ -117,7 +126,7 @@ export class TaskInstancesPage extends BasePage {
if (hasStateBadge) {
await expect(stateBadge.first()).toBeVisible();
} else {
- const allCellsForState = firstRow.locator('td, div[role="cell"]');
+ const allCellsForState = firstRow.getByRole("cell");
expect(await allCellsForState.count()).toBeGreaterThan(2);
}
@@ -127,7 +136,7 @@ export class TaskInstancesPage extends BasePage {
if ((await timeElements.count()) > 0) {
await expect(timeElements.first()).toBeVisible();
} else {
- const dateCells = firstRow.locator('td, div[role="cell"]');
+ const dateCells = firstRow.getByRole("cell");
const dateCellCount = await dateCells.count();
expect(dateCellCount).toBeGreaterThan(3);
@@ -138,7 +147,10 @@ export class TaskInstancesPage extends BasePage {
* Verify that task instances exist in the table
*/
public async verifyTaskInstancesExist(): Promise<void> {
- const rows = this.taskInstancesTable.locator('tbody tr:not(.no-data), div[role="row"]:not(:first-child)');
+ // Skip the header row (index 0); all subsequent rows are data rows.
+ const rows = this.taskInstancesTable
+ .getByRole("row")
+ .filter({ hasNot: this.taskInstancesTable.getByRole("columnheader") });
expect(await rows.count()).toBeGreaterThan(0);
}
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/VariablePage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/VariablePage.ts
index c2d39707cfd..6db90a998aa 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/VariablePage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/VariablePage.ts
@@ -52,33 +52,36 @@ export class VariablePage extends BasePage {
}
public async navigate(): Promise<void> {
- await this.navigateTo("/variables");
+ await expect(async () => {
+ await this.navigateTo("/variables");
+ await this.page.waitForURL(/.*variables/, { timeout: 10_000 });
+ }).toPass({ intervals: [2000], timeout: 60_000 });
}
public rowByKey(key: string): Locator {
- return this.tableRows.filter({ hasText: key });
+ return this.page.locator("tr").filter({ hasText: key });
}
- public async search(key: string) {
+ public async search(key: string): Promise<void> {
await this.searchInput.fill(key);
}
- public async selectRow(key: string) {
+ public async selectRow(key: string): Promise<void> {
const row = this.rowByKey(key);
- const checkbox = row.locator('[id^="checkbox"][id$=":control"]');
+ const checkbox = row.getByRole("checkbox");
- await checkbox.click();
+ await expect(checkbox).toBeVisible({ timeout: 30_000 });
+ // Use force:true because in Firefox the <label> overlay intercepts pointer events
+ await checkbox.click({ force: true });
}
public async waitForLoad(): Promise<void> {
- await this.table.waitFor({ state: "visible", timeout: 15_000 });
- await this.waitForTableData();
- }
+ await expect(this.table).toBeVisible({ timeout: 15_000 });
- private async waitForTableData(): Promise<void> {
- const noData = this.page.getByText("No variables found");
- const firstKeyCell = this.tableRows.first().locator("td:nth-child(2)");
+ // Wait for table data using Playwright locators instead of document.querySelector.
+ const firstRow = this.tableRows.first();
+ const emptyMessage = this.page.getByText(/no variables found/i);
- await expect(noData.or(firstKeyCell)).toBeVisible({ timeout: 60_000 });
+ await expect(firstRow.or(emptyMessage)).toBeVisible({ timeout: 60_000 });
}
}
diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/XComsPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/XComsPage.ts
index becd7f286af..16e850741e2 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/pages/XComsPage.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/pages/XComsPage.ts
@@ -38,11 +38,12 @@ export class XComsPage extends BasePage {
}
public async applyFilter(filterName: string, value: string): Promise<void> {
+ await expect(this.addFilterButton).toBeVisible({ timeout: 30_000 });
await this.addFilterButton.click();
const filterMenu = this.page.locator('[role="menu"]');
- await filterMenu.waitFor({ state: "visible", timeout: 5000 });
+ await expect(filterMenu).toBeVisible({ timeout: 30_000 });
const filterOption = filterMenu.locator('[role="menuitem"]').filter({ hasText: filterName });
@@ -54,17 +55,19 @@ export class XComsPage extends BasePage {
.first();
const filterInput = filterPill.locator("input");
- await filterInput.waitFor({ state: "visible", timeout: 5000 });
+ await expect(filterInput).toBeVisible({ timeout: 30_000 });
await filterInput.fill(value);
await filterInput.press("Enter");
- await this.page.waitForLoadState("networkidle");
+
+ await expect(this.xcomsTable.locator("tbody tr").first()).toBeVisible({ timeout: 30_000 });
}
public async navigate(): Promise<void> {
- await this.navigateTo(XComsPage.xcomsUrl);
- await this.page.waitForURL(/.*xcoms/, { timeout: 15_000 });
- await this.xcomsTable.waitFor({ state: "visible", timeout: 30_000 });
- await this.page.waitForLoadState("networkidle");
+ await expect(async () => {
+ await this.navigateTo(XComsPage.xcomsUrl);
+ await this.page.waitForURL(/.*xcoms/, { timeout: 15_000 });
+ await expect(this.xcomsTable).toBeVisible({ timeout: 30_000 });
+ }).toPass({ intervals: [2000, 5000], timeout: 60_000 });
}
public async verifyDagDisplayNameFiltering(dagDisplayNamePattern: string): Promise<void> {
@@ -92,13 +95,12 @@ export class XComsPage extends BasePage {
public async verifyExpandCollapse(): Promise<void> {
await this.navigate();
- await expect(this.expandAllButton.first()).toBeVisible({ timeout: 5000 });
- await this.expandAllButton.first().click();
- await this.page.waitForLoadState("networkidle");
+ await expect(async () => {
+ await this.expandAllButton.first().click({ timeout: 5000 });
+ await expect(this.collapseAllButton.first()).toBeVisible({ timeout: 3000 });
+ }).toPass({ intervals: [2000], timeout: 15_000 });
- await expect(this.collapseAllButton.first()).toBeVisible({ timeout: 5000 });
await this.collapseAllButton.first().click();
- await this.page.waitForLoadState("networkidle");
}
public async verifyKeyPatternFiltering(keyPattern: string): Promise<void> {
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/asset.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/asset.spec.ts
index 59046947c57..f1f11eed513 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/asset.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/asset.spec.ts
@@ -16,82 +16,52 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { expect, test } from "@playwright/test";
-import { AUTH_FILE, testConfig } from "playwright.config";
-
-import { AssetDetailPage } from "../pages/AssetDetailPage";
-import { AssetListPage } from "../pages/AssetListPage";
-import { DagsPage } from "../pages/DagsPage";
+import { testConfig } from "playwright.config";
+import { expect } from "tests/e2e/fixtures";
+import { test } from "tests/e2e/fixtures/asset-data";
test.describe("Assets Page", () => {
- let assets: AssetListPage;
-
- test.beforeAll(async ({ browser }) => {
- test.setTimeout(3 * 60 * 1000);
- const context = await browser.newContext({ storageState: AUTH_FILE });
- const page = await context.newPage();
- const dagsPage = new DagsPage(page);
-
- await dagsPage.triggerDag("asset_produces_1");
- await expect
- .poll(
- async () => {
- const response = await page.request.get(
- `/api/v2/dags/asset_produces_1/dagRuns?order_by=-start_date&limit=1`,
- );
- const data = (await response.json()) as { dag_runs: Array<{ state: string }> };
-
- return data.dag_runs[0]?.state ?? "pending";
- },
- { intervals: [2000], timeout: 120_000 },
- )
- .toBe("success");
- await context.close();
- });
-
- test.beforeEach(async ({ page }) => {
- assets = new AssetListPage(page);
- await assets.navigate();
- await assets.waitForLoad();
+ // assetData is triggered once per worker via beforeEach.
+ test.beforeEach(async ({ assetData: _data, assetListPage }) => {
+ await assetListPage.navigate();
+ await assetListPage.waitForLoad();
});
- test("verify assets page heading", async () => {
- await expect(assets.heading).toBeVisible();
+ test("verify assets page heading", async ({ assetListPage }) => {
+ await expect(assetListPage.heading).toBeVisible();
});
- test("verify assets table", async () => {
- await expect(assets.table).toBeVisible();
+ test("verify assets table", async ({ assetListPage }) => {
+ await expect(assetListPage.table).toBeVisible();
});
- test("verify asset rows when data exists", async () => {
- await expect(assets.rows.first()).toBeVisible();
+ test("verify asset rows when data exists", async ({ assetListPage }) => {
+ await expect(assetListPage.rows.first()).toBeVisible();
});
- test("verify asset has a visible name link", async () => {
- await expect(assets.rows.locator("td a").first()).toBeVisible();
+ test("verify asset has a visible name link", async ({ assetListPage }) => {
+ await expect(assetListPage.rows.locator("td a").first()).toBeVisible();
});
- test("verify clicking an asset navigates to detail page", async ({ page }) => {
- const name = await assets.openFirstAsset();
+ test("verify clicking an asset navigates to detail page", async ({ assetListPage, page }) => {
+ const name = await assetListPage.openFirstAsset();
await expect(page).toHaveURL(/\/assets\/.+/);
await expect(page.getByRole("heading", { name: new RegExp(name, "i") })).toBeVisible();
});
- test("verify assets using search", async () => {
- await expect(assets.rows.first()).toBeVisible();
+ test("verify assets using search", async ({ assetListPage }) => {
+ await expect(assetListPage.rows.first()).toBeVisible();
const searchTerm = testConfig.asset.name;
- await assets.searchInput.fill(searchTerm);
+ await assetListPage.searchInput.fill(searchTerm);
- // Wait for filtered results - count should decrease OR stay same if search matches all
await expect
.poll(
async () => {
- const links = await assets.rows.locator("td a").allTextContents();
+ const links = await assetListPage.rows.locator("td a").allTextContents();
- // Return true when we have results that match the search
return (
links.length > 0 && links.every((name) => name.toLowerCase().includes(searchTerm.toLowerCase()))
);
@@ -101,18 +71,13 @@ test.describe("Assets Page", () => {
.toBe(true);
});
- test("verify asset details and dependencies", async ({ page }) => {
- const assetDetailPage = new AssetDetailPage(page);
+ test("verify asset details and dependencies", async ({ assetDetailPage }) => {
const assetName = testConfig.asset.name;
await assetDetailPage.goto();
-
await assetDetailPage.clickOnAsset(assetName);
-
- await assetDetailPage.verifyAssetDetails(assetName);
-
+ await expect(assetDetailPage.getHeading(assetName)).toBeVisible();
await assetDetailPage.verifyProducingTasks();
-
await assetDetailPage.verifyScheduledDags();
});
});
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/configuration.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/configuration.spec.ts
index 9e521c0d37b..b1aa8d1490a 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/configuration.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/configuration.spec.ts
@@ -16,26 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { expect, test } from "@playwright/test";
-
-import { ConfigurationPage } from "../pages/ConfigurationPage";
+import { expect, test } from "tests/e2e/fixtures";
test.describe("Configuration Page", () => {
- let configPage: ConfigurationPage;
-
- test.beforeEach(async ({ page }) => {
- configPage = new ConfigurationPage(page);
- await configPage.navigate();
- await configPage.waitForLoad();
+ test.beforeEach(async ({ configurationPage }) => {
+ await configurationPage.navigate();
+ await configurationPage.waitForLoad();
});
- test("verify configuration displays", async () => {
- await expect(configPage.heading).toBeVisible();
- await expect(configPage.table).toBeVisible();
+ test("verify configuration displays", async ({ configurationPage }) => {
+ await expect(configurationPage.heading).toBeVisible();
+ await expect(configurationPage.table).toBeVisible();
- await expect(configPage.rows).not.toHaveCount(0);
+ await expect(configurationPage.rows).not.toHaveCount(0);
- const firstRow = configPage.rows.nth(0);
+ const firstRow = configurationPage.rows.nth(0);
await expect(firstRow.locator("td").nth(0)).not.toBeEmpty();
await expect(firstRow.locator("td").nth(1)).not.toBeEmpty();
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/dag-audit-log.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/dag-audit-log.spec.ts
index 0efc828be5c..1f7ab2f1946 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/dag-audit-log.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/dag-audit-log.spec.ts
@@ -16,54 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { expect, test } from "@playwright/test";
-import { AUTH_FILE, testConfig } from "playwright.config";
-import { DagsPage } from "tests/e2e/pages/DagsPage";
-import { EventsPage } from "tests/e2e/pages/EventsPage";
+import { expect } from "tests/e2e/fixtures";
+import { test } from "tests/e2e/fixtures/audit-log-data";
test.describe("DAG Audit Log", () => {
- let eventsPage: EventsPage;
+ test.setTimeout(60_000);
- const testDagId = testConfig.testDag.id;
- const triggerCount = 3;
- const expectedEventCount = triggerCount + 1;
-
- test.setTimeout(120_000);
-
- test.beforeAll(async ({ browser }) => {
- test.setTimeout(3 * 60 * 1000);
- const context = await browser.newContext({ storageState: AUTH_FILE });
- const page = await context.newPage();
- const setupDagsPage = new DagsPage(page);
- const setupEventsPage = new EventsPage(page);
-
- for (let i = 0; i < triggerCount; i++) {
- await setupDagsPage.triggerDag(testDagId);
- }
-
- await setupEventsPage.navigateToAuditLog(testDagId);
- await expect(async () => {
- const count = await setupEventsPage.tableRows.count();
-
- expect(count).toBeGreaterThanOrEqual(expectedEventCount);
- }).toPass({ timeout: 60_000 });
-
- await context.close();
- });
-
- test.beforeEach(({ page }) => {
- eventsPage = new EventsPage(page);
- });
-
- test("verify audit log table displays", async () => {
- await eventsPage.navigateToAuditLog(testDagId);
+ test("verify audit log table displays", async ({ auditLogData, eventsPage }) => {
+ await eventsPage.navigateToAuditLog(auditLogData.dagId);
await expect(eventsPage.eventsTable).toBeVisible();
await expect(eventsPage.tableRows).not.toHaveCount(0);
});
- test("verify expected columns are visible", async () => {
- await eventsPage.navigateToAuditLog(testDagId);
+ test("verify expected columns are visible", async ({ auditLogData, eventsPage }) => {
+ await eventsPage.navigateToAuditLog(auditLogData.dagId);
await expect(eventsPage.whenColumn).toBeVisible();
await expect(eventsPage.eventColumn).toBeVisible();
@@ -75,8 +42,8 @@ test.describe("DAG Audit Log", () => {
await expect(dagIdColumn).not.toBeVisible();
});
- test.fixme("verify audit log entries display valid data", async () => {
- await eventsPage.navigateToAuditLog(testDagId);
+ test("verify audit log entries display valid data", async ({ auditLogData, eventsPage }) => {
+ await eventsPage.navigateToAuditLog(auditLogData.dagId);
await expect(eventsPage.tableRows).not.toHaveCount(0);
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/dag-calendar-tab.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/dag-calendar-tab.spec.ts
index 65d77ac80d0..b7ba674338b 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/dag-calendar-tab.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/dag-calendar-tab.spec.ts
@@ -16,167 +16,92 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { expect, test } from "@playwright/test";
-import dayjs from "dayjs";
-import { AUTH_FILE, testConfig } from "playwright.config";
-
-import { DagCalendarTab } from "../pages/DagCalendarTab";
+import { expect } from "@playwright/test";
+import { test } from "tests/e2e/fixtures/calendar-data";
test.describe("DAG Calendar Tab", () => {
test.setTimeout(90_000);
- const dagId = testConfig.testDag.id;
- let calendar: DagCalendarTab;
-
- test.beforeAll(async ({ browser }) => {
- test.setTimeout(180_000);
-
- const context = await browser.newContext({ storageState: AUTH_FILE });
- const page = await context.newPage();
-
- // Wait for Dag to be parsed before making API calls
- await expect
- .poll(
- async () => {
- const response = await page.request.get(`/api/v2/dags/${dagId}`);
-
- return response.ok();
- },
- { intervals: [2000], timeout: 60_000 },
- )
- .toBe(true);
-
- await page.request.patch(`/api/v2/dags/${dagId}`, {
- data: { is_paused: false },
- });
-
- const now = dayjs();
- const yesterday = now.subtract(1, "day");
- const baseDate = yesterday.isSame(now, "month") ? yesterday : now;
-
- const successIso = baseDate.startOf("day").hour(10).toISOString();
- const failedIso = baseDate.startOf("day").hour(14).toISOString();
-
- async function createRun(runId: string, iso: string, state: string) {
- const response = await page.request.post(`/api/v2/dags/${dagId}/dagRuns`, {
- data: {
- conf: {},
- dag_run_id: runId,
- logical_date: iso,
- note: "e2e test",
- },
- });
-
- // 409 = a run at this logical_date already exists (parallel worker race);
- // another worker's beforeAll already created the test data, so skip.
- if (response.status() === 409) {
- return;
- }
-
- if (!response.ok()) {
- const body = await response.text();
-
- throw new Error(`Run creation failed: ${response.status()} ${body}`);
- }
-
- const data = (await response.json()) as { dag_run_id: string };
- const dagRunId = data.dag_run_id;
-
- await page.request.patch(`/api/v2/dags/${dagId}/dagRuns/${dagRunId}`, { data: { state } });
- }
-
- await createRun(`cal_success_${Date.now()}`, successIso, "success");
- await createRun(`cal_failed_${Date.now()}`, failedIso, "failed");
-
- await context.close();
- });
- test.beforeEach(async ({ page }) => {
+ // calendarRunsData is triggered once per worker via beforeEach.
+ test.beforeEach(async ({ calendarRunsData, dagCalendarTab }) => {
test.setTimeout(60_000);
- calendar = new DagCalendarTab(page);
- await calendar.navigateToCalendar(dagId);
+ await dagCalendarTab.navigateToCalendar(calendarRunsData.dagId);
});
- test.fixme("verify calendar grid renders", async () => {
- await calendar.switchToHourly();
- await calendar.verifyMonthGridRendered();
+ test("verify calendar grid renders", async ({ dagCalendarTab }) => {
+ await dagCalendarTab.switchToHourly();
});
- test("verify active cells appear for DAG runs", async () => {
- await calendar.switchToHourly();
+ test("verify active cells appear for DAG runs", async ({ dagCalendarTab }) => {
+ await dagCalendarTab.switchToHourly();
- const count = await calendar.getActiveCellCount();
+ const count = await dagCalendarTab.getActiveCellCount();
expect(count).toBeGreaterThan(0);
});
- test("verify manual runs are detected", async () => {
- await calendar.switchToHourly();
+ test("verify manual runs are detected", async ({ dagCalendarTab }) => {
+ await dagCalendarTab.switchToHourly();
- const states = await calendar.getManualRunStates();
+ const states = await dagCalendarTab.getManualRunStates();
expect(states.length).toBeGreaterThanOrEqual(2);
});
- // These tests depend on a "failed" dag run being present. The scheduler
- // can override the PATCH-to-failed state back to success before tests run
- // because the shared testDag may already be unpaused by parallel tests.
-
- test.fixme("verify hover shows correct run states", async () => {
- await calendar.switchToHourly();
+ test("verify hover shows correct run states", async ({ dagCalendarTab }) => {
+ await dagCalendarTab.switchToHourly();
- const states = await calendar.getManualRunStates();
+ const states = await dagCalendarTab.getManualRunStates();
expect(states).toContain("success");
expect(states).toContain("failed");
});
- // The scheduler can override the PATCH-to-failed state back to success before tests run.
- test.fixme("failed filter shows only failed runs", async () => {
- await calendar.switchToHourly();
+ test("failed filter shows only failed runs", async ({ dagCalendarTab }) => {
+ await dagCalendarTab.switchToHourly();
- const totalStates = await calendar.getManualRunStates();
+ const totalStates = await dagCalendarTab.getManualRunStates();
expect(totalStates).toContain("success");
expect(totalStates).toContain("failed");
- await calendar.switchToFailedView();
+ await dagCalendarTab.switchToFailedView();
- const failedStates = await calendar.getManualRunStates();
+ const failedStates = await dagCalendarTab.getManualRunStates();
expect(failedStates).toContain("failed");
expect(failedStates).not.toContain("success");
});
- test("failed view reduces active cells", async () => {
- await calendar.switchToHourly();
+ test("failed view reduces active cells", async ({ dagCalendarTab }) => {
+ await dagCalendarTab.switchToHourly();
- const totalCount = await calendar.getActiveCellCount();
+ const totalCount = await dagCalendarTab.getActiveCellCount();
- await calendar.switchToFailedView();
+ await dagCalendarTab.switchToFailedView();
- const failedCount = await calendar.getActiveCellCount();
+ const failedCount = await dagCalendarTab.getActiveCellCount();
expect(failedCount).toBeLessThan(totalCount);
});
- test.fixme("color scale changes between total and failed view", async () => {
- await calendar.switchToHourly();
+ test("color scale changes between total and failed view", async ({ dagCalendarTab }) => {
+ await dagCalendarTab.switchToHourly();
- const totalColors = await calendar.getActiveCellColors();
+ const totalColors = await dagCalendarTab.getActiveCellColors();
- await calendar.switchToFailedView();
+ await dagCalendarTab.switchToFailedView();
- const failedColors = await calendar.getActiveCellColors();
+ const failedColors = await dagCalendarTab.getActiveCellColors();
- // color palette should differ
expect(failedColors).not.toEqual(totalColors);
});
- test.fixme("cells reflect failed view mode attribute", async () => {
- await calendar.switchToHourly();
- await calendar.switchToFailedView();
+ test("cells reflect failed view mode attribute", async ({ dagCalendarTab }) => {
+ await dagCalendarTab.switchToHourly();
+ await dagCalendarTab.switchToFailedView();
- const cell = calendar.activeCells.first();
+ const cell = dagCalendarTab.activeCells.first();
await expect(cell).toHaveAttribute("data-view-mode", "failed");
});
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/dag-code-tab.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/dag-code-tab.spec.ts
index fc6e93d2382..997a2a9d9cd 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/dag-code-tab.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/dag-code-tab.spec.ts
@@ -16,34 +16,30 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { test } from "@playwright/test";
import { testConfig } from "playwright.config";
-
-import { DagCodePage } from "../pages/DagCodePage";
+import { test } from "tests/e2e/fixtures";
test.describe("DAG Code Tab", () => {
test.setTimeout(60_000);
const dagId = testConfig.testDag.id;
- let codePage: DagCodePage;
- test.beforeEach(async ({ page }) => {
- codePage = new DagCodePage(page);
- await codePage.navigateToCodeTab(dagId);
+ test.beforeEach(async ({ dagCodePage }) => {
+ await dagCodePage.navigateToCodeTab(dagId);
});
- test.fixme("Verify DAG source code is displayed", async () => {
- await codePage.verifySourceCodeDisplayed();
+ test("Verify DAG source code is displayed", async ({ dagCodePage }) => {
+ await dagCodePage.verifySourceCodeDisplayed();
});
- test.fixme("Verify syntax highlighting is applied", async () => {
- await codePage.verifySyntaxHighlighting();
+ test("Verify syntax highlighting is applied", async ({ dagCodePage }) => {
+ await dagCodePage.verifySyntaxHighlighting();
});
- test.fixme("Verify code is scrollable for long files", async () => {
- await codePage.verifyCodeIsScrollable();
+ test("Verify code is scrollable for long files", async ({ dagCodePage }) => {
+ await dagCodePage.verifyCodeIsScrollable();
});
- test.fixme("Verify line numbers are displayed", async () => {
- await codePage.verifyLineNumbersDisplayed();
+ test("Verify line numbers are displayed", async ({ dagCodePage }) => {
+ await dagCodePage.verifyLineNumbersDisplayed();
});
});
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/dag-grid-view.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/dag-grid-view.spec.ts
index f7a0f83def4..648f0da330c 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/dag-grid-view.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/dag-grid-view.spec.ts
@@ -16,62 +16,37 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { test } from "@playwright/test";
-import { AUTH_FILE, testConfig } from "playwright.config";
-import { DagsPage } from "tests/e2e/pages/DagsPage";
-import { GridPage } from "tests/e2e/pages/GridPage";
+import { test } from "tests/e2e/fixtures";
test.describe("DAG Grid View", () => {
test.setTimeout(60_000);
- let gridPage: GridPage;
- const testDagId = testConfig.testDag.id;
-
- test.beforeAll(async ({ browser }) => {
- test.setTimeout(3 * 60 * 1000);
- const context = await browser.newContext({ storageState: AUTH_FILE });
- const page = await context.newPage();
- const setupDagsPage = new DagsPage(page);
-
- const dagRunId = await setupDagsPage.triggerDag(testDagId);
-
- if (dagRunId !== null) {
- await setupDagsPage.verifyDagRunStatus(testDagId, dagRunId);
- }
-
- await context.close();
- });
-
- test.beforeEach(({ page }) => {
- gridPage = new GridPage(page);
- });
-
- test("navigate to DAG detail page and display grid view", async () => {
- await gridPage.navigateToDag(testDagId);
+ test("navigate to DAG detail page and display grid view", async ({ executedDagRun, gridPage }) => {
+ await gridPage.navigateToDag(executedDagRun.dagId);
await gridPage.switchToGridView();
await gridPage.verifyGridViewIsActive();
});
- test("render grid with task instances", async () => {
- await gridPage.navigateToDag(testDagId);
+ test("render grid with task instances", async ({ executedDagRun, gridPage }) => {
+ await gridPage.navigateToDag(executedDagRun.dagId);
await gridPage.switchToGridView();
await gridPage.verifyGridHasTaskInstances();
});
- test("display task states with color coding", async () => {
- await gridPage.navigateToDag(testDagId);
+ test("display task states with color coding", async ({ executedDagRun, gridPage }) => {
+ await gridPage.navigateToDag(executedDagRun.dagId);
await gridPage.switchToGridView();
await gridPage.verifyTaskStatesAreColorCoded();
});
- test("show task details when clicking a grid cell", async () => {
- await gridPage.navigateToDag(testDagId);
+ test("show task details when clicking a grid cell", async ({ executedDagRun, gridPage }) => {
+ await gridPage.navigateToDag(executedDagRun.dagId);
await gridPage.switchToGridView();
await gridPage.clickGridCellAndVerifyDetails();
});
- test("show tooltip on grid cell hover", async () => {
- await gridPage.navigateToDag(testDagId);
+ test("show tooltip on grid cell hover", async ({ executedDagRun, gridPage }) => {
+ await gridPage.navigateToDag(executedDagRun.dagId);
await gridPage.switchToGridView();
await gridPage.verifyTaskTooltipOnHover();
});
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/dag-runs-tab.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/dag-runs-tab.spec.ts
index 5c0edc5bd99..7c825f9e3b1 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/dag-runs-tab.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/dag-runs-tab.spec.ts
@@ -16,88 +16,58 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { expect, test } from "@playwright/test";
-import { AUTH_FILE, testConfig } from "playwright.config";
-import { DagRunsTabPage } from "tests/e2e/pages/DagRunsTabPage";
+import { expect, test } from "tests/e2e/fixtures";
test.describe("DAG Runs Tab", () => {
test.setTimeout(60_000);
- let dagRunsTabPage: DagRunsTabPage;
- const testDagId = testConfig.testDag.id;
-
- test.beforeAll(async ({ browser }) => {
- test.setTimeout(3 * 60 * 1000);
- const context = await browser.newContext({ storageState: AUTH_FILE });
- const page = await context.newPage();
- const setupPage = new DagRunsTabPage(page);
-
- await setupPage.navigateToDag(testDagId);
- const runId1 = await setupPage.triggerDagRun();
-
- if (runId1 !== undefined) {
- await setupPage.navigateToRunDetails(testDagId, runId1);
- await setupPage.markRunAs("success");
- }
-
- await setupPage.navigateToDag(testDagId);
- const runId2 = await setupPage.triggerDagRun();
-
- if (runId2 !== undefined) {
- await setupPage.navigateToRunDetails(testDagId, runId2);
- await setupPage.markRunAs("failed");
- }
-
- await context.close();
- });
-
- test.beforeEach(({ page }) => {
- dagRunsTabPage = new DagRunsTabPage(page);
- });
-
- test("navigate to DAG detail page and click Runs tab", async () => {
- await dagRunsTabPage.navigateToDag(testDagId);
+ test("navigate to DAG detail page and click Runs tab", async ({ dagRunsTabPage, successAndFailedRuns }) => {
+ await dagRunsTabPage.navigateToDag(successAndFailedRuns.dagId);
await dagRunsTabPage.clickRunsTab();
await expect(dagRunsTabPage.page).toHaveURL(/.*\/dags\/[^/]+\/runs/);
});
- test("verify run details display correctly", async () => {
- await dagRunsTabPage.navigateToDag(testDagId);
+ test("verify run details display correctly", async ({ dagRunsTabPage, successAndFailedRuns }) => {
+ await dagRunsTabPage.navigateToDag(successAndFailedRuns.dagId);
await dagRunsTabPage.clickRunsTab();
await dagRunsTabPage.verifyRunDetailsDisplay();
});
- test("verify runs exist in table", async () => {
- await dagRunsTabPage.navigateToDag(testDagId);
+ test("verify runs exist in table", async ({ dagRunsTabPage, successAndFailedRuns }) => {
+ await dagRunsTabPage.navigateToDag(successAndFailedRuns.dagId);
await dagRunsTabPage.clickRunsTab();
await dagRunsTabPage.verifyRunsExist();
});
- test("click on a run and verify run details page", async () => {
- await dagRunsTabPage.navigateToDag(testDagId);
+ test("click on a run and verify run details page", async ({ dagRunsTabPage, successAndFailedRuns }) => {
+ await dagRunsTabPage.navigateToDag(successAndFailedRuns.dagId);
await dagRunsTabPage.clickRunsTab();
await dagRunsTabPage.clickRunAndVerifyDetails();
});
- test("filter runs by success state", async () => {
- await dagRunsTabPage.navigateToDag(testDagId);
+ test("filter runs by success state", async ({ dagRunsTabPage, successAndFailedRuns }) => {
+ await dagRunsTabPage.navigateToDag(successAndFailedRuns.dagId);
await dagRunsTabPage.clickRunsTab();
await dagRunsTabPage.filterByState("success");
await dagRunsTabPage.verifyFilteredByState("success");
});
- test("filter runs by failed state", async () => {
- await dagRunsTabPage.navigateToDag(testDagId);
+ test("filter runs by failed state", async ({ dagRunsTabPage, successAndFailedRuns }) => {
+ await dagRunsTabPage.navigateToDag(successAndFailedRuns.dagId);
await dagRunsTabPage.clickRunsTab();
await dagRunsTabPage.filterByState("failed");
await dagRunsTabPage.verifyFilteredByState("failed");
});
- test("search for dag run by run ID pattern", async () => {
- await dagRunsTabPage.navigateToDag(testDagId);
+ test("search for dag run by run ID pattern", async ({ dagRunsTabPage, successAndFailedRuns }) => {
+ await dagRunsTabPage.navigateToDag(successAndFailedRuns.dagId);
await dagRunsTabPage.clickRunsTab();
- await dagRunsTabPage.searchByRunIdPattern("manual");
- await dagRunsTabPage.verifySearchResults("manual");
+ // Extract the first 6 chars of the success run ID as a search pattern,
+ // so the test is not coupled to a hardcoded fixture prefix.
+ const searchPattern = successAndFailedRuns.successRun.runId.slice(0, 6);
+
+ await dagRunsTabPage.searchByRunIdPattern(searchPattern);
+ await dagRunsTabPage.verifySearchResults(searchPattern);
});
});
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/dag-runs.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/dag-runs.spec.ts
index f7d8f357e37..788de4aaa44 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/dag-runs.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/dag-runs.spec.ts
@@ -16,140 +16,37 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { test, expect } from "@playwright/test";
-import { AUTH_FILE, testConfig } from "playwright.config";
-import { DagRunsPage } from "tests/e2e/pages/DagRunsPage";
+import { test } from "tests/e2e/fixtures/dag-runs-data";
test.describe("DAG Runs Page", () => {
test.setTimeout(60_000);
- let dagRunsPage: DagRunsPage;
- const testDagId1 = testConfig.testDag.id;
- const testDagId2 = "example_python_operator";
+ // dagRunsPageData is triggered once per worker via beforeEach.
+ // eslint-disable-next-line @typescript-eslint/no-empty-function -- triggers worker-scoped data fixture
+ test.beforeEach(async ({ dagRunsPageData: _data }) => {});
- test.beforeAll(async ({ browser }) => {
- const context = await browser.newContext({ storageState: AUTH_FILE });
- const page = await context.newPage();
- const baseUrl = process.env.AIRFLOW_UI_BASE_URL ?? "http://localhost:8080";
-
- // Wait for Dags to be parsed before making API calls
- await expect
- .poll(
- async () => {
- const r1 = await page.request.get(`${baseUrl}/api/v2/dags/${testDagId1}`);
- const r2 = await page.request.get(`${baseUrl}/api/v2/dags/${testDagId2}`);
-
- return r1.ok() && r2.ok();
- },
- { intervals: [2000], timeout: 60_000 },
- )
- .toBe(true);
-
- const timestamp = Date.now();
-
- // Trigger first DAG run and mark as failed
- const runId1 = `test_run_failed_${timestamp}`;
- const logicalDate1 = new Date(timestamp).toISOString();
- const triggerResponse1 = await page.request.post(`${baseUrl}/api/v2/dags/${testDagId1}/dagRuns`, {
- data: JSON.stringify({
- dag_run_id: runId1,
- logical_date: logicalDate1,
- }),
- headers: {
- "Content-Type": "application/json",
- },
- });
-
- expect(triggerResponse1.ok()).toBeTruthy();
- const runData1 = (await triggerResponse1.json()) as { dag_run_id: string };
-
- // Mark the first run as failed
- const patchResponse1 = await page.request.patch(
- `${baseUrl}/api/v2/dags/${testDagId1}/dagRuns/${runData1.dag_run_id}`,
- {
- data: JSON.stringify({ state: "failed" }),
- headers: {
- "Content-Type": "application/json",
- },
- },
- );
-
- expect(patchResponse1.ok()).toBeTruthy();
-
- // Trigger second DAG run and mark as success
- const runId2 = `test_run_success_${timestamp}`;
- const logicalDate2 = new Date(timestamp + 60_000).toISOString();
- const triggerResponse2 = await page.request.post(`${baseUrl}/api/v2/dags/${testDagId1}/dagRuns`, {
- data: JSON.stringify({
- dag_run_id: runId2,
- logical_date: logicalDate2,
- }),
- headers: {
- "Content-Type": "application/json",
- },
- });
-
- expect(triggerResponse2.ok()).toBeTruthy();
- const runData2 = (await triggerResponse2.json()) as { dag_run_id: string };
-
- // Mark the second run as success
- const patchResponse2 = await page.request.patch(
- `${baseUrl}/api/v2/dags/${testDagId1}/dagRuns/${runData2.dag_run_id}`,
- {
- data: JSON.stringify({ state: "success" }),
- headers: {
- "Content-Type": "application/json",
- },
- },
- );
-
- expect(patchResponse2.ok()).toBeTruthy();
-
- // Trigger a run for a different DAG (for DAG ID filtering test)
- const runId3 = `test_run_other_dag_${timestamp}`;
- const logicalDate3 = new Date(timestamp + 120_000).toISOString();
-
- const triggerResponse3 = await page.request.post(`${baseUrl}/api/v2/dags/${testDagId2}/dagRuns`, {
- data: JSON.stringify({
- dag_run_id: runId3,
- logical_date: logicalDate3,
- }),
- headers: {
- "Content-Type": "application/json",
- },
- });
-
- expect(triggerResponse3.ok()).toBeTruthy();
-
- await context.close();
- });
-
- test.beforeEach(({ page }) => {
- dagRunsPage = new DagRunsPage(page);
- });
-
- test("verify DAG runs table displays data", async () => {
+ test("verify DAG runs table displays data", async ({ dagRunsPage }) => {
await dagRunsPage.navigate();
await dagRunsPage.verifyDagRunsExist();
});
- test("verify run details display correctly", async () => {
+ test("verify run details display correctly", async ({ dagRunsPage }) => {
await dagRunsPage.navigate();
await dagRunsPage.verifyRunDetailsDisplay();
});
- test("verify filtering by failed state", async () => {
+ test("verify filtering by failed state", async ({ dagRunsPage, dagRunsPageData }) => {
await dagRunsPage.navigate();
- await dagRunsPage.verifyStateFiltering("Failed");
+ await dagRunsPage.verifyStateFiltering("Failed", dagRunsPageData.dag1Id);
});
- test("verify filtering by success state", async () => {
+ test("verify filtering by success state", async ({ dagRunsPage, dagRunsPageData }) => {
await dagRunsPage.navigate();
- await dagRunsPage.verifyStateFiltering("Success");
+ await dagRunsPage.verifyStateFiltering("Success", dagRunsPageData.dag1Id);
});
- test("verify filtering by DAG ID", async () => {
+ test("verify filtering by DAG ID", async ({ dagRunsPage, dagRunsPageData }) => {
await dagRunsPage.navigate();
- await dagRunsPage.verifyDagIdFiltering(testDagId1);
+ await dagRunsPage.verifyDagIdFiltering(dagRunsPageData.dag1Id);
});
});
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/dag-tasks.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/dag-tasks.spec.ts
index 6366439987c..82b86da6e0d 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/dag-tasks.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/dag-tasks.spec.ts
@@ -16,153 +16,139 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { test, expect } from "@playwright/test";
-import { testConfig, AUTH_FILE } from "playwright.config";
-import { DagsPage } from "tests/e2e/pages/DagsPage";
+import { expect, test } from "tests/e2e/fixtures";
test.describe("Dag Tasks Tab", () => {
- const testDagId = testConfig.testDag.id;
-
- test.beforeAll(async ({ browser }) => {
- test.setTimeout(7 * 60 * 1000);
-
- const context = await browser.newContext({ storageState: AUTH_FILE });
- const page = await context.newPage();
- const dagPage = new DagsPage(page);
-
- const dagRunId = await dagPage.triggerDag(testDagId);
-
- await dagPage.verifyDagRunStatus(testDagId, dagRunId);
-
- await context.close();
- });
- test("verify tasks tab displays task list", async ({ page }) => {
- const dagPage = new DagsPage(page);
-
- await dagPage.navigateToDagTasks(testDagId);
+ test("verify tasks tab displays task list", async ({ dagsPage, page, successDagRun }) => {
+ await dagsPage.navigateToDagTasks(successDagRun.dagId);
await expect(page).toHaveURL(/\/tasks$/);
- await expect(dagPage.taskRows.first()).toBeVisible();
+ await expect(dagsPage.taskRows.first()).toBeVisible();
- const firstRow = dagPage.taskRows.first();
+ const firstRow = dagsPage.taskRows.first();
await expect(firstRow.getByRole("link").first()).toBeVisible();
await expect(firstRow).toContainText("BashOperator");
await expect(firstRow).toContainText("all_success");
});
- test("verify search tasks by name", async ({ page }) => {
- const dagPage = new DagsPage(page);
-
- await dagPage.navigateToDagTasks(testDagId);
+ test("verify search tasks by name", async ({ dagsPage, successDagRun }) => {
+ await dagsPage.navigateToDagTasks(successDagRun.dagId);
- const firstTaskLink = dagPage.taskRows.first().getByRole("link").first();
+ const firstTaskLink = dagsPage.taskRows.first().getByRole("link").first();
const taskName = await firstTaskLink.textContent();
if (taskName === null) {
throw new Error("Task name not found");
}
- await dagPage.searchBox.fill(taskName);
+ await dagsPage.searchBox.fill(taskName);
- await expect.poll(() => dagPage.taskRows.count(), { timeout: 20_000 }).toBe(1);
- await expect(dagPage.taskRows).toContainText(taskName);
+ await expect.poll(() => dagsPage.taskRows.count(), { timeout: 20_000 }).toBe(1);
+ await expect(dagsPage.taskRows).toContainText(taskName);
});
- test("verify filter tasks by operator dropdown", async ({ page }) => {
- const dagPage = new DagsPage(page);
+ test("verify filter tasks by operator dropdown", async ({ dagsPage, successDagRun }) => {
+ await dagsPage.navigateToDagTasks(successDagRun.dagId);
- await dagPage.navigateToDagTasks(testDagId);
+ let operators: Array<string> = [];
- const operators = await dagPage.getFilterOptions(dagPage.operatorFilter);
+ await expect
+ .poll(
+ async () => {
+ operators = await dagsPage.getFilterOptions(dagsPage.operatorFilter);
- expect(operators.length).toBeGreaterThan(0);
+ return operators.length;
+ },
+ { timeout: 30_000 },
+ )
+ .toBeGreaterThan(0);
for (const operator of operators) {
- await dagPage.filterByOperator(operator);
+ await dagsPage.filterByOperator(operator);
+ // Use allTextContents() instead of nth(i).textContent() to avoid
+ // stale DOM references when React re-renders the table mid-iteration.
await expect
.poll(
async () => {
- const count = await dagPage.taskRows.count();
-
- if (count === 0) return false;
- for (let i = 0; i < count; i++) {
- const text = await dagPage.taskRows.nth(i).textContent();
+ const texts = await dagsPage.taskRows.allTextContents();
- if (!text?.includes(operator)) return false;
- }
+ if (texts.length === 0) return false;
- return true;
+ return texts.every((text) => text.includes(operator));
},
{ timeout: 20_000 },
)
.toBeTruthy();
- await dagPage.navigateToDagTasks(testDagId);
+ await dagsPage.navigateToDagTasks(successDagRun.dagId);
}
});
- test("verify filter tasks by trigger rule dropdown", async ({ page }) => {
- const dagPage = new DagsPage(page);
+ test("verify filter tasks by trigger rule dropdown", async ({ dagsPage, successDagRun }) => {
+ await dagsPage.navigateToDagTasks(successDagRun.dagId);
- await dagPage.navigateToDagTasks(testDagId);
+ let rules: Array<string> = [];
- const rules = await dagPage.getFilterOptions(dagPage.triggerRuleFilter);
+ await expect
+ .poll(
+ async () => {
+ rules = await dagsPage.getFilterOptions(dagsPage.triggerRuleFilter);
- expect(rules.length).toBeGreaterThan(0);
+ return rules.length;
+ },
+ { timeout: 30_000 },
+ )
+ .toBeGreaterThan(0);
for (const rule of rules) {
- await dagPage.filterByTriggerRule(rule);
+ await dagsPage.filterByTriggerRule(rule);
await expect
.poll(
async () => {
- const count = await dagPage.taskRows.count();
+ const texts = await dagsPage.taskRows.allTextContents();
- if (count === 0) return false;
- for (let i = 0; i < count; i++) {
- const text = await dagPage.taskRows.nth(i).textContent();
+ if (texts.length === 0) return false;
- if (!text?.includes(rule)) return false;
- }
-
- return true;
+ return texts.every((text) => text.includes(rule));
},
{ timeout: 20_000 },
)
.toBeTruthy();
- await dagPage.navigateToDagTasks(testDagId);
+ await dagsPage.navigateToDagTasks(successDagRun.dagId);
}
});
- test("verify filter by retries", async ({ page }) => {
- const dagPage = new DagsPage(page);
-
- await dagPage.navigateToDagTasks(testDagId);
+ test("verify filter by retries", async ({ dagsPage, successDagRun }) => {
+ await dagsPage.navigateToDagTasks(successDagRun.dagId);
- const retriesOptions = await dagPage.getFilterOptions(dagPage.retriesFilter);
+ const retriesOptions = await dagsPage.getFilterOptions(dagsPage.retriesFilter);
if (retriesOptions.length === 0) {
return;
}
for (const retries of retriesOptions) {
- await dagPage.filterByRetries(retries);
- await expect(dagPage.taskRows.first()).toBeVisible();
- await dagPage.navigateToDagTasks(testDagId);
+ await dagsPage.filterByRetries(retries);
+ await expect(dagsPage.taskRows.first()).toBeVisible();
+ await dagsPage.navigateToDagTasks(successDagRun.dagId);
}
});
- test("verify click task to show details", async ({ page }) => {
- const dagPage = new DagsPage(page);
- await dagPage.navigateToDagTasks(testDagId);
+ test("verify click task to show details", async ({ dagsPage, page, successDagRun }) => {
+ await dagsPage.navigateToDagTasks(successDagRun.dagId);
- const firstCard = dagPage.taskRows.first();
+ const firstCard = dagsPage.taskRows.first();
const taskLink = firstCard.getByRole("link").first();
- await taskLink.click();
- await expect(page).toHaveURL(new RegExp(`/dags/${testDagId}/tasks/.*`));
+ await expect(taskLink).toBeVisible({ timeout: 30_000 });
+
+ await expect(async () => {
+ await taskLink.click();
+ await expect(page).toHaveURL(new RegExp(`/dags/${successDagRun.dagId}/tasks/.+`), { timeout: 5000 });
+ }).toPass({ intervals: [1000, 2000], timeout: 30_000 });
});
});
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/dags-list.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/dags-list.spec.ts
index a2ca283c0df..7d96f06f240 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/dags-list.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/dags-list.spec.ts
@@ -16,65 +16,71 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { expect, test } from "@playwright/test";
import { testConfig } from "playwright.config";
-import { DagsPage } from "tests/e2e/pages/DagsPage";
+import { expect, test } from "tests/e2e/fixtures";
+import { apiDeleteDagRun, waitForDagRunStatus } from "tests/e2e/utils/test-helpers";
test.describe("Dag Trigger Workflow", () => {
- let dagsPage: DagsPage;
const testDagId = testConfig.testDag.id;
- test.beforeEach(({ page }) => {
- dagsPage = new DagsPage(page);
- });
-
- test.fixme("should successfully trigger a Dag run", async () => {
- test.setTimeout(7 * 60 * 1000);
+ test("should successfully trigger a Dag run", async ({
+ authenticatedRequest,
+ dagReady: _ready,
+ dagsPage,
+ page,
+ }) => {
+ test.slow();
const dagRunId = await dagsPage.triggerDag(testDagId);
- if (Boolean(dagRunId)) {
- await dagsPage.verifyDagRunStatus(testDagId, dagRunId);
+ expect(dagRunId).toBeTruthy();
+
+ if (dagRunId !== null) {
+ await waitForDagRunStatus(authenticatedRequest, {
+ dagId: testDagId,
+ expectedState: "success",
+ runId: dagRunId,
+ timeout: 120_000,
+ });
+
+ await page.goto(`/dags/${testDagId}/runs/${dagRunId}`);
+ const stateBadge = page.getByTestId("state-badge").first();
+
+ await expect(stateBadge).toContainText("Success", { timeout: 30_000 });
+
+ await apiDeleteDagRun(authenticatedRequest, testDagId, dagRunId).catch(() => undefined);
}
});
});
test.describe("Dag Details Tab", () => {
- let dagsPage: DagsPage;
-
const testDagId = testConfig.testDag.id;
- test.beforeEach(({ page }) => {
- dagsPage = new DagsPage(page);
- });
-
- test.fixme("should successfully verify details tab", async () => {
- test.setTimeout(120_000);
- await dagsPage.verifyDagDetails(testDagId);
+ test("should successfully verify details tab", async ({ dagReady: _ready, dagsPage }) => {
+ test.slow();
+ await dagsPage.navigateToDagDetails(testDagId);
});
});
test.describe("Dags List Display", () => {
- let dagsPage: DagsPage;
-
- test.beforeEach(({ page }) => {
- dagsPage = new DagsPage(page);
- });
+ // dagReady is triggered once per worker via beforeEach.
+ // eslint-disable-next-line @typescript-eslint/no-empty-function -- triggers worker-scoped data fixture
+ test.beforeEach(async ({ dagReady: _ready }) => {});
- test("should display Dags list after successful login", async () => {
- test.setTimeout(120_000);
+ test("should display Dags list after successful login", async ({ dagsPage }) => {
+ test.slow();
await dagsPage.navigate();
- await dagsPage.verifyDagsListVisible();
+ await dagsPage.waitForDagList();
const dagsCount = await dagsPage.getDagsCount();
expect(dagsCount).toBeGreaterThan(0);
});
- test("should display Dag links correctly", async () => {
- test.setTimeout(120_000);
+ test("should display Dag links correctly", async ({ dagsPage }) => {
+ test.slow();
await dagsPage.navigate();
- await dagsPage.verifyDagsListVisible();
+ await dagsPage.waitForDagList();
const dagLinks = await dagsPage.getDagLinks();
@@ -85,37 +91,31 @@ test.describe("Dags List Display", () => {
}
});
- test("should display test Dag in the list", async () => {
- test.setTimeout(120_000);
+ test("should display test Dag in the list", async ({ dagsPage }) => {
+ test.slow();
const testDagId = testConfig.testDag.id;
await dagsPage.navigate();
- await dagsPage.verifyDagsListVisible();
- await dagsPage.verifyDagExists(testDagId);
+ await dagsPage.waitForDagList();
+ await expect(dagsPage.getDagLink(testDagId)).toBeVisible();
});
});
test.describe("Dags View Toggle", () => {
- let dagsPage: DagsPage;
-
- test.beforeEach(({ page }) => {
- dagsPage = new DagsPage(page);
- });
-
- test("should toggle between card view and table view", async () => {
- test.setTimeout(120_000);
+ test("should toggle between card view and table view", async ({ dagsPage }) => {
+ test.slow();
await dagsPage.navigate();
- await dagsPage.verifyDagsListVisible();
+ await dagsPage.waitForDagList();
await dagsPage.switchToCardView();
- await dagsPage.verifyCardViewVisible();
+ await dagsPage.waitForCardView();
const cardViewDagsCount = await dagsPage.getDagsCount();
expect(cardViewDagsCount).toBeGreaterThan(0);
await dagsPage.switchToTableView();
- await dagsPage.verifyTableViewVisible();
+ await dagsPage.waitForTableView();
const tableViewDagsCount = await dagsPage.getDagsCount();
@@ -124,28 +124,22 @@ test.describe("Dags View Toggle", () => {
});
test.describe("Dags Search", () => {
- let dagsPage: DagsPage;
-
const testDagId = testConfig.testDag.id;
- test.beforeEach(({ page }) => {
- dagsPage = new DagsPage(page);
- });
-
- test.fixme("should search for a Dag by name", async () => {
- test.setTimeout(120_000);
+ test("should search for a Dag by name", async ({ dagsPage }) => {
+ test.slow();
await dagsPage.navigate();
- await dagsPage.verifyDagsListVisible();
+ await dagsPage.waitForDagList();
const initialCount = await dagsPage.getDagsCount();
expect(initialCount).toBeGreaterThan(0);
await dagsPage.searchDag(testDagId);
- await dagsPage.verifyDagExists(testDagId);
+ await expect(dagsPage.getDagLink(testDagId)).toBeVisible();
await dagsPage.clearSearch();
- await dagsPage.verifyDagsListVisible();
+ await dagsPage.waitForDagList();
await expect
.poll(async () => dagsPage.getDagsCount(), {
@@ -157,16 +151,10 @@ test.describe("Dags Search", () => {
});
test.describe("Dags Status Filtering", () => {
- let dagsPage: DagsPage;
-
- test.beforeEach(({ page }) => {
- dagsPage = new DagsPage(page);
- });
-
- test("should display status filter buttons", async () => {
- test.setTimeout(7 * 60 * 1000);
+ test("should display status filter buttons", async ({ dagsPage }) => {
+ test.slow();
await dagsPage.navigate();
- await dagsPage.verifyDagsListVisible();
+ await dagsPage.waitForDagList();
await expect(dagsPage.successFilter).toBeVisible();
await expect(dagsPage.failedFilter).toBeVisible();
@@ -174,9 +162,9 @@ test.describe("Dags Status Filtering", () => {
await expect(dagsPage.queuedFilter).toBeVisible();
await dagsPage.filterByStatus("success");
- await dagsPage.verifyDagsListVisible();
+ await dagsPage.waitForDagList();
await dagsPage.filterByStatus("failed");
- await dagsPage.verifyDagsListVisible();
+ await dagsPage.waitForDagList();
});
});
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/events-page.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/events-page.spec.ts
index 7de6cf30ef7..792fa5e793e 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/events-page.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/events-page.spec.ts
@@ -16,19 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { expect, test } from "@playwright/test";
-import { testConfig, AUTH_FILE } from "playwright.config";
-import { DagsPage } from "tests/e2e/pages/DagsPage";
-import { EventsPage } from "tests/e2e/pages/EventsPage";
+import { expect, test } from "tests/e2e/fixtures";
test.describe("Events Page", () => {
- let eventsPage: EventsPage;
-
- test.beforeEach(({ page }) => {
- eventsPage = new EventsPage(page);
- });
-
- test("verify events page displays correctly", async () => {
+ test("verify events page displays correctly", async ({ eventsPage }) => {
await eventsPage.navigate();
await expect(eventsPage.eventsPageTitle).toBeVisible({ timeout: 10_000 });
@@ -36,62 +27,19 @@ test.describe("Events Page", () => {
await eventsPage.verifyTableColumns();
});
- test("verify search input is visible", async () => {
+ test("verify search input is visible", async ({ eventsPage }) => {
await eventsPage.navigate();
await eventsPage.waitForEventsTable();
- // Verify filter bar (containing search functionality) is visible
await expect(eventsPage.filterBar).toBeVisible({ timeout: 10_000 });
-
- // Verify the filter button is present (allows adding search filters)
- const filterButton = eventsPage.page.locator('button:has-text("Filter")');
-
- await expect(filterButton).toBeVisible();
-
- // Click the filter button to open the filter menu
- await filterButton.click();
-
- // Verify filter menu opened - be more specific to target the filter menu
- const filterMenu = eventsPage.page.locator('[role="menu"][aria-labelledby*="menu"][data-state="open"]');
-
- await expect(filterMenu).toBeVisible({ timeout: 5000 });
-
- // Look for text search options in the menu
- const textSearchOptions = eventsPage.page.locator(
- '[role="menuitem"]:has-text("DAG ID"), [role="menuitem"]:has-text("Event Type"), [role="menuitem"]:has-text("User")',
- );
-
- const textSearchOptionsCount = await textSearchOptions.count();
-
- expect(textSearchOptionsCount).toBeGreaterThan(0);
- await expect(textSearchOptions.first()).toBeVisible();
-
- // Close the menu by pressing Escape
- await eventsPage.page.keyboard.press("Escape");
+ await eventsPage.verifyFilterMenuHasOptions();
});
});
test.describe("Events with Generated Data", () => {
- let eventsPage: EventsPage;
- const testDagId = testConfig.testDag.id;
-
test.setTimeout(60_000);
- test.beforeAll(async ({ browser }) => {
- test.setTimeout(3 * 60 * 1000);
- const context = await browser.newContext({ storageState: AUTH_FILE });
- const page = await context.newPage();
- const dagsPage = new DagsPage(page);
-
- await dagsPage.triggerDag(testDagId);
- await context.close();
- });
-
- test.beforeEach(({ page }) => {
- eventsPage = new EventsPage(page);
- });
-
- test("verify audit log entries display valid data", async () => {
+ test("verify audit log entries display valid data", async ({ eventsPage, executedDagRun: _run }) => {
await eventsPage.navigate();
await expect(eventsPage.eventsTable).toBeVisible();
@@ -102,7 +50,10 @@ test.describe("Events with Generated Data", () => {
await eventsPage.verifyLogEntriesWithData();
});
- test.fixme("verify search for specific event type and filtered results", async () => {
+ test("verify search for specific event type and filtered results", async ({
+ eventsPage,
+ executedDagRun: _run,
+ }) => {
await eventsPage.navigate();
const initialRowCount = await eventsPage.getTableRowCount();
@@ -123,10 +74,10 @@ test.describe("Events with Generated Data", () => {
}).toPass({ timeout: 20_000 });
});
- test.fixme("verify filter by DAG ID", async () => {
+ test("verify filter by DAG ID", async ({ eventsPage, executedDagRun }) => {
await eventsPage.navigate();
await eventsPage.addFilter("DAG ID");
- await eventsPage.setFilterValue("DAG ID", testDagId);
+ await eventsPage.setFilterValue("DAG ID", executedDagRun.dagId);
await expect(eventsPage.eventsTable).toBeVisible();
await expect(async () => {
@@ -140,7 +91,7 @@ test.describe("Events with Generated Data", () => {
const dagIdCell = await eventsPage.getCellByColumnName(row, "DAG ID");
const dagIdText = await dagIdCell.textContent();
- expect(dagIdText?.toLowerCase()).toContain(testDagId.toLowerCase());
+ expect(dagIdText?.toLowerCase()).toContain(executedDagRun.dagId.toLowerCase());
}
}).toPass({ timeout: 20_000 });
});
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/home-dashboard.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/home-dashboard.spec.ts
index 847a63058ab..4ff8092d38a 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/home-dashboard.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/home-dashboard.spec.ts
@@ -16,23 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { expect, test } from "@playwright/test";
import { testConfig } from "playwright.config";
-import { DagsPage } from "tests/e2e/pages/DagsPage";
-import { HomePage } from "tests/e2e/pages/HomePage";
+import { expect } from "tests/e2e/fixtures";
+import { test } from "tests/e2e/fixtures/dashboard-data";
test.describe("Dashboard Metrics Display", () => {
- let homePage: HomePage;
-
- test.beforeEach(({ page }) => {
- homePage = new HomePage(page);
- });
-
- test("should display dashboard stats section with DAG metrics", async () => {
+ test("should display dashboard stats section with DAG metrics", async ({ homePage }) => {
await homePage.navigate();
await homePage.waitForDashboardLoad();
- // Use Playwright assertions directly for clearer error messages
await expect(homePage.statsSection).toBeVisible();
await expect(homePage.activeDagsCard).toBeVisible();
@@ -51,18 +43,17 @@ test.describe("Dashboard Metrics Display", () => {
expect(failedDagsCount).toBeGreaterThanOrEqual(0);
});
- test("should display health status badges", async () => {
+ test("should display health status badges", async ({ homePage }) => {
await homePage.navigate();
await homePage.waitForDashboardLoad();
- // Use Playwright assertions directly for clearer error messages
await expect(homePage.healthSection).toBeVisible();
await expect(homePage.metaDatabaseHealth).toBeVisible();
await expect(homePage.schedulerHealth).toBeVisible();
await expect(homePage.triggererHealth).toBeVisible();
});
- test("should navigate to filtered DAGs list when clicking stats cards", async () => {
+ test("should navigate to filtered DAGs list when clicking stats cards", async ({ homePage }) => {
await homePage.navigate();
await homePage.waitForDashboardLoad();
@@ -76,60 +67,48 @@ test.describe("Dashboard Metrics Display", () => {
await expect(homePage.page).toHaveURL(/last_dag_run_state=running/);
});
- test("should display welcome heading on dashboard", async () => {
+ test("should display welcome heading on dashboard", async ({ homePage }) => {
await homePage.navigate();
await homePage.waitForDashboardLoad();
await expect(homePage.welcomeHeading).toBeVisible();
});
- test("should update metrics when DAG is triggered", async () => {
- // Increase timeout for this test since DAG triggering takes time
- test.setTimeout(7 * 60 * 1000);
+ test("should update metrics when DAG is triggered", async ({ dagRunCleanup, dagsPage, homePage }) => {
+ test.slow();
await homePage.navigate();
await homePage.waitForDashboardLoad();
- const initialRunningCount = await homePage.getRunningDagsCount();
-
- // Trigger a DAG to update metrics
- const dagsPage = new DagsPage(homePage.page);
+ const dagRunId = await dagsPage.triggerDag(testConfig.testDag.id);
- await dagsPage.triggerDag(testConfig.testDag.id);
+ if (dagRunId !== null) {
+ dagRunCleanup.track(dagRunId);
+ }
- // Navigate back to home and verify metrics updated
await homePage.navigate();
await homePage.waitForDashboardLoad();
- // Verify stats section is still visible after DAG trigger
await expect(homePage.statsSection).toBeVisible();
-
- // Get updated counts - running count should reflect the triggered DAG
- const updatedRunningCount = await homePage.getRunningDagsCount();
-
- // Either running count increased or stayed same (if DAG completed quickly)
- expect(updatedRunningCount).toBeGreaterThanOrEqual(0);
- expect(initialRunningCount).toBeGreaterThanOrEqual(0);
+ await expect(homePage.activeDagsCard).toBeVisible();
+ await expect(homePage.runningDagsCard).toBeVisible();
});
- test("should display historical metrics section with recent runs", async () => {
+ test("should display historical metrics section with recent runs", async ({ homePage }) => {
await homePage.navigate();
await homePage.waitForDashboardLoad();
- // Use Playwright assertions directly for clearer error messages
await expect(homePage.historicalMetricsSection).toBeVisible();
await expect(homePage.dagRunMetrics).toBeVisible();
await expect(homePage.taskInstanceMetrics).toBeVisible();
});
- test("should handle DAG import errors display when errors exist", async () => {
+ test("should handle DAG import errors display when errors exist", async ({ homePage }) => {
await homePage.navigate();
await homePage.waitForDashboardLoad();
- // DAG Import Errors button only appears when there are actual import errors
const isDagImportErrorsVisible = await homePage.isDagImportErrorsVisible();
- // Skip test with clear message if no import errors exist in the test environment
test.skip(!isDagImportErrorsVisible, "No DAG import errors present in test environment");
await expect(homePage.dagImportErrorsCard).toBeVisible();
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/plugins.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/plugins.spec.ts
index 8d85845db4b..6207a74fec9 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/plugins.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/plugins.spec.ts
@@ -16,32 +16,27 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { expect, test } from "@playwright/test";
-
-import { PluginsPage } from "../pages/PluginsPage";
+import { expect, test } from "tests/e2e/fixtures";
test.describe("Plugins Page", () => {
- let pluginsPage: PluginsPage;
-
- test.beforeEach(async ({ page }) => {
- pluginsPage = new PluginsPage(page);
+ test.beforeEach(async ({ pluginsPage }) => {
await pluginsPage.navigate();
await pluginsPage.waitForLoad();
});
- test("verify plugins page heading is visible", async () => {
+ test("verify plugins page heading is visible", async ({ pluginsPage }) => {
await expect(pluginsPage.heading).toBeVisible();
});
- test("verify plugins table is visible", async () => {
+ test("verify plugins table is visible", async ({ pluginsPage }) => {
await expect(pluginsPage.table).toBeVisible();
});
- test("verify plugins list has at least one entry", async () => {
+ test("verify plugins list has at least one entry", async ({ pluginsPage }) => {
await expect(pluginsPage.rows).not.toHaveCount(0);
});
- test("verify each plugin has a name", async () => {
+ test("verify each plugin has a name", async ({ pluginsPage }) => {
await expect(pluginsPage.rows).not.toHaveCount(0);
const count = await pluginsPage.rows.count();
@@ -50,7 +45,7 @@ test.describe("Plugins Page", () => {
}
});
- test("verify each plugin has a source", async () => {
+ test("verify each plugin has a source", async ({ pluginsPage }) => {
await expect(pluginsPage.rows).not.toHaveCount(0);
const count = await pluginsPage.rows.count();
@@ -59,7 +54,7 @@ test.describe("Plugins Page", () => {
}
});
- test("verify plugin names and sources have matching counts", async () => {
+ test("verify plugin names and sources have matching counts", async ({ pluginsPage }) => {
const rowCount = await pluginsPage.rows.count();
await expect(pluginsPage.nameColumn).toHaveCount(rowCount);
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/providers.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/providers.spec.ts
index 19f639b4bc0..bee7bd8d12e 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/providers.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/providers.spec.ts
@@ -16,45 +16,48 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { test, expect } from "@playwright/test";
-
-import { ProvidersPage } from "../pages/ProvidersPage";
+import { expect, test } from "tests/e2e/fixtures";
test.describe("Providers Page", () => {
- let providersPage: ProvidersPage;
-
- test.beforeEach(async ({ page }) => {
- providersPage = new ProvidersPage(page);
+ test.beforeEach(async ({ providersPage }) => {
await providersPage.navigate();
await providersPage.waitForLoad();
});
- test("verify providers page heading", async () => {
+ test("verify providers page heading", async ({ providersPage }) => {
await expect(providersPage.heading).toBeVisible();
});
- test("Verify Providers page is accessible via Admin menu", async ({ page }) => {
- await providersPage.navigateFromAdminMenu();
- await providersPage.waitForLoad();
+ test("Verify Providers page is accessible via Admin menu", async ({ page, providersPage }) => {
+ await page.goto("/");
+
+ await page.getByRole("button", { name: /^admin$/i }).click();
- await expect(page).toHaveURL(/\/providers$/);
+ const providersItem = page.getByRole("menuitem", { name: /^providers$/i });
+
+ await expect(providersItem).toBeVisible();
+ await providersItem.click();
+
+ await providersPage.waitForLoad();
await expect(providersPage.heading).toBeVisible();
- await expect(providersPage.rows).not.toHaveCount(0);
+ expect(await providersPage.getRowCount()).toBeGreaterThan(0);
});
- test("Verify the providers list displays", async () => {
+ test("Verify the providers list displays", async ({ providersPage }) => {
await expect(providersPage.table).toBeVisible();
});
- test("Verify package name, version, and description are not blank", async () => {
- await expect(providersPage.rows).not.toHaveCount(0);
+ test("Verify package name, version, and description are not blank", async ({ providersPage }) => {
+ const count = await providersPage.getRowCount();
+
+ expect(count).toBeGreaterThan(0);
- const count = Math.min(await providersPage.rows.count(), 2);
+ for (let i = 0; i < 2; i++) {
+ const { description, packageName, version } = await providersPage.getRowDetails(i);
- for (let i = 0; i < count; i++) {
- await expect(providersPage.packageLinkAt(i)).not.toBeEmpty();
- await expect(providersPage.versionCellAt(i)).not.toBeEmpty();
- await expect(providersPage.descriptionCellAt(i)).not.toBeEmpty();
+ expect(packageName).not.toEqual("");
+ expect(version).not.toEqual("");
+ expect(description).not.toEqual("");
}
});
});
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/task-instances.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/task-instances.spec.ts
index 58763975802..1fc396737ed 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/task-instances.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/task-instances.spec.ts
@@ -16,149 +16,32 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { test, expect } from "@playwright/test";
-import { AUTH_FILE, testConfig } from "playwright.config";
-import { TaskInstancesPage } from "tests/e2e/pages/TaskInstancesPage";
-import { waitForServerReady } from "tests/e2e/utils/health";
+import { test } from "tests/e2e/fixtures/task-instances-data";
test.describe("Task Instances Page", () => {
test.setTimeout(60_000);
- let taskInstancesPage: TaskInstancesPage;
- const testDagId = testConfig.testDag.id;
+ // taskInstancesData is triggered once per worker via beforeEach.
+ // eslint-disable-next-line @typescript-eslint/no-empty-function -- triggers worker-scoped data fixture
+ test.beforeEach(async ({ taskInstancesData: _data }) => {});
- test.beforeAll(async ({ browser }) => {
- test.setTimeout(120_000);
- const context = await browser.newContext({ storageState: AUTH_FILE });
- const page = await context.newPage();
- const baseUrl = process.env.AIRFLOW_UI_BASE_URL ?? "http://localhost:8080";
- const timestamp = Date.now();
-
- // Wait for server to be responsive before making API calls
- await waitForServerReady(page);
-
- // Wait for Dag to be parsed before making API calls
- await expect
- .poll(
- async () => {
- const response = await page.request.get(`${baseUrl}/api/v2/dags/${testDagId}`, {
- timeout: 30_000,
- });
-
- return response.ok();
- },
- { intervals: [2000], timeout: 60_000 },
- )
- .toBe(true);
-
- // Create first DAG run for success state
- const runId1 = `test_ti_success_${timestamp}`;
- const logicalDate1 = new Date(timestamp).toISOString();
- const triggerResponse1 = await page.request.post(`${baseUrl}/api/v2/dags/${testDagId}/dagRuns`, {
- data: JSON.stringify({
- dag_run_id: runId1,
- logical_date: logicalDate1,
- }),
- headers: {
- "Content-Type": "application/json",
- },
- timeout: 30_000,
- });
-
- expect(triggerResponse1.ok()).toBeTruthy();
-
- // Get all task instances for the first run
- const tasksResponse1 = await page.request.get(
- `${baseUrl}/api/v2/dags/${testDagId}/dagRuns/${runId1}/taskInstances`,
- { timeout: 30_000 },
- );
-
- expect(tasksResponse1.ok()).toBeTruthy();
-
- const tasksData1 = (await tasksResponse1.json()) as {
- task_instances: Array<{ task_id: string }>;
- };
-
- // Mark all tasks as success
- for (const task of tasksData1.task_instances) {
- const patchResponse = await page.request.patch(
- `${baseUrl}/api/v2/dags/${testDagId}/dagRuns/${runId1}/taskInstances/${task.task_id}`,
- {
- data: JSON.stringify({ new_state: "success" }),
- headers: { "Content-Type": "application/json" },
- timeout: 30_000,
- },
- );
-
- expect(patchResponse.ok()).toBeTruthy();
- }
-
- // Create second DAG run for failed state
- const runId2 = `test_ti_failed_${timestamp}`;
- const logicalDate2 = new Date(timestamp + 60_000).toISOString();
- const triggerResponse2 = await page.request.post(`${baseUrl}/api/v2/dags/${testDagId}/dagRuns`, {
- data: JSON.stringify({
- dag_run_id: runId2,
- logical_date: logicalDate2,
- }),
- headers: {
- "Content-Type": "application/json",
- },
- timeout: 30_000,
- });
-
- expect(triggerResponse2.ok()).toBeTruthy();
-
- // Get all task instances for the second run
- const tasksResponse2 = await page.request.get(
- `${baseUrl}/api/v2/dags/${testDagId}/dagRuns/${runId2}/taskInstances`,
- { timeout: 30_000 },
- );
-
- expect(tasksResponse2.ok()).toBeTruthy();
-
- const tasksData2 = (await tasksResponse2.json()) as {
- task_instances: Array<{ task_id: string }>;
- };
-
- // Mark all tasks as failed
- for (const task of tasksData2.task_instances) {
- const patchResponse = await page.request.patch(
- `${baseUrl}/api/v2/dags/${testDagId}/dagRuns/${runId2}/taskInstances/${task.task_id}`,
- {
- data: JSON.stringify({ new_state: "failed" }),
- headers: { "Content-Type": "application/json" },
- timeout: 30_000,
- },
- );
-
- expect(patchResponse.ok()).toBeTruthy();
- }
-
- await context.close();
- });
-
- test.beforeEach(({ page }) => {
- taskInstancesPage = new TaskInstancesPage(page);
- });
-
- test.fixme("verify task instances table displays data", async () => {
+ test("verify task instances table displays data", async ({ taskInstancesPage }) => {
await taskInstancesPage.navigate();
await taskInstancesPage.verifyTaskInstancesExist();
});
- test.fixme("verify task details display correctly", async () => {
+ test("verify task details display correctly", async ({ taskInstancesPage }) => {
await taskInstancesPage.navigate();
await taskInstancesPage.verifyTaskDetailsDisplay();
});
- test("verify filtering by failed state", async () => {
+ test("verify filtering by failed state", async ({ taskInstancesData, taskInstancesPage }) => {
await taskInstancesPage.navigate();
- await taskInstancesPage.verifyStateFiltering("Failed");
+ await taskInstancesPage.verifyStateFiltering("Failed", taskInstancesData.dagId);
});
- test.fixme("verify filtering by success state", async () => {
+ test("verify filtering by success state", async ({ taskInstancesData, taskInstancesPage }) => {
await taskInstancesPage.navigate();
- await taskInstancesPage.verifyStateFiltering("Success");
+ await taskInstancesPage.verifyStateFiltering("Success", taskInstancesData.dagId);
});
});
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/task-logs.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/task-logs.spec.ts
index 344244b11be..c77b9c8d584 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/task-logs.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/task-logs.spec.ts
@@ -16,56 +16,33 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { expect, test } from "@playwright/test";
-import { AUTH_FILE, testConfig } from "playwright.config";
-
-import { TaskInstancePage } from "../pages/TaskInstancePage";
+import { testConfig } from "playwright.config";
+import { expect, test } from "tests/e2e/fixtures";
test.describe("Verify task logs display", () => {
test.describe.configure({ mode: "serial" });
- const testDagId = testConfig.testDag.id;
const testTaskId = testConfig.testTask.id;
- let dagRunId: string;
-
- test.beforeAll(async ({ browser }) => {
- test.setTimeout(120_000);
-
- const context = await browser.newContext({ storageState: AUTH_FILE });
- const page = await context.newPage();
- const taskInstancePage = new TaskInstancePage(page);
-
- await taskInstancePage.triggerDagAndWaitForSuccess(testDagId);
-
- const url = page.url();
- const match = /runs\/([^/]+)/.exec(url);
-
- dagRunId = match?.[1] ?? "";
-
- if (!dagRunId) {
- throw new Error(`Could not extract dagRunId from URL: ${url}`);
- }
-
- await context.close();
+ test.beforeEach(async ({ executedDagRun, page, taskInstancePage }) => {
+ // Clear localStorage — "log settings" test persists toggles that affect subsequent tests.
+ // Swallow SecurityError on about:blank (WebKit).
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
+ await page.evaluate(() => localStorage.clear()).catch(() => {});
+ await taskInstancePage.navigateToTaskInstance(executedDagRun.dagId, executedDagRun.runId, testTaskId);
});
- test.beforeEach(async ({ page }) => {
- const taskInstancePage = new TaskInstancePage(page);
-
- await taskInstancePage.navigateToTaskInstance(testDagId, dagRunId, testTaskId);
- });
-
- test("Verify log content is displayed", async ({ page }) => {
+ test("Verify log content is displayed", async ({ executedDagRun: _run, page }) => {
const virtualizedList = page.getByTestId("virtualized-list");
await expect(virtualizedList).toBeVisible({ timeout: 30_000 });
+
const logItems = page.getByTestId(/^virtualized-item-/);
- await expect(logItems.first()).toBeVisible({ timeout: 10_000 });
+ await expect(logItems.first()).toBeVisible({ timeout: 30_000 });
});
- test("Verify log levels are visible", async ({ page }) => {
+ test("Verify log levels are visible", async ({ executedDagRun: _run, page }) => {
const virtualizedList = page.getByTestId("virtualized-list");
await expect(virtualizedList).toBeVisible({ timeout: 30_000 });
@@ -73,39 +50,43 @@ test.describe("Verify task logs display", () => {
await expect(virtualizedList).toContainText(/INFO|WARNING|ERROR|CRITICAL/);
});
- test("Verify log timestamp formatting", async ({ page }) => {
+ test("Verify log timestamp formatting", async ({ executedDagRun: _run, page }) => {
const virtualizedList = page.getByTestId("virtualized-list");
await expect(virtualizedList).toBeVisible({ timeout: 30_000 });
- await expect(virtualizedList).toContainText(/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}]/);
+ await expect(virtualizedList).toContainText(/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}]/, {
+ timeout: 30_000,
+ });
});
- test("Verify log settings", async ({ page }) => {
+ test("Verify log settings", async ({ executedDagRun: _run, page }) => {
const virtualizedList = page.getByTestId("virtualized-list");
await expect(virtualizedList).toBeVisible({ timeout: 30_000 });
- // Verify timestamps are visible initially
- await expect(virtualizedList).toContainText(/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}]/);
+ const logItems = page.getByTestId(/^virtualized-item-/);
+
+ await expect(logItems.first()).toBeVisible({ timeout: 30_000 });
+
+ await expect(virtualizedList).toContainText(/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}]/, {
+ timeout: 30_000,
+ });
await page.getByTestId("log-settings-button").click();
await page.getByTestId("log-settings-timestamp").click();
await expect(virtualizedList).not.toContainText(/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}]/);
- // Test Show Source
await page.getByTestId("log-settings-button").click();
await page.getByTestId("log-settings-source").click();
await expect(virtualizedList).toContainText(/source/);
- // Test Unwrap
await page.getByTestId("log-settings-button").click();
const wrapMenuItem = page.getByTestId("log-settings-wrap");
await expect(wrapMenuItem).toContainText(/Wrap|Unwrap/);
await wrapMenuItem.click();
- // Test Expand
await page.getByTestId("log-settings-button").click();
const expandMenuItem = page.getByTestId("log-settings-expand");
@@ -113,14 +94,19 @@ test.describe("Verify task logs display", () => {
await expandMenuItem.click();
});
- test("Verify logs are getting downloaded fine", async ({ page }) => {
+ test("Verify logs are getting downloaded fine", async ({ executedDagRun: _run, page }) => {
const virtualizedList = page.getByTestId("virtualized-list");
await expect(virtualizedList).toBeVisible({ timeout: 30_000 });
- const downloadPromise = page.waitForEvent("download", { timeout: 10_000 });
+ const downloadButton = page.getByTestId("download-logs-button");
+
+ await expect(downloadButton).toBeVisible({ timeout: 10_000 });
+ await expect(downloadButton).toBeEnabled({ timeout: 10_000 });
+
+ const downloadPromise = page.waitForEvent("download", { timeout: 30_000 });
- await page.getByTestId("download-logs-button").click();
+ await downloadButton.click();
const download = await downloadPromise;
expect(download.suggestedFilename()).toMatch(/^logs_.*\.txt$/);
diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/xcoms.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/xcoms.spec.ts
index 3911ab27c8a..19fdb0bee77 100644
--- a/airflow-core/src/airflow/ui/tests/e2e/specs/xcoms.spec.ts
+++ b/airflow-core/src/airflow/ui/tests/e2e/specs/xcoms.spec.ts
@@ -16,84 +16,45 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { expect, test } from "@playwright/test";
-import { AUTH_FILE, testConfig } from "playwright.config";
-import { DagsPage } from "tests/e2e/pages/DagsPage";
-import { XComsPage } from "tests/e2e/pages/XComsPage";
+import { expect } from "tests/e2e/fixtures";
+import { test } from "tests/e2e/fixtures/xcom-data";
test.describe("XComs Page", () => {
test.setTimeout(60_000);
- let xcomsPage: XComsPage;
- const testDagId = testConfig.xcomDag.id;
- const testXComKey = "return_value";
- const triggerCount = 2;
+ // xcomRunsData is triggered once per worker via beforeEach.
+ // eslint-disable-next-line @typescript-eslint/no-empty-function -- triggers worker-scoped data fixture
+ test.beforeEach(async ({ xcomRunsData: _data }) => {});
- test.beforeAll(async ({ browser }) => {
- test.setTimeout(3 * 60 * 1000);
- const context = await browser.newContext({ storageState: AUTH_FILE });
- const page = await context.newPage();
- const setupDagsPage = new DagsPage(page);
- const setupXComsPage = new XComsPage(page);
-
- for (let i = 0; i < triggerCount; i++) {
- const dagRunId = await setupDagsPage.triggerDag(testDagId);
-
- await setupDagsPage.verifyDagRunStatus(testDagId, dagRunId);
- }
-
- await setupXComsPage.navigate();
- await page.waitForFunction(
- (minCount) => {
- const table = document.querySelector('[data-testid="table-list"]');
-
- if (!table) {
- return false;
- }
- const rows = table.querySelectorAll("tbody tr");
-
- return rows.length >= minCount;
- },
- triggerCount,
- { timeout: 120_000 },
- );
-
- await context.close();
- });
-
- test.beforeEach(({ page }) => {
- xcomsPage = new XComsPage(page);
- });
-
- test("verify XComs table renders", async () => {
+ test("verify XComs table renders", async ({ xcomsPage }) => {
await xcomsPage.navigate();
await expect(xcomsPage.xcomsTable).toBeVisible();
});
- test("verify XComs table displays data", async () => {
+ test("verify XComs table displays data", async ({ xcomsPage }) => {
await xcomsPage.navigate();
await xcomsPage.verifyXComsExist();
});
- test("verify XCom details display correctly", async () => {
+ test("verify XCom details display correctly", async ({ xcomsPage }) => {
await xcomsPage.navigate();
await xcomsPage.verifyXComDetailsDisplay();
});
- test("verify XCom values can be viewed", async () => {
+ test("verify XCom values can be viewed", async ({ xcomsPage }) => {
await xcomsPage.navigate();
await xcomsPage.verifyXComValuesDisplayed();
});
- test("verify expand/collapse functionality", async () => {
+ test("verify expand/collapse functionality", async ({ xcomsPage }) => {
await xcomsPage.verifyExpandCollapse();
});
- test("verify filtering by key pattern", async () => {
- await xcomsPage.verifyKeyPatternFiltering(testXComKey);
+ test("verify filtering by key pattern", async ({ xcomRunsData, xcomsPage }) => {
+ await xcomsPage.verifyKeyPatternFiltering(xcomRunsData.xcomKey);
});
- test("verify filtering by DAG display name", async () => {
- await xcomsPage.verifyDagDisplayNameFiltering(testDagId);
+ test("verify filtering by DAG display name", async ({ xcomRunsData, xcomsPage }) => {
+ await xcomsPage.verifyDagDisplayNameFiltering(xcomRunsData.dagId);
});
});
diff --git a/airflow-core/src/airflow/ui/tests/e2e/utils/health.ts b/airflow-core/src/airflow/ui/tests/e2e/utils/health.ts
deleted file mode 100644
index d1d7340ac51..00000000000
--- a/airflow-core/src/airflow/ui/tests/e2e/utils/health.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-/*!
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import type { Page } from "@playwright/test";
-
-const HEALTH_ENDPOINT = "/api/v2/monitor/health";
-const MAX_WAIT_MS = 30_000;
-const REQUEST_TIMEOUT_MS = 10_000;
-const BACKOFF_INTERVALS = [1000, 2000, 4000, 8000];
-
-/**
- * Wait for the Airflow server to be responsive before proceeding.
- *
- * Polls the health endpoint, checking for HTTP 200. Uses backoff intervals between retries.
- * We intentionally do not check response time: on Firefox/CI the health endpoint regularly
- * exceeds 2s, which would cause the check to never succeed.
- *
- * When the server responds on the first attempt, this function returns immediately.
- */
-export async function waitForServerReady(page: Page): Promise<void> {
- const startTime = Date.now();
- let attempt = 0;
-
- while (Date.now() - startTime < MAX_WAIT_MS) {
- try {
- const response = await page.request.get(HEALTH_ENDPOINT, {
- timeout: REQUEST_TIMEOUT_MS,
- });
-
- if (response.status() === 200) {
- return;
- }
- } catch {
- // Request failed or timed out — server not ready yet.
- }
-
- const index = Math.min(attempt, BACKOFF_INTERVALS.length - 1);
- const interval = BACKOFF_INTERVALS[index] as number;
- const remaining = MAX_WAIT_MS - (Date.now() - startTime);
-
- if (remaining <= 0) {
- break;
- }
-
- await page.waitForTimeout(Math.min(interval, remaining));
- attempt++;
- }
-
- throw new Error(
- `Server not ready after ${MAX_WAIT_MS}ms — health endpoint ${HEALTH_ENDPOINT} did not return 200`,
- );
-}