Skip to content

Commit

Permalink
fix flaky test with HMR console
Browse files Browse the repository at this point in the history
  • Loading branch information
pacocoursey committed Oct 30, 2024
1 parent 5d9d6e3 commit 74087a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ test.describe('basic behavior', async () => {

test('item onSelect is called on click', async ({ page }) => {
const item = page.locator(`[cmdk-item][data-value="Item"]`)
const [message] = await Promise.all([page.waitForEvent('console'), item.click()])
expect(message.text()).toEqual('Item selected')
await item.click()
expect(await page.evaluate(() => (window as any).onSelect)).toEqual('Item selected')
})

test('first item is selected by default', async ({ page }) => {
Expand Down
8 changes: 7 additions & 1 deletion test/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ const Page = () => {
<Command.Input placeholder="Search…" className="input" />
<Command.List className="list">
<Command.Empty className="empty">No results.</Command.Empty>
<Command.Item keywords={['key']} onSelect={() => console.log('Item selected')} className="item">
<Command.Item
keywords={['key']}
onSelect={() => {
;(window as any).onSelect = 'Item selected'
}}
className="item"
>
Item
</Command.Item>
<Command.Item value="xxx" className="item">
Expand Down

0 comments on commit 74087a6

Please sign in to comment.