Repository navigation
Tests: Preserve development state during E2E runs - #16262
ArkaPrabhaChowdhury wants to merge 9 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
lancewillett
left a comment
There was a problem hiding this comment.
Please rebase onto trunk and give E2E its own database. In an isolated checkout the normal run preserved the development post and comment, but it erased a table in the PHPUnit database. Two overlapping runs also restored the development database while the second run was still active. Please make a second run stop before it changes that shared configuration, or isolate each run completely.
Please also use the checkout’s configured port when checking the target. With a custom port in .env, setup rejected the correct URL and accepted the default port. After rebasing, please verify the existing permalink/404 spec against the fresh site and run the E2E jobs against both src and build.
AI review · gpt-6.2-astra
There was a problem hiding this comment.
🟡 Changes recommended
E2E setup can destroy concurrent PHPUnit state and leak cached data into the development site, while also mishandling explicit local URLs and the configured WordPress tree.
4 open issues
What changed in this PR
This PR aims to preserve development data during Core E2E runs by temporarily switching database and uploads settings, then restoring the original configuration.
Changes:
- Adds configuration snapshots, teardown restoration, and recovery after interrupted runs.
- Requires explicit isolation confirmation for custom targets and adjusts Docker startup behavior.
- Adds configuration checks and increases the installation-click timeout to 30 seconds.
| File | Description |
|---|---|
tests/e2e/specs/install.test.js |
Increases the install-button click timeout. |
tests/e2e/README.md |
Documents isolation, restoration, and custom-target requirements. |
tests/e2e/playwright.config.js |
Registers teardown and conditionally starts Docker. |
tests/e2e/config/global-teardown.js |
Restores development configuration after E2E runs. |
tests/e2e/config/global-setup.js |
Prepares isolated storage and restores configuration on failure. |
tests/e2e/config/database.test.cjs |
Tests explicit isolation confirmation for custom targets. |
tests/e2e/config/database.js |
Implements database switching, configuration snapshots, and restoration. |
package.json |
Adds configuration checks before the E2E suite. |
.gitignore |
Ignores the E2E uploads directory under src. |
Review effort: Balanced
d72b4dc to
39c0c01
Compare
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
Hi @lancewillett, Thanks a lot for the review. I have addressed the feedback points. Please do check. Thank you! |
lancewillett
left a comment
There was a problem hiding this comment.
The dedicated E2E database preserved a table in the PHPUnit database, and a second process was refused before it changed configuration. The custom port worked. On build, all 123 Playwright tests passed. On src, all four cases in the 404/cache-header and installation specs passed. The three config tests passed. I confirmed the current trunk merges cleanly, so the earlier rebase request is addressed.
I’m keeping the change request on 40a4e2a for these findings:
- The normal development login URL served the E2E site during the run. Please give E2E its own site configuration so the development URL stays attached to its database throughout.
- I simulated an interruption at the install spec’s table-prefix switch. Recovery restored
DB_NAMEbut leftwp_e2e_, and the next run failed because WordPress appeared uninstalled. Restoring only the original prefix made it pass. A stale recovery marker also blocked recovery and left the development URL on the E2E database. - With the bundled Memcached drop-in enabled, a development cache key survived across WP-CLI processes before setup and was gone afterward. The installer flushes the Memcached server, which also evicts keys under the development salt. Please isolate the cache along with the database.
- JSDoc lint fails in the new
global-teardown.jsbecause itsconfigparameter is undocumented.
AI review · gpt-6.2-sol
|
Hi @lancewillett, Thanks for the review again. I have addressed the feedback and requested re-review. Thank you! |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved isolation gaps can direct E2E HTTP, CLI, and filesystem operations at the development site, risking changes to its data, accounts, configuration, and availability.
11 open issues
Inherited WP_HOME and WP_SITEURL redirect E2E to development · New E2E shares development files and can disrupt the site · New Copied custom user tables can modify development accounts · New Local config can bypass E2E routing and modify development content · New Custom E2E URLs still target development CLI and config · New Custom table prefixes break E2E installation tests · New Docker Toolbox does not forward the E2E port · New Use consistent local URL detection for startup and database setup Avoid resetting the database used by active PHPUnit runs Give E2E a separate persistent-cache namespace Use the configured WordPress tree for E2E database setup
Review effort: Balanced
| wpCli( | ||
| [ 'config', 'set', 'DB_NAME', E2E_DB_NAME, '--type=constant' ], | ||
| localDir, | ||
| temporaryConfigFile | ||
| ); |
| wpCli( | ||
| [ 'config', 'set', 'UPLOADS', E2E_UPLOADS, '--type=constant' ], | ||
| localDir, | ||
| temporaryConfigFile |
| wpCli( | ||
| [ 'config', 'set', 'UPLOADS', E2E_UPLOADS, '--type=constant' ], | ||
| localDir, | ||
| temporaryConfigFile | ||
| ); |
| configurationMayBeMutated = false; | ||
| } | ||
|
|
||
| const localDir = getLocalDir(); |
| const configArgs = isDefaultEnvironment( baseURL ) | ||
| ? [ '--env', 'WP_CONFIG_PATH=/var/www/wp-config-e2e.php' ] | ||
| : []; |
| const temporaryConfigPath = path.join( process.cwd(), temporaryConfigFile ); | ||
| await copyFile( rootConfigPath, temporaryConfigPath ); | ||
|
|
||
| try { |
| local_env_utils.ensure_env_file(); | ||
|
|
||
| dotenvExpand.expand( dotenv.config() ); | ||
| process.env.LOCAL_E2E_PORT ||= String( Number( process.env.LOCAL_PORT || 8889 ) + 1 ); |
lancewillett
left a comment
There was a problem hiding this comment.
The default two-port setup kept the development and E2E sites on separate databases. The PHPUnit table and development Memcached key survived. A second process was refused, and recovery discarded the interrupted install prefix and stale recovery marker. Five focused browser cases passed locally on src, and the four build E2E jobs passed in CI. The config tests and JSDoc lint passed.
I’m keeping the change request because development still depends on files the tests change:
- The existing maintenance test’s file returned HTTP 503 on both ports. Please give E2E a separate document tree or otherwise scope that fixture to E2E.
- With a valid document-root
wp-config.phppresent, the E2E port served the development site even after the separate database was installed. Global setup would then send its cleanup requests there. Please verify the HTTP target is isolated before cleanup. - The copied
WP_HOMEandWP_SITEURLkept the E2E site on the development URL. The router also made a valid development config withdeclare(strict_types=1)fail PHP lint and prevented either login page from loading. Please avoid rewriting the development config or preserve its PHP structure and use E2E-specific URL settings.
AI review · gpt-6.2-sol


Summary
wp-config-e2e.php, keeping the development site on its original database configuration.WP_E2E_ISOLATED=truefor custom targets and use consistent local-target detection for Docker startup and database setup.Trac ticket: https://core.trac.wordpress.org/ticket/66227
Checks
npm run test:e2e:config-- 5 passed.LOCAL_DIR=build) -- all four serial/parallel jobs passed: 123 tests withSCRIPT_DEBUGenabled and 123 with it disabled.npm run lint:jsdoc -- --no-ignore tests/e2e/config/database.js tests/e2e/config/database.test.cjs tests/e2e/playwright.config.js tests/e2e/utils/wp-cli.js tests/e2e/config/global-teardown.js-- passed.wp-scripts lint-js --no-ignoreon touched JavaScript -- passed.git diff --check-- passed.Use of AI Tools
This pull request is for code review only. Please keep other discussion in the Trac ticket. Do not merge this pull request on GitHub.