Skip to content

Commit 59402a9

Browse files
committed
fix(emcn): wait for focus restoration instead of a fixed 20ms sleep in the modal test
1 parent ad61fff commit 59402a9

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

packages/emcn/src/components/modal/modal.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* @vitest-environment jsdom
33
*/
44
import { act, type ReactNode, useState } from 'react'
5-
import { sleep } from '@sim/utils/helpers'
65
import { createRoot, type Root } from 'react-dom/client'
76
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
87
import {
@@ -248,9 +247,8 @@ describe('native-surface modal preparation', () => {
248247
if (!close) throw new Error('Modal close button did not render')
249248
await act(async () => {
250249
close.click()
251-
await sleep(20)
252250
})
253-
expect(document.activeElement).toBe(trigger)
251+
await vi.waitFor(() => expect(document.activeElement).toBe(trigger))
254252
})
255253

256254
it('fails closed when a registered preparation rejects', async () => {

0 commit comments

Comments
 (0)