import type { Meta, StoryObj } from '@storybook/react-vite'
import { expect } from 'storybook/test'

import { Input } from './input'

const meta = {
  component: Input,
  tags: ['ai-generated'],
} satisfies Meta<typeof Input>

export default meta
type Story = StoryObj<typeof meta>

export const Default: Story = {
  args: { placeholder: 'Object name', 'aria-label': 'name' },
}

export const Disabled: Story = {
  args: { 'aria-label': 'name', disabled: true, defaultValue: 'Amphora' },
  play: async ({ canvas }) => {
    await expect(canvas.getByLabelText('name')).toBeDisabled()
  },
}

export const Typing: Story = {
  args: { 'aria-label': 'name' },
  play: async ({ canvas, userEvent }) => {
    const input = canvas.getByLabelText('name')
    await userEvent.type(input, 'Bronze fibula')
    await expect(input).toHaveValue('Bronze fibula')
  },
}
