Skip to content

Commit 309800d

Browse files
committed
fix: wait for debounced focus effect to settle in ChatView test
The 'does not grab focus when follow-up question presented' test was flaky on Windows due to timing issues with the 50ms debounced focus effect. On Windows, the test could clear mockFocus before the initial debounced effect fired, causing the effect to fire with stale state after the clear. Added explicit wait (100ms) after initial render to ensure the debounced focus effect has completed before clearing mocks.
1 parent 77a0232 commit 309800d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

webview-ui/src/components/chat/__tests__/ChatView.spec.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,11 @@ describe("ChatView - Focus Grabbing Tests", () => {
490490
expect(getByTestId("chat-textarea")).toBeInTheDocument()
491491
})
492492

493+
// Wait for the debounced focus effect to fire (50ms debounce + buffer for CI variability)
494+
await act(async () => {
495+
await new Promise((resolve) => setTimeout(resolve, 100))
496+
})
497+
493498
// Clear any initial calls after state has settled
494499
mockFocus.mockClear()
495500

0 commit comments

Comments
 (0)