Skip to content

Commit b3284d6

Browse files
authored
Merge pull request #3298 from github/koesie10/try-fix-flaky-suggestbox-tab
Wait for options to be shown and to be removed when pressing Tab
2 parents e9e9840 + 820989a commit b3284d6

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

extensions/ql-vscode/src/view/common/SuggestBox/__tests__/SuggestBox.test.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { render as reactRender, screen } from "@testing-library/react";
1+
import { render as reactRender, screen, waitFor } from "@testing-library/react";
22
import type { SuggestBoxProps } from "../SuggestBox";
33
import { SuggestBox } from "../SuggestBox";
44
import { userEvent } from "@testing-library/user-event";
@@ -200,6 +200,9 @@ describe("SuggestBox", () => {
200200
});
201201

202202
await userEvent.click(screen.getByRole("combobox"));
203+
204+
expect(screen.getAllByRole("option")).not.toHaveLength(0);
205+
203206
await userEvent.keyboard("{Enter}");
204207

205208
expect(screen.queryByRole("option")).not.toBeInTheDocument();
@@ -211,9 +214,14 @@ describe("SuggestBox", () => {
211214
});
212215

213216
await userEvent.click(screen.getByRole("combobox"));
217+
218+
expect(screen.getAllByRole("option")).not.toHaveLength(0);
219+
214220
await userEvent.keyboard("{Tab}");
215221

216-
expect(screen.queryByRole("option")).not.toBeInTheDocument();
222+
await waitFor(() => {
223+
expect(screen.queryByRole("option")).not.toBeInTheDocument();
224+
});
217225
});
218226

219227
it("shows no suggestions with no matching followup options", async () => {

0 commit comments

Comments
 (0)