feat(eslint): add stable Playwright action locator rule - #44
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR adds an opt-in Playwright ESLint rule that reports static copy-based locators used for actions. It supports locator aliases and wrappers, includes tests for allowed patterns, and documents configuration and exceptions. ChangesStable action locators
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ESLint
participant PlaywrightSpec
participant PreferStableActionLocator
participant LocatorAnalysisHelpers
ESLint->>PlaywrightSpec: load Playwright configuration
PlaywrightSpec->>PreferStableActionLocator: inspect locator action
PreferStableActionLocator->>LocatorAnalysisHelpers: resolve locator chain
LocatorAnalysisHelpers-->>PreferStableActionLocator: return selector classification
PreferStableActionLocator-->>ESLint: report static copy locator
Possibly related PRs
Suggested reviewers: Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
limetech-playwright/prefer-stable-action-locatorrulehasTextconstraintsWhy
Action steps such as
getByText("Save").click()become brittle when consumer applications translate or revise UI copy. A stable semantic test ID keeps the journey coupled to behavior instead of wording. The policy remains opt-in because third-party surfaces and accessibility-first suites cannot always add IDs and may intentionally use role/name action locators.Validation
pnpm test— 41 tests passedpnpm run format:check— passedgit diff --check— passedConsumer follow-up
After this ships in a release, Account can enable the rule for its E2E files and migrate action targets to stable test IDs incrementally. The diagnostic findings should be triaged rather than fixed blindly, especially for third-party, dynamic-data, and accessibility-specific interactions.
Summary by CodeRabbit
New Features
Documentation
data-testidusage, and documented exceptions.