feat: implement window.Vaadin.Flow.whenReady(callback) for TestBench async waiting#23739
Closed
feat: implement window.Vaadin.Flow.whenReady(callback) for TestBench async waiting#23739
Conversation
597eb10 to
7b7980b
Compare
Collaborator
|
Is this PR still valid and should be reviewed and tested? |
|
Define ready() as the canonical Promise-based "wait until Flow is
idle" API and whenReady(callback) as a thin callback adapter for
TestBench-style usage. Both are inlined into the bootstrap HTML so
they are available on every Flow page in dev and production mode.
ready() resolves once document.readyState is complete,
window.Vaadin.Flow.devServerIsNotLoaded is falsy, at least one client
with isActive() has been registered, and all such clients report
inactive. The "at least one client" requirement avoids a false
positive before Flow has bootstrapped. ready() takes an optional
{ timeout } (default 30s) and rejects on timeout instead of polling
forever. whenReady(callback) invokes the callback either when ready()
resolves or after logging the rejection on timeout, so the callback
contract holds either way.
The dev-mode-not-ready page sets ready and whenReady to false as
not-ready sentinels for TestBench.
a538e5b to
a5a1cae
Compare
Member
Author
|
Replaced by #24240 |
|
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.



TestBench needs a way to know when a Flow application is fully
initialized and idle before interacting with it. Previously there was
no standard async mechanism — TestBench had to poll internal state
directly, which required repeated round-trips between the test and
the browser.
Add a whenReady function that polls until the document is fully loaded
and all Flow clients are idle, then invokes the callback. This gives
TestBench a reliable async signal for waitForVaadin, avoiding the
polling overhead.
The function is defined in a single resource file (whenReady.js) and
injected into both bootstrap paths via placeholder replacement. Module
files (Flow.ts, FlowBootstrap.js) do not include it since they load
after the inline scripts.
The dev-mode-not-ready page sets whenReady to false so TestBench can
distinguish "not ready yet" from "not supported" and poll until the
real page loads.