From 8b881f369b35e4a1a620801b77b5382d9f8c7fb8 Mon Sep 17 00:00:00 2001 From: Anders Olsson Date: Tue, 9 Jun 2026 12:32:06 +0200 Subject: [PATCH] test(web): add a Storybook story for the combobox primitive (#67) --- web/src/components/ui/combobox.stories.tsx | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 web/src/components/ui/combobox.stories.tsx diff --git a/web/src/components/ui/combobox.stories.tsx b/web/src/components/ui/combobox.stories.tsx new file mode 100644 index 0000000..b90a6c4 --- /dev/null +++ b/web/src/components/ui/combobox.stories.tsx @@ -0,0 +1,63 @@ +import type { Meta, StoryObj } from '@storybook/react-vite' +import { useState } from 'react' +import { expect } from 'storybook/test' + +import { + ComboboxRoot, + ComboboxInputGroup, + ComboboxInput, + ComboboxClear, + ComboboxTrigger, + ComboboxPopup, + ComboboxList, + ComboboxItem, + ComboboxItemIndicator, + ComboboxEmpty, +} from './combobox' + +const fruits = ['Apple', 'Apricot', 'Banana', 'Cherry'] + +function ComboboxDemo() { + const [value, setValue] = useState(null) + + return ( + + items={fruits} + value={value} + onValueChange={setValue} + itemToStringLabel={(item) => item ?? ''} + isItemEqualToValue={(a, b) => a === b} + > + + + + + + + No matches + + {(item: string) => ( + + + {item} + + )} + + + + ) +} + +const meta = { + component: ComboboxDemo, + tags: ['ai-generated'], +} satisfies Meta + +export default meta +type Story = StoryObj + +export const Default: Story = { + play: async ({ canvas }) => { + await expect(canvas.getByPlaceholderText('Pick a fruit')).toBeInTheDocument() + }, +}