-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use actual WordPress in Playground tests #463
Comments
@eliot-akira I’m thinking of using the WordPress data modules that already come with the repository. Perhaps a About wp-now specifically, I will propose a vision and a crisp scope for the core Playground repo in a few days. The idea is to stabilize the project, have predictable expectations, and keep it focused on the framework. This involves moving consumer apps to separate repos so let’s put the wp-now part of this issue on hold for now. |
With |
wp-now
package from Playground tests
There's a precedent of this in wordpress-playground/packages/playground/sync/src/test/sql.spec.ts Lines 111 to 120 in 39a7df2
We should find a way to generalize this to all packages. I wonder if Blueprints should do that internally as Playground depends on Blueprints. If Blueprints also depended on Playground, that would be a circular dependency. We should be fine to just copy WordPress 6.3 data module to Blueprints for now and then reflect on the internal dependency graph. Perhaps introducing a |
That sounds like a good solution, it aligns with one of the suggestions in the
I saw that the new package |
#837) Moves WordPress data modules to a new dependency-free module `@wp-playground/wordpress`. Now every Playground module may import WordPress data modules and, e.g., use them in unit tests. Before this PR, WordPress data modules lived in the `@wp-playground/remote` package. They couldn't be easily imported, and even if they could, that would often create a circular dependency problem. Related to #463 ## Implementation details * All WordPress bundling functions are updated to point to the newly created module. * The `@wp-playground/remote` public directory is now set to `packages/playground/wordpress/public` as that's where all the WordPress files live. The `remote` package ships no public assets of its own, except for the .htaccess file which is now handled by a dedicated plugin. * The new module also exports `RecommendedPHPVersion = '8.0'` to help avoid hardcoding a version number in unit tests shipped by other Playground packages. * `@wp-playground/wordpress` has a `bundle-wordpress` nx task that bundles WordPress. It's deliberately not called `build` so that nx does not mistake it for a build dependency (which would trigger it on every `npm run dev`). * Loading the data module from the filesystem is implemented in `@php-wasm/node` by implementing the `getPreloadedPackage` Emscripten handler. The handler runs a few safety checks and then reads the data module from the disk via `readFileSync`. * A new unit test for the `setSiteOptions()` Blueprint step has been added to confirm that WordPress is actually correctly loaded in Node.js. ## Remaining tasks - [x] Run the new `bundle` task to confirm it creates the correct WordPress files in the correct directories. - [x] Add a unit test to the new module to explicitly test loading WordPress (instead of implicitly relying on the `setSiteOption` test) ## Testing instructions Confirm the CI tests pass. E2E tests will confirm the playground.wordpress.net website still loads all the supported WordPress versions, and the unit tests will confirm that WordPress is correctly loaded in Node.js.
With Node.js WordPress support initially merged in #837 and a battery of WordPress-related unit tests added in #982, this issue seems to be solved. Here's a unit test covering the |
From discussion in #427 comment.
A difficulty: if
wp-now
imports from the Playground package being tested, the tests cannot import fromwp-now
because it results in a circular dependency.Found a documentation page about this in the
nx
repository.Resolving Circular Dependencies
Strategies recommended:
The text was updated successfully, but these errors were encountered: