Repository navigation
Conversation
There was a problem hiding this comment.
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.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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-checkis also registered on this governing setup, and consumer sites additionally registerDELETE /brand-config. Both routes fall back tomanage_optionsfor 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()expectswrite_keyto 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 );
There was a problem hiding this comment.
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
@paramentries no longer align the variable column with the fully qualified request type above, unlike the surrounding PHPDoc and the extracted implementation inTestCase.php. Restore the spacing so this new PHPCS-scanned file follows the repository's function-comment formatting.
There was a problem hiding this comment.
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 usescheck_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_Controlleronly while the site is governing, so it testsGET /brand-configbut never registers or authorizes the consumer-onlyDELETE /brand-confighandler. 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.
|
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.... |
|
@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.
The 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. |
The implementation is the main concern.
Except you're not using them to test Algolia, you're using them to test
If there is reason for a live API smoke test, then move this and the parent
What's wrong with
Putting aside that seems like crazy overkill (it's e2e tests, we want to use the UI, we have
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. |
459722d to
3800838
Compare
justlevine
left a comment
There was a problem hiding this comment.
Didn't review the individual scenarios yet, just some initial cleanup feedback
| "config": { | ||
| "FS_METHOD": "direct", | ||
| "WP_DEBUG": true, | ||
| "ONESEARCH_MOCK_ALGOLIA": true, |
There was a problem hiding this comment.
Putting aside whether we need this mock, are we enabling it for both e2e and phpunit?
There was a problem hiding this comment.
Yes, both E2E and PHPUnit use the shared Algolia mock.
There was a problem hiding this comment.
I think we can drop this constant now that it's handled by the mu plugin. enabled plugin === active.
| "ONESEARCH_MOCK_ALGOLIA": true, |
…ntities tests for consistency
…ter validation Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…governing-site search
acd7bb0 to
7283b24
Compare
justlevine
left a comment
There was a problem hiding this comment.
Last round of feedback and we should be good to merge.
| 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. |
There was a problem hiding this comment.
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.
| 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. |
| files: [ 'tests/e2e/**/*.{ts,tsx}' ], | ||
| rules: { | ||
| 'jsdoc/no-undefined-types': 'off', | ||
|
|
| "./tests/_data/plugins/localhost-helper.php", | ||
| "./tests/_data/plugins/algolia-helper.php" | ||
| ], | ||
| "themes": [ "WordPress/twentytwentyone", "WordPress/twentytwentyfive" ], |
There was a problem hiding this comment.
Is TT5 not enough?
| "themes": [ "WordPress/twentytwentyone", "WordPress/twentytwentyfive" ], | |
| "themes": [ "WordPress/twentytwentyfive" ], |
| "./tests/_data/plugins/localhost-helper.php", | ||
| "./tests/_data/plugins/algolia-helper.php" | ||
| ], | ||
| "config": { |
There was a problem hiding this comment.
Does the child site not need a theme, the way the governing test env does?
| "config": { | ||
| "FS_METHOD": "direct", | ||
| "WP_DEBUG": true, | ||
| "ONESEARCH_MOCK_ALGOLIA": true, |
There was a problem hiding this comment.
I think we can drop this constant now that it's handled by the mu plugin. enabled plugin === active.
| "ONESEARCH_MOCK_ALGOLIA": true, |
| async function searchedSites( site: OneSearchUtils ) { | ||
| return ( await site.algoliaRequests() ) |
There was a problem hiding this comment.
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)
| async function searchedSites( site: OneSearchUtils ) { | |
| return ( await site.algoliaRequests() ) | |
| function searchedSites( site: OneSearchUtils ) { | |
| return site.algoliaRequests() |
| 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! ) | ||
| ); | ||
| } | ||
| } ); |
There was a problem hiding this comment.
This seems unnecessary...
| { label && <span className="msc-label">{ label }</span> } | ||
| <button | ||
| type="button" | ||
| aria-label={ ariaLabel || label || placeholder } |
There was a problem hiding this comment.
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.
| ariaLabel={ sprintf( | ||
| /* translators: %s: site name */ | ||
| __( | ||
| 'Select entities… for %s', | ||
| 'onesearch' | ||
| ), | ||
| __( 'Governing Site', 'onesearch' ) | ||
| ) } |
There was a problem hiding this comment.
| ariaLabel={ sprintf( | |
| /* translators: %s: site name */ | |
| __( | |
| 'Select entities… for %s', | |
| 'onesearch' | |
| ), | |
| __( 'Governing Site', 'onesearch' ) | |
| ) } |
| ariaLabel={ sprintf( | ||
| /* translators: %s: site name */ | ||
| __( | ||
| 'Select entities… for %s', | ||
| 'onesearch' | ||
| ), | ||
| site.name | ||
| ) } |
There was a problem hiding this comment.
| ariaLabel={ sprintf( | |
| /* translators: %s: site name */ | |
| __( | |
| 'Select entities… for %s', | |
| 'onesearch' | |
| ), | |
| site.name | |
| ) } |


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
Checklist