E2E Test for api.html site export - #4231
Merged
Merged
Conversation
Co-authored-by: Brandon Payton <brandon@happycode.net>
ashfame
marked this pull request as ready for review
August 3, 2026 11:28
## What Adds a short explanation to `api.html` for people who open the endpoint directly. The paragraph starts with the HTML `hidden` attribute and a small synchronous script reveals it only when `window.self === window.top`. The existing module import remains in `api.html`, but `bootPlaygroundAPI()` is called only when the page is embedded, so direct navigation does not initialize the export API and iframe consumers never receive a visible artifact. ## Direct navigation Opening `api.html` as the top-level page shows the intended explanation.  ## Embedded export For verification, the API iframe was deliberately made visible and given a border. It remained blank before and after exporting a real saved site.  ## `startPlaygroundWeb()` handling Passing `api.html` as the `remoteUrl` to `startPlaygroundWeb()` does not load this page. The client validates the URL before assigning `iframe.src` and throws an `Invalid remote URL` error because `startPlaygroundWeb()` requires the pathname to be `/remote.html`. The new direct-navigation explanation therefore covers someone opening `api.html` in a browser, while the existing client error covers this API misuse. ## Tested - Navigated directly to `api.html` and confirmed the explanation is visible, `window.playgroundAPI` is not initialized, and no page errors occur. - Loaded `api.html` in an iframe and confirmed its body remains visually empty, its paragraph retains `hidden` with zero client rects, `window.playgroundAPI` is initialized, and no page errors occur. - Called `startPlaygroundAPI()` with a deliberately visible iframe, seeded a real OPFS saved site, and ran `exportSavedSiteAsZip()`. - Confirmed the export returned `application/zip`, 647 bytes, with the ZIP `PK\x03\x04` signature. - Confirmed the iframe body remained empty and the paragraph had zero visible client rects both before and after export. - Confirmed `npm exec nx lint playground-website` and `npm exec nx typecheck playground-website` pass.
… agent/pr4219-test-quality # Conflicts: # packages/playground/website/src/lib/state/opfs/opfs-site-storage.spec.ts
ashfame
force-pushed
the
agent/api-html-e2e-test
branch
from
August 3, 2026 17:32
552508e to
357be89
Compare
ashfame
force-pushed
the
agent/hosted-playground-api-deployment
branch
from
August 3, 2026 17:32
a9045ec to
27cc386
Compare
Base automatically changed from
agent/hosted-playground-api-deployment
to
trunk
August 4, 2026 06:58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/api.html, exports a saved OPFS site, and verifies the returned ZIP contains unique site content.client/index.jsshim respect Vite's configured base path.Why
This is stacked on #4220 and verifies the saved-site export API through the same public entry points consumers use.
The test directly seeds a minimal valid OPFS site so it isolates the API contract without coupling the coverage to WordPress startup or unrelated site-manager UI behavior. Its output assertion verifies the complete browser-to-iframe-to-OPFS-to-ZIP path.
Exercising the real development deployment exposed that the public client shim emitted a root-relative
/@fs/import even when the website was served below/website-server/. Using Vite's configured base fixes that path.Validation
npm exec nx -- run playground-website:e2e:playwright --args='packages/playground/website/playwright/e2e/api.spec.ts --project=chromium'npm exec nx -- run playground-website:lintnpm exec nx -- run playground-website:typechecknpm exec nx -- run playground-website:buildgit diff --check