Expose builder chip selection beyond color, raise unselected contrast, and make the five-value limit visible.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
adilallo
2026-09-10 09:04:06 -06:00
co-authored by Cursor
parent 95e1937419
commit 64a2ef5a00
16 changed files with 266 additions and 51 deletions
+38
View File
@@ -123,6 +123,44 @@ describe("MultiSelect behaviour specifics", () => {
expect(helpIcon).toBeInTheDocument();
});
it("does not show a help icon by default", () => {
render(<MultiSelect options={defaultChipOptions} label="Test Label" />);
expect(screen.queryByAltText("Help")).not.toBeInTheDocument();
});
it("disables leftover chips and add when maxSelections is reached", async () => {
const handleChipClick = vi.fn();
const handleAddClick = vi.fn();
const options = [
{ id: "1", label: "One", state: "selected" as const },
{ id: "2", label: "Two", state: "selected" as const },
{ id: "3", label: "Three", state: "unselected" as const },
];
render(
<MultiSelect
options={options}
onChipClick={handleChipClick}
onAddClick={handleAddClick}
addButton
addButtonText="Add option"
maxSelections={2}
selectionCountText="2 of 2"
limitReachedAnnouncement="Limit reached"
/>,
);
expect(screen.getByText("2 of 2")).toBeInTheDocument();
expect(screen.getByText("Limit reached")).toBeInTheDocument();
expect(screen.getByRole("button", { name: "One" })).toBeEnabled();
expect(screen.getByRole("button", { name: "Three" })).toBeDisabled();
expect(screen.getByRole("button", { name: "Add option" })).toBeDisabled();
await userEvent.click(screen.getByRole("button", { name: "Three" }));
await userEvent.click(screen.getByRole("button", { name: "Add option" }));
expect(handleChipClick).not.toHaveBeenCalled();
expect(handleAddClick).not.toHaveBeenCalled();
});
it("renders add button text when provided", () => {
render(
<MultiSelect