mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: make ChatView focus grabbing test more robust
Add delays to wait for debounced focus effects to complete before asserting. The useDebounceEffect has a 50ms delay, and the test was flaky because state changes could trigger the debounced effect after mockFocus.mockClear() was called.
This commit is contained in:
parent
8eb5abf7f8
commit
06eb310c34
1 changed files with 10 additions and 4 deletions
|
|
@ -468,7 +468,12 @@ describe("ChatView - Focus Grabbing Tests", () => {
|
|||
expect(getByTestId("chat-textarea")).toBeInTheDocument()
|
||||
})
|
||||
|
||||
// Clear any initial calls after state has settled
|
||||
// Wait for any debounced focus effects to complete (useDebounceEffect has 50ms delay)
|
||||
await act(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 100))
|
||||
})
|
||||
|
||||
// Clear any initial calls after state has settled and debounce completed
|
||||
mockFocus.mockClear()
|
||||
|
||||
// Add follow-up question
|
||||
|
|
@ -489,12 +494,13 @@ describe("ChatView - Focus Grabbing Tests", () => {
|
|||
],
|
||||
})
|
||||
|
||||
// Wait for state update to complete
|
||||
await waitFor(() => {
|
||||
expect(getByTestId("chat-textarea")).toBeInTheDocument()
|
||||
// Wait for state update to complete and any debounced effects
|
||||
await act(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 100))
|
||||
})
|
||||
|
||||
// Should not grab focus for follow-up questions
|
||||
// The followup case sets enableButtons to true, which prevents focus grabbing
|
||||
expect(mockFocus).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue