fix: add Promise.resolve() after advancing fake timers to flush state updates

Co-authored-by: hyoban <38493346+hyoban@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-02-04 14:40:37 +00:00
parent e4aaabb079
commit 8c10513d6d

View File

@ -720,13 +720,14 @@ describe('UpdateDSLModal', () => {
await Promise.resolve()
// Advance past the 300ms setTimeout in the component
await vi.advanceTimersByTimeAsync(350)
// Flush any pending state updates
await Promise.resolve()
})
vi.useRealTimers()
await waitFor(() => {
expect(screen.getByText('newApp.appCreateDSLErrorTitle')).toBeInTheDocument()
}, { timeout: 5000 })
// Element should be immediately available after advancing timers and flushing
expect(screen.getByText('newApp.appCreateDSLErrorTitle')).toBeInTheDocument()
})
it('should show version info in error modal', async () => {
@ -852,11 +853,13 @@ describe('UpdateDSLModal', () => {
await Promise.resolve()
// Advance past the 300ms setTimeout in the component
await vi.advanceTimersByTimeAsync(350)
// Flush any pending state updates
await Promise.resolve()
})
vi.useRealTimers()
// Element should be immediately available after advancing timers
// Element should be immediately available after advancing timers and flushing
expect(screen.getByText('newApp.appCreateDSLErrorTitle')).toBeInTheDocument()
// Click confirm button
@ -1152,11 +1155,13 @@ describe('UpdateDSLModal', () => {
await Promise.resolve()
// Advance past the 300ms setTimeout in the component
await vi.advanceTimersByTimeAsync(350)
// Flush any pending state updates
await Promise.resolve()
})
vi.useRealTimers()
// Element should be immediately available after advancing timers
// Element should be immediately available after advancing timers and flushing
expect(screen.getByText('newApp.appCreateDSLErrorTitle')).toBeInTheDocument()
const confirmButton = screen.getByText('newApp.Confirm')