Skip to content

E2E[Content Summarization]: Prefer user-facing attributes#762

Merged
dkotter merged 2 commits into
WordPress:developfrom
yogeshbhutkar:fix/adopt-user-facing-locators
Jun 23, 2026
Merged

E2E[Content Summarization]: Prefer user-facing attributes#762
dkotter merged 2 commits into
WordPress:developfrom
yogeshbhutkar:fix/adopt-user-facing-locators

Conversation

@yogeshbhutkar

@yogeshbhutkar yogeshbhutkar commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What, Why, and How?

Playwright recommends using user-facing locators (example, getByRole) instead of CSS classes or DOM-structure selectors wherever possible. This is because CSS classes and markup structure are implementation details that can change during design or refactoring without changing the actual user experience, which can make tests fail even though the feature still works (Docs).

This PR updates the content summarization E2E spec to follow the Playwright best practices by replacing hard-coded page.locator(...) calls with role-based locators. This should make the test less brittle because it now targets the UI the way a user, or assistive technology, understands it rather than depending on implementation details.

Apart from making the test more resilient to CSS and markup changes, this also makes the assertions easier to read and understand. For example:

// Before:
await page
	.locator( '.editor-sidebar__panel-tabs button:has-text("Post")' )
	.click();

// After:
await page.getByRole( 'tab', { name: 'Post' } ).click();

Note: This PR deliberately scopes the change to the Content Summarization E2E spec only. If we agree this approach is preferable for the reasons above, we can apply it to other E2E specs incrementally, a few modules at a time.

Use of AI Tools

AI assistance: Yes
Tool(s): Codex
Model(s): GPT-5.5
Used for: Code review

Testing Instructions

CI should be green.

Changelog Entry

Changed - Updated Content Summarization E2E selectors to use Playwright user-facing attributes

Open WordPress Playground Preview

- Updated the test suite to use role-based selectors.
- Refactored tests to verify button visibility and state more effectively, enhancing overall test reliability.
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.41%. Comparing base (27e202b) to head (cab0bd5).

Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #762   +/-   ##
==========================================
  Coverage      76.41%   76.41%           
  Complexity      1828     1828           
==========================================
  Files             87       87           
  Lines           7764     7764           
==========================================
  Hits            5933     5933           
  Misses          1831     1831           
Flag Coverage Δ
unit 76.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Also adds `exact: true` wherever required
@yogeshbhutkar yogeshbhutkar changed the title E2E[Content Summarization]: Use role-based locators E2E[Content Summarization]: Prefer user-facing attributes Jun 23, 2026
@yogeshbhutkar yogeshbhutkar marked this pull request as ready for review June 23, 2026 12:15
@github-actions

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: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>

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

@dkotter dkotter added this to the 1.1.0 milestone Jun 23, 2026
@dkotter dkotter merged commit ba6d4b8 into WordPress:develop Jun 23, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants