import type { Meta, StoryObj } from '@storybook/react'; import { expect, userEvent, within } from 'storybook/test'; import { Button } from './button'; import { Plus, Trash2, Settings, ArrowRight } from 'lucide-react'; import React from 'react'; const meta: Meta = { title: 'UI/Button', component: Button, render: args => ), }; export const IconOnly: Story = { args: { size: 'icon', variant: 'outline', 'aria-label': 'Settings', }, render: args => ( ), }; export const DestructiveWithIcon: Story = { render: args => ( ), }; export const Success: Story = { render: args => ( ), }; export const Info: Story = { render: args => ( ), }; export const Warning: Story = { render: args => ( ), }; export const Loading: Story = { args: { disabled: true, }, render: args => ( ), }; export const Clickable: Story = { args: { children: 'Click me' }, play: async ({ canvasElement }) => { const canvas = within(canvasElement); const button = canvas.getByRole('button', { name: 'Click me' }); await expect(button).toBeInTheDocument(); await expect(button).not.toBeDisabled(); await userEvent.click(button); await expect(button).toBeInTheDocument(); }, }; export const DisabledState: Story = { args: { children: 'Disabled', disabled: true }, play: async ({ canvasElement }) => { const canvas = within(canvasElement); const button = canvas.getByRole('button', { name: 'Disabled' }); await expect(button).toBeDisabled(); await expect(button).toHaveAttribute('disabled'); }, };