Skip to content

Commit 3a4ae4c

Browse files
committed
Fix: improve listbox retrieval in CreatableOption test
Updated the CreatableOption test to wait for the dropdown to open before attempting to find the listbox role. This change replaces the previous timing delay with a timeout parameter, enhancing test reliability and reducing flakiness.
1 parent e60441c commit 3a4ae4c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

apps/docs/src/remix-hook-form/select.stories.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,9 @@ export const CreatableOption: Story = {
511511
// Wait for the component to render before interacting
512512
const regionSelect = await canvas.findByLabelText('Custom Region');
513513
await userEvent.click(regionSelect);
514-
515-
// Wait for the dropdown to appear in the portal
516-
const listbox = await within(document.body).findByRole('listbox');
517-
514+
515+
// Wait for the dropdown to open and find the listbox
516+
const listbox = await within(document.body).findByRole('listbox', {}, { timeout: 5000 });
518517
// The search input is outside the listbox container; query from the portal root
519518
const input = await within(document.body).findByPlaceholderText('Search...');
520519
await userEvent.click(input);
@@ -536,10 +535,9 @@ export const CreatableOption: Story = {
536535
// Wait for the component to render before interacting
537536
const regionSelect = await canvas.findByLabelText('Custom Region');
538537
await userEvent.click(regionSelect);
539-
540-
// Wait for the dropdown to appear in the portal
541-
const listbox = await within(document.body).findByRole('listbox');
542-
538+
539+
// Wait for the dropdown to open and find the listbox
540+
const listbox = await within(document.body).findByRole('listbox', {}, { timeout: 5000 });
543541
// The search input is outside the listbox container; query from the portal root
544542
const input = await within(document.body).findByPlaceholderText('Search...');
545543
await userEvent.click(input);

0 commit comments

Comments
 (0)