Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(tests): remove racy home-route wait in collapsible-thinking snapshot spec (#1201)

John-Mason P. Shackelford9df17f302220
diff --git a/tests/e2e/snapshots/collapsible-thinking.snapshot.spec.ts b/tests/e2e/snapshots/collapsible-thinking.snapshot.spec.ts
index c9e096807c..fbe8be9e78 100644
--- a/tests/e2e/snapshots/collapsible-thinking.snapshot.spec.ts
+++ b/tests/e2e/snapshots/collapsible-thinking.snapshot.spec.ts
@@ -197,11 +197,10 @@ async function navigateToConversation(page: Page, events: unknown[]) {
});
});
- // The GUI now hides ChatSuggestions (and shows the "LLM not configured"
- // banner) unless an active profile with a key exists β€” see useLlmConfigured.
- // Seed one so the empty conversation renders normally: it restores the
- // "Let's start building!" readiness signal below and keeps the banner out of
- // the captured screenshots (matching the baselines).
+ // The GUI hides ChatSuggestions (and shows the "LLM not configured" banner)
+ // unless an active profile with a key exists β€” see useLlmConfigured. Seed
+ // one so the empty conversation renders normally and the banner stays out
+ // of the captured screenshots (matching the baselines).
await page.route(
(url) => url.pathname.endsWith("/api/profiles"),
async (route) => {
@@ -229,9 +228,34 @@ async function navigateToConversation(page: Page, events: unknown[]) {
waitUntil: "domcontentloaded",
});
await dismissConsentModal(page);
- await expect(page.getByText("Let's start building!")).toBeVisible({
- timeout: 20000,
- });
+
+ // Wait for the conversation route to mount before injecting events.
+ // ConversationWebSocketContext runs a useLayoutEffect on mount that
+ // calls clearEventsForConversation(<id>) β€” if we inject events first,
+ // that effect wipes them and the UI renders the empty state. Use the
+ // store's `loadedConversationId` as a route-stable readiness signal:
+ // it flips from null β†’ CONVERSATION_ID inside that layoutEffect, so
+ // observing it means the clear-and-set has already happened and any
+ // subsequent addEvents will survive.
+ //
+ // We deliberately don't wait on the home route's "Let's start
+ // building!" text here β€” it only renders on the home route, so relying
+ // on a brief home flash before the conversation hydrates is racy and
+ // caused the 20s timeout flake tracked in #1200.
+ await page.waitForFunction(
+ (expectedId) => {
+ const store = (
+ window as unknown as {
+ __OH_EVENT_STORE__?: {
+ getState: () => { loadedConversationId: string | null };
+ };
+ }
+ ).__OH_EVENT_STORE__;
+ return store?.getState().loadedConversationId === expectedId;
+ },
+ CONVERSATION_ID,
+ { timeout: 20000 },
+ );
await injectEvents(page, events);