-
Notifications
You must be signed in to change notification settings - Fork 211
feat(e2e): refactor tests to use semantic selectors and remove flaky anti-patterns #3837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(e2e): refactor tests to use semantic selectors and remove flaky anti-patterns #3837
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
PR Reviewer Guide 🔍(Review updated until commit ce0cf78)Here are some key observations to aid the review process:
|
PR TypeEnhancement Description
|
| Relevant files | |||||||
|---|---|---|---|---|---|---|---|
| Enhancement |
|
b2b584c to
0ddad92
Compare
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||
|
/review |
|
Persistent review updated to latest commit 0ddad92 |
|
The image is available at: |
0ddad92 to
ce0cf78
Compare
|
/review |
|
Persistent review updated to latest commit ce0cf78 |
|
The image is available at: |
18df22d to
23296ff
Compare
ef23dac to
b9bf5d2
Compare
Implemented 3 suggestions from qoDo bot review: 1. Fixed getClusterAccordion to use expanded attribute instead of MUI class 2. Removed redundant WaitStrategies.forVisible/forHidden methods 3. Documented ESLint enforcement recommendation for future implementation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Fixed ESLint issues introduced in refactoring:
- Removed unused UI_HELPER_ELEMENTS import from catalog-timestamp.spec.ts
- Removed unused table variable from catalog-timestamp.spec.ts
- Replaced raw MUI locator with semantic getByRole in oidc.spec.ts
- Replaced raw tbody tr locator with semantic getByRole('row') filter
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Auto-formatted files using Prettier to fix code style issues. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Removed WaitStrategies.forNetworkIdle() method as networkidle is not recommended by Playwright ESLint rules. It doesn't wait for requests triggered after load and can give false positives with polling. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Removed unused imports causing ESLint errors: - kubernetes-actions.spec.ts: Removed UI_HELPER_ELEMENTS - rbac.spec.ts: Removed Locator and UI_HELPER_ELEMENTS 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Updated test descriptions to remove the skip status for multiple test files, allowing them to run as part of the test suite. This includes tests for catalog-timestamp, custom-theme, default-global-header, dynamic-home-page-customization, extensions, home-page-customization, smoke-test, and several plugins. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Modified the global header tests to ensure the first navigation element is targeted for visibility checks, improving test accuracy and reliability. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Updated tests to improve accuracy by scoping selectors to specific elements. Changes include targeting the first navigation element in the global header, refining link selection in the learning paths, and replacing heading checks with text content verification in the user settings info card. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Updated various test files to improve accuracy in element selection. Changes include scoping sign-out actions to the profile menu, refining context card interactions to ensure shared state visibility, and optimizing user link retrieval in the catalog users page object. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Refined the test for guest login in the OIDC provider configuration by scoping the selector to the main content area, improving accuracy in identifying sign-in method card headers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Updated the RBAC test suite to enhance accuracy in element selection. Changes include replacing text-based selectors with role-based selectors for navigation links and verifying component metadata visibility, ensuring more reliable test outcomes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…ication provider and RBAC tests Updated the application provider tests to improve accuracy in card selection by using index-based access for context cards. In the RBAC tests, refined element selection by scoping visibility checks to specific article elements, ensuring more reliable test outcomes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Enhanced the login process in the Common utility by adding error handling for popup closure during navigation. This ensures that the test can gracefully handle scenarios where the popup closes before the navigation completes, improving test reliability. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…erification Updated the RBAC page object to include a verification step for the success message after creating a role. This ensures that the test accurately confirms the role creation before proceeding to the roles list, improving overall test reliability. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
5c2be4d to
eeadff4
Compare
|
The image is available at: /test e2e-ocp-helm |
|
🚫 Image Push Skipped. The container image push was skipped because the build was skipped (either due to [skip-build] tag or no relevant changes with existing image) /test e2e-ocp-helm |
e2e-tests/playwright/e2e/plugins/kubernetes/kubernetes-rbac.spec.ts
Outdated
Show resolved
Hide resolved
…loper#3837 Fixes flaky test patterns and strict mode violations: RBAC Tests (rbac.spec.ts): - Fix strict mode violation when waiting for review step by removing .or() combinator and explicitly checking for Save button visibility/enabled state - Fix timeout when updating role policies by closing plugins dropdown before interacting with permissions table and expanding specific rows - Applied fixes at lines 383-387 and 786-790 for consistent behavior RBAC Page Object (rbac-po.ts): - Add error alert detection in createRole method before waiting for success message to provide clearer error feedback when role creation fails due to insufficient permissions Catalog Users (catalog-users-obj.ts): - Fix getListOfUsers to scope to first table using .first() before selecting rowgroup to avoid selecting pagination table - Change from .last() to .nth(1) for explicit data rows selection Application Provider (application-provider.spec.ts): - Fix CSS selector from 'main article > div:first-child > div' to 'main article).last().locator("> div > div")' - Resolves timeout by correctly targeting card containers All changes follow Playwright best practices: - Use semantic locators (getByRole) over CSS selectors - Proper element scoping to avoid ambiguity - Explicit state checks (toBeVisible + toBeEnabled) - Avoid .or() when both elements can be visible simultaneously Related to PR redhat-developer#3837: feat(e2e): refactor tests to use semantic selectors and remove flaky anti-patterns
Implements all suggestions from PR redhat-developer#3837 review: 1. Remove heading level specification (kubernetes-rbac.spec.ts) - Changed getByRole('heading', { level: 6 }) to getByRole('heading') - More resilient to UI hierarchy changes 2. Refactor button interactions (rbac.spec.ts) - Replace uiHelper.clickButton() with direct locator.click() - Create dedicated button locators (nextButton, saveButton) - More explicit and follows Playwright best practices - Applied to both role creation flows (lines 378-386, 785-792) 3. Enhance verifyButtonURL method (ui-helper.ts) - Now accepts both string selectors and Locator objects - Enables better locator reusability - Updated topology.spec.ts to use Locator object 4. Refactor learning-path loop (learning-path-page.spec.ts) - Changed from indexed for loop to for-of with .all() - More idiomatic and cleaner code - Automatically handles all elements without hardcoded count All changes maintain test functionality while improving: - Code maintainability - Playwright best practices adherence - Locator reusability Co-authored-by: jrichter1 <[email protected]>
Remove Playwright page fixture from tests that rely on shared page instance configured in beforeAll. Using fixture parameter would inject a different page instance, causing reference mismatches with shared uiHelper, common, and backstageShowcase instances. Tests now correctly use the global page variable consistent with other tests in the file and the shared setup pattern.
23e7baf to
9f2827d
Compare
|
|
The image is available at: /test e2e-ocp-helm |



Description
Refactored Playwright E2E tests to follow best practices using semantic locators and removed common anti-patterns that cause test flakiness.
Which issue(s) does this PR fix
PR acceptance criteria
Please make sure that the following steps are complete:
How to test changes / Special notes to the reviewer