Skip to content

[Website] Add E2E coverage for playground-zip import regressions - #3874

Merged
brandonpayton merged 9 commits into
trunkfrom
codex/import-opfs-follow-up
Jul 18, 2026
Merged

[Website] Add E2E coverage for playground-zip import regressions#3874
brandonpayton merged 9 commits into
trunkfrom
codex/import-opfs-follow-up

Conversation

@ashfame

@ashfame ashfame commented Jul 2, 2026

Copy link
Copy Markdown
Member

What changed

  • Add an inline comment explaining why ZIP imports explicitly flush OPFS before reporting success.
  • Add Chromium E2E coverage for imported saved-site durability.

E2E test coverage

  1. Creates a temporary Playground with a known marker and saves it to OPFS.
  2. Imports a generated ZIP containing a distinct marker into a new saved Playground.
  3. Waits for exactly one success alert and resolves the imported site slug.
  4. Immediately fresh-boots the imported slug from ?site-slug=<slug>, discarding the runtime that performed the import.
  5. Requests the imported marker from the fresh runtime and confirms that it was restored from saved storage.
  6. Verifies that no “Save failed” or “Site failed” UI appears.
  7. Switches to the original saved site, then back to the imported site, and verifies that the marker still loads.
  8. Direct-loads the imported slug once more and verifies that the marker remains available.

Why

The previous assertion order requested the imported marker from the active import runtime before switching sites. Completing that request emits request.end, which can trigger background OPFS flushing and mask files that were not durable when import success was reported.

Fresh-booting first checks the user-visible contract: once import reports success, the imported files can be restored from saved storage. This intentionally remains a black-box durability check; it does not couple the test to Comlink or assert which OPFS flush path completed.

Follow-up to review feedback on #3847.

@ashfame
ashfame marked this pull request as ready for review July 2, 2026 23:26
@ashfame
ashfame requested review from a team, brandonpayton and Copilot July 2, 2026 23:26
@ashfame ashfame changed the title [Website] Add E2E coverage for zip import persistence Jul 2, 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

Note

Copilot was unable to run its full agentic suite in this review.

This PR improves reliability of ZIP imports into OPFS by ensuring imported files are flushed before reporting success, and adds an E2E regression test to verify imported sites persist across site switches and reloads.

Changes:

  • Document why OPFS flush is required after ZIP import before surfacing success.
  • Add Playwright E2E coverage for ZIP import persistence across switching sites and direct reload by site-slug.
  • Add small E2E helpers for getting/setting the active site and navigating within the Playground.

Reviewed changes

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

File Description
packages/playground/website/src/components/saved-playgrounds-overlay/index.tsx Adds an inline comment clarifying the OPFS flush rationale during ZIP import flow.
packages/playground/website/playwright/e2e/opfs.spec.ts Adds a regression E2E test plus helpers to validate ZIP import persistence across navigation and site switching.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/playground/website/playwright/e2e/opfs.spec.ts Outdated
Comment thread packages/playground/website/playwright/e2e/opfs.spec.ts
Comment thread packages/playground/website/playwright/e2e/opfs.spec.ts Outdated
Comment thread packages/playground/website/playwright/e2e/opfs.spec.ts
Comment thread packages/playground/website/src/components/saved-playgrounds-overlay/index.tsx Outdated
@ashfame

ashfame commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

@brandonpayton Can you take a look at this too? This is awaiting your review based on your feedback in #3847

@brandonpayton

Copy link
Copy Markdown
Member

It looks like the dock UI change probably broke this PR, and I'm having an agent look at that as part of reviewing this PR.

…esting-follow-up-2knrg

# Conflicts:
#	packages/playground/website/src/components/saved-playgrounds-overlay/index.tsx
The persistence test previously requested the imported marker from the active import runtime before switching sites. Completing that request emits request.end and can trigger background OPFS flushing, masking writes that were not durable when import success was reported.

Boot the imported site directly from its saved slug before issuing the first marker request. Keep the existing failure UI checks, switch-away and switch-back coverage, final direct reload, and exact success-dialog assertion unchanged.

This remains a black-box durability check rather than an assertion about a specific flush RPC; automatic filesystem-write flushing may still settle before the success dialog.
The persistence test fresh-boots the imported saved-site slug so that its first test-controlled request cannot run in the runtime that performed the ZIP import.

Keep the marker navigation and content assertion immediately after that top-level reload. This makes the durability boundary explicit: the old runtime has been discarded, and the marker must be restored from OPFS before the fresh runtime can serve it. Checking the marker before the reload could emit request.end and allow automatic background flushing to mask a missing import-time flush.

Move the existing Save failed and Site failed checks after the marker assertion, while retaining the later switch-away, switch-back, direct-reload, and exact success-dialog coverage.

This remains a black-box check of the user-visible contract. It verifies that an import reported as successful is durable at the next boot without coupling the test to Comlink or asserting which OPFS flush path completed.
@brandonpayton

brandonpayton commented Jul 18, 2026

Copy link
Copy Markdown
Member

I pushed the conflict resolution plus one small test change.

Why: the test now reloads the imported site before requesting its marker file. Reloading discards the runtime that performed the import. If the test requested the file first, that request could trigger a background save and hide the bug. After a fresh boot, the file can appear only if the import was already saved to OPFS.

The later site-switch and reload checks are unchanged.

@brandonpayton

Copy link
Copy Markdown
Member

I removed the checks that searched for the exact text “Save failed” and “Site failed.” Those checks could pass even when something was broken if the UI wording changed, because the old text would simply no longer be found.

The test already checks the behavior we actually care about: the imported marker file must load after a fresh boot, after switching away and back, and after another reload. Those checks fail when the import is not persisted and do not depend on UI copy.

@brandonpayton
brandonpayton merged commit 2ef1024 into trunk Jul 18, 2026
53 checks passed
@brandonpayton
brandonpayton deleted the codex/import-opfs-follow-up branch July 18, 2026 13:18
@ashfame

ashfame commented Jul 18, 2026

Copy link
Copy Markdown
Member Author

Thank you @brandonpayton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment