fix(ui/e2e): improve Playwright test patterns in xcoms.spec.ts#63993
Open
tysoncung wants to merge 1 commit intoapache:mainfrom
Open
fix(ui/e2e): improve Playwright test patterns in xcoms.spec.ts#63993tysoncung wants to merge 1 commit intoapache:mainfrom
tysoncung wants to merge 1 commit intoapache:mainfrom
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
xcoms.spec.tsandXComsPage.tsuse several Playwright anti-patterns includingpage.waitForFunction()with DOM queries,waitForLoadState('networkidle'), CSS attribute selectors instead ofgetByTestId(), and role string selectors instead ofgetByRole().Solution
Changes in
XComsPage.ts:locator('[data-testid="..."]')→getByTestId()(4 occurrences)locator('[role="menu"]')→getByRole('menu')locator('[role="menuitem"]')→getByRole('menuitem')filterMenu.waitFor()→expect().toBeVisible()filterInput.waitFor()→expect().toBeVisible()xcomsTable.waitFor()→expect().toBeVisible()waitForLoadState('networkidle')calls (3 occurrences) — replaced with state-based waitinglocator('tbody tr')→locator('tbody').getByRole('row')locator('td')→getByRole('cell')count()assertions →not.toHaveCount(0)verifyXComDetailsDisplayto use web-first assertionsChanges in
xcoms.spec.ts:page.waitForFunction()with DOM queries → locator-basedexpect().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 ✅page.evaluate()for DOM manipulation → N/A (not present):has-text()→ user-facing locators ✅Files Changed
airflow-core/src/airflow/ui/tests/e2e/pages/XComsPage.tsairflow-core/src/airflow/ui/tests/e2e/specs/xcoms.spec.tsPart of #63036
Closes #63966