feat(web): set up Storybook (preview + MSW + stories for real components)
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite'
|
||||
import { expect } from 'storybook/test'
|
||||
|
||||
import { Checkbox } from './checkbox'
|
||||
|
||||
const meta = {
|
||||
component: Checkbox,
|
||||
args: { 'aria-label': 'required' },
|
||||
tags: ['ai-generated'],
|
||||
} satisfies Meta<typeof Checkbox>
|
||||
|
||||
export default meta
|
||||
type Story = StoryObj<typeof meta>
|
||||
|
||||
export const Unchecked: Story = {
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole('checkbox')).toHaveAttribute('aria-checked', 'false')
|
||||
},
|
||||
}
|
||||
|
||||
export const Checked: Story = {
|
||||
args: { defaultChecked: true },
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole('checkbox')).toHaveAttribute('aria-checked', 'true')
|
||||
},
|
||||
}
|
||||
|
||||
export const Toggle: Story = {
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const checkbox = canvas.getByRole('checkbox')
|
||||
await expect(checkbox).toHaveAttribute('aria-checked', 'false')
|
||||
await userEvent.click(checkbox)
|
||||
await expect(checkbox).toHaveAttribute('aria-checked', 'true')
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user