Skip to content

test: e2e playwright coverage - #303

Open
Kallyan01 wants to merge 21 commits into
mainfrom
test/e2e-playwright-coverage
Open

Kallyan01 wants to merge 21 commits into
mainfrom
test/e2e-playwright-coverage

Conversation

@Kallyan01

@Kallyan01 Kallyan01 commented Sep 1, 2026 •

Copy link
Copy Markdown
Collaborator

What

Adds Playwright E2E coverage for the journeys that need both a governing and a brand site running together, plus the accessible names the tests locate controls by.

Why

Nothing tested the flows that only break when both installs run: the brand-site handshake, re-indexing every connected site, a brand site searching with the governing site's configuration, and disconnecting. PHPUnit covers the endpoints on one site at a time, and Vitest covers the components.

Related Issue(s):

How

Scope

A journey goes in E2E only if it crosses both sites, depends on PHP-rendered data reaching the React screen, or checks a theme render. Validation messages, disabled states, REST permission matrices and Algolia SDK behaviour are left to Vitest and PHPUnit.

AI Disclosure

Used Opus 5.5 for refactoring the mock-Algolia environment and verifying the test case impacts.

Testing Instructions

npm install && composer install
npm run build:prod
npm run test:e2e   # starts both test sites if they are not running

Checklist

  • I have read the Contribution Guidelines.
  • I have read the Development Guidelines.
  • I have added necessary tests to cover my changes.
  • I have updated the project documentation as needed.
  • My code has detailed inline documentation.
  • My code is tested to the best of my abilities.
  • My code passes all lints, tests, and checks.
Open WordPress Playground Preview

@Kallyan01
Kallyan01 requested a balanced review from Copilot September 1, 2026 09:05
@Kallyan01 Kallyan01 self-assigned this Sep 1, 2026
@Kallyan01
Kallyan01 marked this pull request as ready for review September 1, 2026 09:08

Copilot AI 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.

Pull request overview

Adds broad Playwright coverage for OneSearch, including real governing-to-brand site communication and REST authorization checks.

Changes:

  • Adds 45 E2E tests and a second WordPress test environment.
  • Introduces shared Algolia mocking and authorization coverage.
  • Improves admin-control accessibility and testing documentation.

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/phpunit/TestCase.php Uses shared Algolia mock.
tests/phpunit/Support/Mock_Algolia_Http_Client.php Implements shared mock transport.
tests/phpunit/Integration/Modules/Search/WatcherTest.php Updates mock terminology.
tests/phpunit/Integration/Modules/Rest/RouteAuthorizationTest.php Tests privileged REST routes.
tests/e2e/settings/settings-page.spec.ts Covers settings variants.
tests/e2e/settings/rest-authorization.spec.ts Tests browser REST authorization.
tests/e2e/settings/capabilities.spec.ts Tests editor access restrictions.
tests/e2e/settings/brand-sites.spec.ts Covers brand-site management.
tests/e2e/settings/brand-site-connection.spec.ts Covers brand connections.
tests/e2e/settings/algolia-credentials.spec.ts Covers credential management.
tests/e2e/settings/activation.spec.ts Expands activation coverage.
tests/e2e/search/site-search-settings.spec.ts Covers search configuration.
tests/e2e/search/setup-required.spec.ts Tests setup prerequisites.
tests/e2e/search/indexable-entities.spec.ts Covers indexing workflows.
tests/e2e/search/brand-site-fan-out.spec.ts Tests cross-site fan-out.
tests/e2e/scaffold/test.ts Defines shared fixtures.
tests/e2e/scaffold/onesearch-utils.ts Adds state-seeding utilities.
tests/e2e/scaffold/index.ts Exports scaffold utilities.
tests/e2e/scaffold/constants.ts Defines E2E constants.
tests/e2e/onboarding/site-type.spec.ts Covers onboarding flows.
tests/e2e-smoke/algolia-live.spec.ts Adds live Algolia smoke tests.
tests/_data/mu-plugins/onesearch-e2e-helper.php Adds test-state REST endpoints.
playwright.smoke.config.ts Configures smoke tests.
playwright.config.ts Starts both test sites.
package.json Adds E2E commands.
inc/Modules/Settings/Admin.php Adds dialog semantics.
eslint.config.mjs Supports test configuration files.
docs/DEVELOPMENT.md Documents E2E architecture.
assets/src/components/SiteSearchSettings.tsx Adds accessible labels.
assets/src/components/SiteIndexableEntities.tsx Labels entity controls.
assets/src/components/MultiSelectChips.tsx Supports accessible names.
.wp-env.test.json Maps the E2E helper.
.wp-env.test-child.json Defines the brand test site.
.phpcs.xml.dist Lints test mu-plugins.
.github/workflows/reusable-e2e.yml Starts the brand environment.
.github/workflows/ci.yml Expands E2E path triggers.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread inc/Modules/Settings/Admin.php Resolved
@codecov-commenter

