Skip to content

feat: implement window.Vaadin.Flow.whenReady(callback) for TestBench async waiting#23739

Draft
Artur- wants to merge 2 commits intomainfrom
wait-for-vaadin-in-flow
Draft

feat: implement window.Vaadin.Flow.whenReady(callback) for TestBench async waiting#23739
Artur- wants to merge 2 commits intomainfrom
wait-for-vaadin-in-flow

Conversation

@Artur-
Copy link
Copy Markdown
Member

@Artur- Artur- commented Mar 3, 2026

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.

@github-actions github-actions bot added the +0.0.1 label Mar 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 3, 2026

Test Results

 1 387 files  ±0   1 387 suites  ±0   1h 24m 11s ⏱️ + 1m 12s
 9 932 tests ±0   9 861 ✅ ±0  71 💤 ±0  0 ❌ ±0 
10 405 runs  ±0  10 325 ✅ ±0  80 💤 ±0  0 ❌ ±0 

Results for commit 7b7980b. ± Comparison against base commit 18f0648.

♻️ This comment has been updated with latest results.

Artur- and others added 2 commits March 30, 2026 16:21
…async waiting

Add a whenReady function that polls until the document is fully loaded,
the dev server is available, and all Flow clients are idle, then invokes
the callback. This gives TestBench a reliable async signal for
waitForVaadin.

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.
@mcollovati mcollovati force-pushed the wait-for-vaadin-in-flow branch from 597eb10 to 7b7980b Compare March 30, 2026 14:22
@mcollovati
Copy link
Copy Markdown
Collaborator

Is this PR still valid and should be reviewed and tested?

@sonarqubecloud
Copy link
Copy Markdown

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants