Skip to content

Tests: Replace page-level selectors with locators in e2e specs - #81053

Merged
Mamaduka merged 3 commits into
trunkfrom
fix/tests-eslint-warnings
Aug 2, 2026
Merged

Tests: Replace page-level selectors with locators in e2e specs#81053
Mamaduka merged 3 commits into
trunkfrom
fix/tests-eslint-warnings

Conversation

@Mamaduka

@Mamaduka Mamaduka commented Aug 2, 2026

Copy link
Copy Markdown
Member

What?

PR bulk fixes playwright/prefer-locator ESLint warnings in test/e2e/specs by converting page.click( 'role=…' )-style calls to locator chains, preferring getByRole.

Why?

These are leftovers from the pre-locator Playwright API. Locators auto-wait and retry; page-level selector methods don't.

How?

Mechanical conversion, preserving matching semantics:

Selector Result
role=button[name="X"i] getByRole( 'button', { name: 'X' } )
role=button[name="X"] (no i) getByRole( 'button', { name: 'X', exact: true } )
role=button[name=/X/i] getByRole( 'button', { name: /X/i } )
role=heading[…][level=3] getByRole( 'heading', { …, level: 3 } )
a >> b .getByRole( … ).getByRole( … )
text=X / text="X" getByText( 'X' ) / getByText( 'X', { exact: true } )
CSS selectors .locator( … )

Testing Instructions

Tests-only change; relying on CI. npm run lint:js -- test/e2e/specs should report no prefer-locator warnings, down from 217, with all other rule counts unchanged.

Use of AI Tools

Assisted By Claude

@Mamaduka Mamaduka self-assigned this Aug 2, 2026
@Mamaduka Mamaduka added the [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. label Aug 2, 2026
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka
Mamaduka requested a review from t-hamano August 2, 2026 07:09
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.78 MB

compressed-size-action

@Mamaduka
Mamaduka force-pushed the fix/tests-eslint-warnings branch from a01b917 to 8653875 Compare August 2, 2026 07:58

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment thread test/e2e/specs/widgets/customizing-widgets.spec.js Outdated
Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
@Mamaduka
Mamaduka enabled auto-merge (squash) August 2, 2026 10:03
@Mamaduka
Mamaduka merged commit d15606e into trunk Aug 2, 2026
42 checks passed
@Mamaduka
Mamaduka deleted the fix/tests-eslint-warnings branch August 2, 2026 10:37
@github-actions github-actions Bot added this to the Gutenberg 23.8 milestone Aug 2, 2026
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

Flaky tests detected in 352e86f.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/30742958400
📝 Reported issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants