CONSOLE-5196: Replace page.locator with getByTestId in Playwright tests - #16873
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
@rhamilto: This pull request references CONSOLE-5196 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (13)
🚧 Files skipped from review as they are similar to previous changes (11)
WalkthroughFrontend test hooks and Playwright end-to-end selectors are standardized across dashboard, details, command-line, alert-routing, channel, notification, and perspective-switching components without changing test behavior. ChangesSelector normalization
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
/pipeline required |
|
Scheduling tests matching the |
|
Flakes in other tests. |
fa9a71b to
88dee0f
Compare
|
Flakes in other tests. |
88dee0f to
da1f149
Compare
Add data-test attributes alongside existing data-test-id attributes in
React source components so Playwright's getByTestId() can target them
(testIdAttribute is configured to match data-test). Then replace all
page.locator('[data-test-id="..."]') calls with idiomatic getByTestId()
in e2e tests and page objects.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add data-test attribute alongside existing data-test-selector on the
DetailsItem label element in details-item.tsx (the value element already
had one). Then replace all page.locator('[data-test-selector="..."]')
calls with getByTestId() in console-notification.spec.ts.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
da1f149 to
c344267
Compare
|
Flakes in other tests. |
|
/test e2e-playwright |
|
/approve |
|
@rhamilto: This PR has been marked as verified by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
Tests from second stage were triggered manually. Pipeline can be controlled only manually, until HEAD changes. Use command to trigger second stage. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: logonoff, rhamilto The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/pipeline required |
|
Scheduling tests matching the |
|
/test backend |
|
@rhamilto: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Analysis / Root cause:
The Playwright e2e tests use
page.locator('[data-test-id="..."]')and similar CSS attribute selectors instead of the idiomaticpage.getByTestId()API. SincetestIdAttributeis configured todata-testinplaywright.config.ts, these legacy attributes (data-test-id,data-test-selector) are not matched bygetByTestId()without first adding a correspondingdata-testattribute to the React source.Solution description:
Three incremental commits replace legacy locator patterns with
getByTestId():data-test-id→getByTestId()— Addsdata-testalongside existingdata-test-idon 4 React components (Dashboard,alert-routing-modalinputs,command-line-tools, node dashboardDetailsCard), then replaces 10page.locator('[data-test-id="..."]')calls across 5 test/page files.data-test-selector→getByTestId()— Addsdata-testalongside existingdata-test-selectoron thedetails-item.tsxlabel element, then replaces 6 locator calls inconsole-notification.spec.ts.locator('[data-test="..."]')→getByTestId()— Replaces 4 remaininglocator('[data-test="x"]')calls with the equivalentgetByTestId('x')inconsole-notification.spec.ts,channel-modal.spec.ts, andcluster-settings-page.ts.Total: 13 files changed, 18 locator calls replaced.
Screenshots / screen recording:
N/A — no visual changes.
Test setup:
Console running locally or in CI.
Test cases:
npx playwright test e2e/tests/console/crd-extensions/console-notification.spec.ts— passes (1 pre-existing failure incrd-test-utils.tsunrelated to these changes)npx playwright test e2e/tests/console/cluster-settings/channel-modal.spec.ts— passesyarn eslinton all changed files — cleanBrowser conformance:
Additional info:
Part of ongoing effort to migrate Playwright tests to idiomatic APIs per the locator priority in
.claude/migration-context.md:getByTestId > getByRole > getByText > locator.Reviewers and assignees:
🤖 Generated with Claude Code
Summary by CodeRabbit