fix(ui/e2e): improve Playwright test patterns in variable.spec.ts#63992
Open
tysoncung wants to merge 1 commit intoapache:mainfrom
Open
fix(ui/e2e): improve Playwright test patterns in variable.spec.ts#63992tysoncung wants to merge 1 commit intoapache:mainfrom
tysoncung wants to merge 1 commit intoapache:mainfrom
Conversation
…ache#63965) Replace Playwright anti-patterns with best practices in variable spec and VariablePage page object. Changes in VariablePage.ts: - Replace page.waitForFunction() with DOM queries with locator-based .or() pattern using web-first assertions - Replace this.table.waitFor() with expect().toBeVisible() - Replace locator('tbody tr') with locator('tbody').getByRole('row') - Replace locator('thead input[type=checkbox]') with locator('thead').getByRole('checkbox') - Replace locator('[id^=checkbox][id$=:control]') with getByRole('checkbox') - Replace locator('tr:has-text(...)') with tableRows.filter({ hasText }) - Replace locator('td:nth-child(2)') with getByRole('cell').nth(1) Changes in variable.spec.ts: - Replace locator('[data-part=backdrop]') with getByRole('dialog') Changes in playwright.config.ts: - Remove variable.spec.ts from testIgnore list closes apache#63965
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
variable.spec.tsandVariablePage.tsuse several Playwright anti-patterns that can cause flakiness and reduce maintainability.Solution
Changes in
VariablePage.ts:page.waitForFunction()with DOM queries → locator-based.or()pattern using web-first assertionsthis.table.waitFor()→expect().toBeVisible()locator('tbody tr')→locator('tbody').getByRole('row')locator('thead input[type=checkbox]')→locator('thead').getByRole('checkbox')locator('[id^=checkbox][id$=:control]')→getByRole('checkbox')locator('tr:has-text(...)')→tableRows.filter({ hasText })locator('td:nth-child(2)')→getByRole('cell').nth(1)Changes in
variable.spec.ts:locator('[data-part="backdrop"]')→getByRole('dialog')Changes in
playwright.config.ts:variable.spec.tsfromtestIgnorelistChecklist
page.waitForFunction()with DOM queries → locator-based waiting ✅page.waitForTimeout()→ N/A (not present)waitForLoadState("networkidle")→ N/A (not present)page.evaluate()for DOM manipulation → N/A (not present):has-text()→ user-facing locators ✅Files Changed
airflow-core/src/airflow/ui/tests/e2e/pages/VariablePage.tsairflow-core/src/airflow/ui/tests/e2e/specs/variable.spec.tsairflow-core/src/airflow/ui/playwright.config.tsPart of #63036
Closes #63965