Skip to content

fix(ui/e2e): improve Playwright test patterns in xcoms.spec.ts#63993

Open
tysoncung wants to merge 1 commit intoapache:mainfrom
tysoncung:fix/63966-improve-playwright-xcoms-spec
Open

fix(ui/e2e): improve Playwright test patterns in xcoms.spec.ts#63993
tysoncung wants to merge 1 commit intoapache:mainfrom
tysoncung:fix/63966-improve-playwright-xcoms-spec

Conversation

@tysoncung
Copy link

Problem

xcoms.spec.ts and XComsPage.ts use several Playwright anti-patterns including page.waitForFunction() with DOM queries, waitForLoadState('networkidle'), CSS attribute selectors instead of getByTestId(), and role string selectors instead of getByRole().

Solution

Changes in XComsPage.ts:

  • Replace locator('[data-testid="..."]')getByTestId() (4 occurrences)
  • Replace locator('[role="menu"]')getByRole('menu')
  • Replace locator('[role="menuitem"]')getByRole('menuitem')
  • Replace filterMenu.waitFor()expect().toBeVisible()
  • Replace filterInput.waitFor()expect().toBeVisible()
  • Replace xcomsTable.waitFor()expect().toBeVisible()
  • Remove waitForLoadState('networkidle') calls (3 occurrences) — replaced with state-based waiting
  • Replace locator('tbody tr')locator('tbody').getByRole('row')
  • Replace locator('td')getByRole('cell')
  • Replace manual count() assertions → not.toHaveCount(0)
  • Simplify verifyXComDetailsDisplay to use web-first assertions

Changes in xcoms.spec.ts:

  • Replace page.waitForFunction() with DOM queries → locator-based expect().not.toHaveCount(0)

Checklist

  • page.waitForFunction() with DOM queries → locator-based waiting ✅
  • page.waitForTimeout() → N/A (not present)
  • waitForLoadState("networkidle") → wait for specific UI state ✅
  • Manual assertions → web-first assertions ✅
  • page.evaluate() for DOM manipulation → N/A (not present)
  • CSS :has-text() → user-facing locators ✅

Files Changed

  • airflow-core/src/airflow/ui/tests/e2e/pages/XComsPage.ts
  • airflow-core/src/airflow/ui/tests/e2e/specs/xcoms.spec.ts

Part of #63036
Closes #63966

…e#63966) Replace Playwright anti-patterns with best practices in xcoms spec and XComsPage page object. Changes in XComsPage.ts: - Replace locator('[data-testid="..."]') with getByTestId() (4 occurrences) - Replace locator('[role="menu"]') with getByRole('menu') - Replace locator('[role="menuitem"]') with getByRole('menuitem') - Replace filterMenu.waitFor() with expect().toBeVisible() - Replace filterInput.waitFor() with expect().toBeVisible() - Replace xcomsTable.waitFor() with expect().toBeVisible() - Remove waitForLoadState('networkidle') calls (3 occurrences) - Replace locator('tbody tr') with locator('tbody').getByRole('row') - Replace locator('td') with getByRole('cell') - Replace manual count assertions with not.toHaveCount(0) - Simplify verifyXComDetailsDisplay to use web-first assertions Changes in xcoms.spec.ts: - Replace page.waitForFunction() with DOM queries with locator-based expect().not.toHaveCount(0) closes apache#63966
@boring-cyborg boring-cyborg bot added the area:UI Related to UI/UX. For Frontend Developers. label Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:UI Related to UI/UX. For Frontend Developers.

1 participant