From 667c4de2010fea6fa8dfa3d02d2a5a8caeb382be Mon Sep 17 00:00:00 2001 From: Luke Bennett Date: Mon, 10 Aug 2026 20:08:07 +1000 Subject: [PATCH] test: stabilize ComboboxField integration test by waiting for popover enter before clicking an option (#389) --- .../combobox-field/combobox-field.browser.test.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/@luke-ui/react/src/combobox-field/combobox-field.browser.test.tsx b/packages/@luke-ui/react/src/combobox-field/combobox-field.browser.test.tsx index 1dc87366..ac08c34e 100644 --- a/packages/@luke-ui/react/src/combobox-field/combobox-field.browser.test.tsx +++ b/packages/@luke-ui/react/src/combobox-field/combobox-field.browser.test.tsx @@ -74,7 +74,18 @@ testIntegration(componentTestRegistration, 'ComboboxField', async () => { const input = locator.getByRole('combobox', { name: 'Country' }); await user.click(input); - await user.click(page.getByRole('option', { name: 'Australia' })); + + const option = page.getByRole('option', { name: 'Australia' }); + // oxlint-disable-next-line vitest/no-standalone-expect + await expect.element(option).toBeInTheDocument(); + // Clicking an option scrolls it into view first, and React Aria closes the popover on a + // document scroll. While the popover is still entering, that close lands before the click and + // detaches the option. + const popover = page.getByRole('listbox').element().parentElement; + if (popover == null) throw new Error('Expected the popover element.'); + await waitForOverlayEnter(popover); + + await user.click(option); // oxlint-disable-next-line vitest/no-standalone-expect expect(page.getByRole('combobox', { name: 'Country' })).toHaveValue('Australia'); }); -- 2.51.2