codecov-commenter commented Sep 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.87%. Comparing base (6566895) to head (961999b).

Files with missing lines Patch % Lines
assets/src/components/MultiSelectChips.tsx 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #303      +/-   ##
============================================
- Coverage     91.92%   90.87%   -1.05%     
  Complexity      894      894              
============================================
  Files            37       51      +14     
  Lines          2711     3343     +632     
  Branches          0      190     +190     
============================================
+ Hits           2492     3038     +546     
- Misses          219      250      +31     
- Partials          0       55      +55     
Flag Coverage Δ
unit 91.92% <ø> (ø)
vitest 86.39% <0.00%> (?)

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

Files with missing lines Coverage Δ
assets/src/components/SiteIndexableEntities.tsx 85.54% <ø> (ø)
assets/src/components/SiteSearchSettings.tsx 84.56% <ø> (ø)
assets/src/components/MultiSelectChips.tsx 72.88% <0.00%> (ø)

... and 11 files with indirect coverage changes

🚀 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.

Copilot AI review requested due to automatic review settings September 1, 2026 11:47
@Kallyan01 Kallyan01 changed the title E2E playwright coverage test: e2e playwright coverage Sep 1, 2026

Copilot AI 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.

Pull request overview

Copilot reviewed 37 out of 38 changed files in this pull request and generated no new comments.

Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

tests/phpunit/Integration/Modules/Rest/RouteAuthorizationTest.php:84

  • This provider is not exhaustive for check_api_permissions(): GET /health-check is also registered on this governing setup, and consumer sites additionally register DELETE /brand-config. Both routes fall back to manage_options for same-origin requests, so the editor/subscriber matrix currently leaves two privileged methods untested despite the class/PR claiming coverage of every privileged route. Add the health-check case and a consumer-site setup for the DELETE variant.

tests/_data/mu-plugins/onesearch-e2e-helper.php:276

  • Seed governing Algolia credentials through the production setter instead of writing this option verbatim. Search_Settings::get_algolia_credentials() expects write_key to be encrypted, while this fallback stores the test key in plaintext; consequently the E2E “loads stored credentials” path does not use production-formatted state and can hide decryption/storage regressions.
	update_option( $option, $value );

Copilot AI review requested due to automatic review settings September 1, 2026 12:13

Copilot AI 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.

Pull request overview

Copilot reviewed 38 out of 39 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

tests/phpunit/Support/Mock_Algolia_Http_Client.php:128

  • These @param entries no longer align the variable column with the fully qualified request type above, unlike the surrounding PHPDoc and the extracted implementation in TestCase.php. Restore the spacing so this new PHPCS-scanned file follows the repository's function-comment formatting.

Comment thread tests/e2e/onboarding/site-type.spec.ts Resolved
Copilot AI review requested due to automatic review settings September 1, 2026 14:03

Copilot AI 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.

Pull request overview

Copilot reviewed 42 out of 43 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings September 1, 2026 14:26

Copilot AI 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.

Pull request overview

