Skip to content

Commit 742c60e

Browse files
bjohansebasclaude
andcommitted
test(e2e): poll app text on an interval so hidden pages resolve
waitForFunction's default requestAnimationFrame polling never fires on a hidden document, so the backgrounded first tab of the broadcast test hung on a wait for text it had already rendered. Also settle the connections before editing so both pages receive the broadcast rather than a catch-up sync. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 1f591f5 commit 742c60e

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

test/e2e/client.test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ function waitForAppText(page, text) {
3838
return page
3939
.waitForFunction(
4040
(expected) => document.getElementById("app")?.textContent === expected,
41-
{ timeout: 30000 },
41+
// Interval polling: the default requestAnimationFrame polling freezes
42+
// on hidden pages (e.g. the backgrounded tab in the two-page test).
43+
{ timeout: 30000, polling: 100 },
4244
text,
4345
)
4446
.then(() => {});
@@ -106,13 +108,19 @@ describe("hot client (browser)", () => {
106108
app = await createHotApp({ code: acceptedApp("v1") });
107109
({ page, browser } = await runBrowser());
108110
const pageTwo = await runPage(browser);
111+
const consoleOne = collectConsole(page);
112+
const consoleTwo = collectConsole(pageTwo);
109113

110114
await page.goto(app.url);
111115
await pageTwo.goto(app.url);
112116
await waitForAppText(page, "v1");
113117
await waitForAppText(pageTwo, "v1");
118+
// Both pages must be attached before the build, so what they receive is
119+
// the broadcast — not their own catch-up sync.
120+
await consoleOne.waitFor("connected");
121+
await consoleTwo.waitFor("connected");
114122

115-
// One edit, one publish ed build — every connected page applies it.
123+
// One edit, one published build — every connected page applies it.
116124
app.edit(acceptedApp("v2"));
117125
await waitForAppText(page, "v2");
118126
await waitForAppText(pageTwo, "v2");

0 commit comments

Comments
 (0)