From b7b732916f4732f24d6c3929b50bcc82a5a62c2b Mon Sep 17 00:00:00 2001 From: Jeongkyu Shin Date: Tue, 8 Sep 2026 23:41:41 +0900 Subject: [PATCH] test: cover the two Select cases only a consumer had Closing #16 turned up a correction: the proposal said neither product had a `Select` test, which was true of backend.ai-go and wrong about continuum-hub, whose five tests predate this admission. The package's fifteen covered four of them. These are the other two. Arrow keys skip a disabled option, not just a click, and a select without `searchable` renders no search field and every option. Both were only guarded in a consumer, which is the wrong place for a property of this component. Verified against the perturbations: letting the keyboard land on disabled options fails three tests, rendering the search field unconditionally fails one. --- src/components/Select/Select.test.tsx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/components/Select/Select.test.tsx b/src/components/Select/Select.test.tsx index 9f6d819..ef63bd7 100644 --- a/src/components/Select/Select.test.tsx +++ b/src/components/Select/Select.test.tsx @@ -90,6 +90,20 @@ describe("Select", () => { expect(screen.getByRole("option", { name: /Oregon/ })).toBeInTheDocument(); }); + it("skips a disabled option from the keyboard too", () => { + const { onChange, trigger } = renderSelect({ + value: "eu", + options: [OPTIONS[0]!, { ...OPTIONS[1]!, disabled: true }, OPTIONS[2]!], + }); + + fireEvent.keyDown(trigger, { key: "ArrowDown" }); + fireEvent.keyDown(trigger, { key: "ArrowDown" }); + fireEvent.keyDown(trigger, { key: "Enter" }); + + // Past Oregon, which is disabled, and onto Seoul. + expect(onChange).toHaveBeenCalledWith("ap"); + }); + it("stays closed and inert when disabled", async () => { const user = userEvent.setup(); const { trigger } = renderSelect({ disabled: true }); @@ -206,3 +220,15 @@ describe("as a form field", () => { expect(onBlur).toHaveBeenCalled(); }); }); + +describe("without the filter", () => { + it("renders no search field and every option", async () => { + const user = userEvent.setup(); + const { trigger } = renderSelect(); + + await user.click(trigger); + + expect(screen.queryByRole("searchbox")).not.toBeInTheDocument(); + expect(screen.getAllByRole("option")).toHaveLength(3); + }); +});