Copilot reviewed 42 out of 43 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings September 1, 2026 14:42

Copilot AI 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.

Pull request overview

Copilot reviewed 42 out of 43 changed files in this pull request and generated no new comments.

Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

tests/phpunit/Integration/Modules/Rest/RouteAuthorizationTest.php:84

  • The authorization matrix omits GET /health-check, even though that route uses check_api_permissions() and is reachable through the same administrator-or-token boundary as the other routes. Existing health-check tests cover only an administrator and a valid token, so an editor/subscriber denial is not exercised. Add it to this provider so the claimed privileged-route coverage includes this endpoint.
    tests/phpunit/Integration/Modules/Rest/RouteAuthorizationTest.php:101
  • This suite registers Governing_Data_Controller only while the site is governing, so it tests GET /brand-config but never registers or authorizes the consumer-only DELETE /brand-config handler. That leaves a privileged REST method outside the supposedly exhaustive editor/subscriber matrix. Add a consumer-site authorization case (or parameterize the provider/setup by site role) for the DELETE handler.

@Kallyan01
Kallyan01 requested a review from justlevine September 1, 2026 14:49
@justlevine

justlevine commented Sep 5, 2026 •

Copy link
Copy Markdown
Collaborator

This entire PR reads like AI slop... Genuinely cant tell what here is intentional and what here was initiated by the AI and is totally not necessary....

@Kallyan01

Kallyan01 commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator Author

@justlevine If my review and verification are the main concerns here, I’ve cross-verified the changes and tested them locally. The configuration and tests look legitimate to me, and I haven’t found any issues with the current implementation.

playwright.smoke.config.ts was intentional and is specifically used to verify Algolia operations with real credentials. As you know, we cannot use real credentials in the testing environment, so this config is only intended for testing against production.

.wp-env.test-child.json was created specifically for the test brand site.

mu-plugins/onesearch-e2e-helper.php serves two test-only purposes:
It adds a REST endpoint (onesearch-e2e/v1/state) that allows Playwright to seed, read, and reset plugin options and transients directly, bypassing the UI.
It mocks Algolia’s outbound HTTP client so that the E2E tests do not make requests to the real Algolia API.

The tests/e2e/scaffold files are used to set up the test environment and configure the required values for the tests.

We can have a separate discussion about how we can handle these test-specific utilities and environment setup more cleanly.

I'll still check once again the test cases and ask for re-review tomorrow.

Comment thread docs/DEVELOPMENT.md Resolved
@justlevine

Copy link
Copy Markdown
Collaborator

@justlevine If my review and verification are the main concerns here

The implementation is the main concern.

playwright.smoke.config.ts was intentional and is specifically used to verify Algolia operations with real credentials. As you know, we cannot use real credentials in the testing environment, so this config is only intended for testing against production.

