Repository navigation
Conversation
clairep94
marked this pull request as ready for review
October 31, 2026 11:21
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change to wait for preview acknowledgement before clicking Play.
No open issues 🎉
What changed in this PR
This PR addresses intermittent end-to-end test failures by waiting for the preview app to acknowledge messages before clicking Play, rather than relying on the iframe’s src attribute.
Changes:
- Adds a reusable
waitForPreviewReadyhelper that retries aREGISTERhandshake until acknowledged or timed out. - Uses the helper before Play clicks in sketch-management and signup tests.
- Removes iframe URL checks and redundant console-not-empty assertions while retaining expected-log assertions.
| File | Description |
|---|---|
e2e/specs/sketches_management.spec.ts |
Waits for preview readiness before running initial and renamed sketches. |
e2e/specs/signup.spec.ts |
Waits for preview readiness before running sketches before and after signup. |
e2e/helpers/preview.ts |
Adds the bounded readiness handshake with timer and listener cleanup. |
Review effort: Balanced
Vaivaswat2244
approved these changes
Nov 1, 2026
Vaivaswat2244
left a comment
Member
There was a problem hiding this comment.
Hi! This looks good to me.
Although, I saw something similar in editor.spec.ts
https://github.com/processing/p5.js-web-editor/blob/develop/e2e/specs/editor.spec.ts#L62 , L260, L474. which also the same races, I think maybe we should apply waitForPreviewReady there as well...
This branch was successfully deployed
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.
Issue:
Fixes #4284 P2
The e2e test
sketches_management.spec.ts› "can rename a sketch and the update persists" fails on CI now and then:The sketch's code is saved and loaded correctly, and Play is clicked, but the sketch never runs. The console stays empty for the whole timeout.
Cause: a race between clicking Play and the preview iframe loading. Play sends the sketch to the preview iframe with a one-way
postMessage. There's no acknowledgement and no retry. The preview is a separate app that only starts handling messages after it mounts. This test does a full page reload, opens the sketch, and clicks Play straight away. If Play lands before the preview is listening, the message is dropped and nothing runs.The test's existing check,
toHaveAttribute('src', /9002/), doesn't prevent this. The iframe'ssrcis set immediately, so the check passes before the preview has loaded.This is also why #4343 doesn't fix the flake. Adding
not.toBeEmpty()only waits longer. The sketch was never started, so the console never fills.Demo:
Changes:
e2e/helpers/preview.tswith awaitForPreviewReady(page)helper. It uses the same handshakeFullView.jsxalready relies on: it postsREGISTERto the preview iframe every 100ms until the preview echoesREGISTERback. The preview only echoes once its message listener is attached, so after this wait a Play click will be received. The IDE console ignores these messages, so they have no side effects.sketches_management.spec.tsandsignup.spec.ts: callwaitForPreviewReady(page)before every#play-sketchclick, and remove thesrcchecks, which didn't prove anything.NOTE:
Follow-up (separate issue): this PR only fixes the test. The race behind it is a real bug for users: on a slow connection, clicking Play right after opening a sketch can silently do nothing, because the preview iframe hasn't started listening yet. The follow-up PR will have the preview send a
READYmessage once it is listening. If the editor is in a playing state when that message arrives, it re-sends the sketch. With that change, Play works even when it's clicked before the preview loads, andwaitForPreviewReadybecomes a safeguard rather than a requirement.I have verified that this pull request:
npm run lint)npm run test)npm run typecheck)developbranch.Fixes #123