test(desktop): poll for 'listening' after re-arm in voice rearm tests

status flips to 'listening' only after handle.start() resolves, so the
synchronous assertion right after waitFor(start x2) raced (2/9 flakes on
'speaks completed fallback sentences before the response finishes').
Wrap it in waitFor; same assertion, no longer timing-dependent.
This commit is contained in:
kshitijk4poor
2026-09-24 19:56:33 +05:30
committed by kshitij
parent feb503d68f
commit dbc4780a08

View File

@@ -235,7 +235,8 @@ describe('useVoiceConversation playback rearm', () => {
})
await waitFor(() => expect(mocks.handle.start).toHaveBeenCalledTimes(2))
expect(hook.result.current.status).toBe('listening')
// status flips to 'listening' only after start() resolves — poll for it.
await waitFor(() => expect(hook.result.current.status).toBe('listening'))
})
it('honors Stop while streaming playback is still preparing', async () => {
@@ -301,7 +302,8 @@ describe('useVoiceConversation playback rearm', () => {
})
)
await waitFor(() => expect(mocks.handle.start).toHaveBeenCalledTimes(2))
expect(hook.result.current.status).toBe('listening')
// status flips to 'listening' only after start() resolves — poll for it.
await waitFor(() => expect(hook.result.current.status).toBe('listening'))
})
it('speaks completed fallback sentences before the response finishes', async () => {
@@ -327,7 +329,8 @@ describe('useVoiceConversation playback rearm', () => {
})
)
await waitFor(() => expect(mocks.handle.start).toHaveBeenCalledTimes(2))
expect(hook.result.current.status).toBe('listening')
// status flips to 'listening' only after start() resolves — poll for it.
await waitFor(() => expect(hook.result.current.status).toBe('listening'))
})
it('does not play the next fallback sentence or re-arm after Stop', async () => {