Except you're not using them to test Algolia, you're using them to test

  • Does our endpoint send them to our algolia caller - tested by integration, test, and now possibly regular e2e (i didn't review thoroughly)
  • Does the algolia library itself work - tested by the algolia library.

If there is reason for a live API smoke test, then move this and the parent playwright.config.ts into tests or even tests/e2e instead of muddying up our root dir, but as it stands I dont see a reason.

.wp-env.test-child.json was created specifically for the test brand site.

What's wrong with WP_ENV_PORT=8891 npm run wp-env:test ? Also, why does every reference to it in docs and code need to call it the "real" child site. Is there a fake one? FR the doc-slop is absolutely rampant here.

mu-plugins/onesearch-e2e-helper.php serves two test-only purposes: It adds a REST endpoint (onesearch-e2e/v1/state) that allows Playwright to seed, read, and reset plugin options and transients directly, bypassing the UI. It mocks Algolia’s outbound HTTP client so that the E2E tests do not make requests to the real Algolia API.

Putting aside that seems like crazy overkill (it's e2e tests, we want to use the UI, we have requestUtils and all the core setting endpoints ), why is it

  1. an mu-plugin vs a plugin
  2. It's own plugin vs a part of the existing localhost-helper

Ultimately, it feels like you just asked Claude to "backfill e2e tests" without thinking about or scoping what should be an e2e test (versus a jest or a phpunit test), and everything else just snowballed from there. If that's the case or if you need help determining what should be tested, lmk and we can hop on a call and go through it. Either way, looking forward to your re-review.

@Kallyan01
Kallyan01 force-pushed the test/e2e-playwright-coverage branch from 459722d to 3800838 Compare October 27, 2026 09:39
@Kallyan01
Kallyan01 requested a review from justlevine October 27, 2026 13:22

@justlevine justlevine left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Didn't review the individual scenarios yet, just some initial cleanup feedback

Comment thread .github/.codecov.yml Resolved
Comment thread docs/DEVELOPMENT.md Resolved
Comment thread .wp-env.test-child.json Resolved
Comment thread .wp-env.test.json
"config": {
"FS_METHOD": "direct",
"WP_DEBUG": true,
"ONESEARCH_MOCK_ALGOLIA": true,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Putting aside whether we need this mock, are we enabling it for both e2e and phpunit?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, both E2E and PHPUnit use the shared Algolia mock.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we can drop this constant now that it's handled by the mu plugin. enabled plugin === active.

Suggested change
"ONESEARCH_MOCK_ALGOLIA": true,

Comment thread tests/js/MultiSelectChips.test.tsx Resolved
Comment thread docs/DEVELOPMENT.md Resolved

Copilot AI 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.

🔵 Needs a closer look

The E2E environment does not install twentytwentyone, causing the new search spec to fail during theme activation on fresh CI before validating search results.

3 open issues

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 12, 2026 13:06

Copilot AI 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.

🟡 Changes recommended

The E2E setup does not provision Twenty Twenty-One, causing the theme test to fail during activation on clean installations before its search assertions run.

4 open issues

Review effort: Balanced

Comment thread .wp-env.test.json Resolved
Kallyan01 and others added 20 commits November 25, 2026 21:27
…ter validation

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Kallyan01
Kallyan01 force-pushed the test/e2e-playwright-coverage branch from acd7bb0 to 7283b24 Compare November 25, 2026 16:07
Copilot AI balanced review requested due to automatic review settings December 1, 2026 12:59

Copilot AI 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.

🟢 Approval recommended

No active review issues are reported for the OneSearch test coverage and supporting infrastructure changes.

No open issues 🎉

4 resolved since last review

Review effort: Balanced

@justlevine justlevine left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Last round of feedback and we should be good to merge.

Comment thread docs/DEVELOPMENT.md
Comment on lines +497 to +499
The tests run against the built plugin, so run `npm run build:prod` and `composer install` first. They use two sites, started if they are not already running: the governing site on port 8889 (`npm run wp-env:test start`) and a brand site on port 8891 (`npm run wp-env:test-child start`). Algolia is stubbed by `tests/_data/plugins/algolia-helper.php` in both test environments. Specs import their fixtures and helpers from `tests/e2e/_support`.

PHPUnit shares the governing site's database, clears its permalink structure, which the plugin needs for its `/wp-json/` URLs, and switches it to a theme that doesn't exist. After `npm run test:php`, run `npm run wp-env:test start -- --update` and `npm run wp-env:test -- run cli wp theme activate twentytwentyfive` before the E2E tests.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Most of this is AI slop that we don't need to care about in this section.

If TT5 is required to be active, then we should update either the setup or even the wp-env config files to activate it instead of requiring an activation command.

Suggested change
The tests run against the built plugin, so run `npm run build:prod` and `composer install` first. They use two sites, started if they are not already running: the governing site on port 8889 (`npm run wp-env:test start`) and a brand site on port 8891 (`npm run wp-env:test-child start`). Algolia is stubbed by `tests/_data/plugins/algolia-helper.php` in both test environments. Specs import their fixtures and helpers from `tests/e2e/_support`.
PHPUnit shares the governing site's database, clears its permalink structure, which the plugin needs for its `/wp-json/` URLs, and switches it to a theme that doesn't exist. After `npm run test:php`, run `npm run wp-env:test start -- --update` and `npm run wp-env:test -- run cli wp theme activate twentytwentyfive` before the E2E tests.
The tests require a live site instances for both the test governing site (`npm run wp-env:test start`) and test brand site (`npm run wp-env:test-child start`) to work.

Comment thread eslint.config.mjs
files: [ 'tests/e2e/**/*.{ts,tsx}' ],
rules: {
'jsdoc/no-undefined-types': 'off',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change

Comment thread .wp-env.test.json
"./tests/_data/plugins/localhost-helper.php",
"./tests/_data/plugins/algolia-helper.php"
],
"themes": [ "WordPress/twentytwentyone", "WordPress/twentytwentyfive" ],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is TT5 not enough?

Suggested change
"themes": [ "WordPress/twentytwentyone", "WordPress/twentytwentyfive" ],
"themes": [ "WordPress/twentytwentyfive" ],

Comment thread .wp-env.test-child.json
"./tests/_data/plugins/localhost-helper.php",
"./tests/_data/plugins/algolia-helper.php"
],
"config": {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does the child site not need a theme, the way the governing test env does?

Comment thread .wp-env.test.json
"config": {
"FS_METHOD": "direct",
"WP_DEBUG": true,
"ONESEARCH_MOCK_ALGOLIA": true,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we can drop this constant now that it's handled by the mu plugin. enabled plugin === active.

Suggested change
"ONESEARCH_MOCK_ALGOLIA": true,

Comment on lines +21 to +22
async function searchedSites( site: OneSearchUtils ) {
return ( await site.algoliaRequests() )

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a reason I'm not seeing this needs to be async? I ask because E2E tests are already long, so if there's a way to not lock things with await, probably better.

(I noticed this here, but I think it applies generally throughout the tests.Maybe ask your AI to do a pass dropping any unnecessary asyncs)

Suggested change
async function searchedSites( site: OneSearchUtils ) {
return ( await site.algoliaRequests() )
function searchedSites( site: OneSearchUtils ) {
return site.algoliaRequests()

Comment on lines +74 to +94
it( 'includes the visible selector text in each site’s accessible name', () => {
answer( {} );
renderEntities( {
sites: [ brandSite ],
allPostTypes: {
[ currentSiteUrl ]: [ { slug: 'post', label: 'Posts' } ],
[ brandSiteUrl ]: [ { slug: 'page', label: 'Pages' } ],
},
} );

for ( const siteName of [ 'Governing Site', 'Brand Site' ] ) {
const selector = screen.getByRole( 'button', {
name: `Select entities… for ${ siteName }`,
} );
const visibleText =
within( selector ).getByText( 'Select entities…' );
expect( selector ).toHaveAccessibleName(
expect.stringContaining( visibleText.textContent! )
);
}
} );

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems unnecessary...

{ label && <span className="msc-label">{ label }</span> }
<button
type="button"
aria-label={ ariaLabel || label || placeholder }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think we need the aria-label now that the wrappers have a role="group". "Select entities... for %s" also feels pretty awkward.

IMO we can drop.

Comment on lines +280 to +287
ariaLabel={ sprintf(
/* translators: %s: site name */
__(
'Select entities… for %s',
'onesearch'
),
__( 'Governing Site', 'onesearch' )
) }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

#303 (comment)

Suggested change
ariaLabel={ sprintf(
/* translators: %s: site name */
__(
'Select entities… for %s',
'onesearch'
),
__( 'Governing Site', 'onesearch' )
) }

Comment on lines +354 to +361
ariaLabel={ sprintf(
/* translators: %s: site name */
__(
'Select entities… for %s',
'onesearch'
),
site.name
) }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

#303 (comment)

Suggested change
ariaLabel={ sprintf(
/* translators: %s: site name */
__(
'Select entities… for %s',
'onesearch'
),
site.name
) }

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.

4 participants