Skip to content

Commit 9768060

Browse files
committed
fix the flaky test
1 parent ee56a1c commit 9768060

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/components/Folder/Folder.test.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { describe, expect, it, test, vi } from 'vitest'
55
import { Config, ConfigProvider } from '../../hooks/useConfig.js'
66
import { DirSource, FileMetadata, HyperparamFileMetadata, getHyperparamSource } from '../../lib/sources/index.js'
77
import Folder from './Folder.js'
8+
import { userEvent } from '@testing-library/user-event'
89

910
const endpoint = 'http://localhost:3000'
1011
const mockFiles: HyperparamFileMetadata[] = [
@@ -140,16 +141,11 @@ describe('Folder Component', () => {
140141

141142
// Type a search query and hit enter
142143
const searchInput = getByPlaceholderText('Search...') as HTMLInputElement
143-
act(() => {
144-
fireEvent.keyUp(searchInput, { target: { value: 'file1' } })
145-
})
146-
144+
const user = userEvent.setup()
145+
await user.type(searchInput, 'file1')
147146
await findByText('file1.txt')
148147

149-
act(() => {
150-
fireEvent.keyUp(searchInput, { key: 'Enter' })
151-
})
152-
148+
await user.type(searchInput, '{Enter}')
153149
expect(location.href).toBe('/files?key=file1.txt')
154150
})
155151

0 commit comments

Comments
 (0)