import Button from "../../app/components/buttons/Button"; import { within, userEvent } from "storybook/test"; export default { title: "Components/Buttons/Button/Visual Regression", component: Button, parameters: { // Chromatic configuration for visual testing chromatic: { viewports: [320, 640, 1024, 1280], delay: 200, modes: { light: {}, dark: { colorScheme: "dark", }, }, }, }, argTypes: { size: { control: { type: "select" }, options: ["xsmall", "small", "medium", "large", "xlarge"], }, buttonType: { control: { type: "select" }, options: ["filled", "outline", "ghost", "danger"], }, palette: { control: { type: "select" }, options: ["default", "inverse"], }, disabled: { control: { type: "boolean" }, }, }, }; // Default button states export const Default = { args: { children: "Default Button", }, parameters: { docs: { description: { story: "Default button state for visual regression testing.", }, }, }, }; export const Hover = { args: { children: "Hover Button", }, parameters: { docs: { description: { story: "Button in hover state for visual regression testing.", }, }, }, play: async ({ canvasElement }) => { const canvas = within(canvasElement); const button = canvas.getByRole("button"); await userEvent.hover(button); await new Promise((resolve) => setTimeout(resolve, 100)); }, }; export const Focus = { args: { children: "Focus Button", }, parameters: { docs: { description: { story: "Button in focus state for visual regression testing.", }, }, }, play: async ({ canvasElement }) => { const canvas = within(canvasElement); const button = canvas.getByRole("button"); button.focus(); await new Promise((resolve) => setTimeout(resolve, 100)); }, }; export const Active = { args: { children: "Active Button", }, parameters: { docs: { description: { story: "Button in active/pressed state for visual regression testing.", }, }, }, play: async ({ canvasElement }) => { const canvas = within(canvasElement); const button = canvas.getByRole("button"); await userEvent.click(button); await new Promise((resolve) => setTimeout(resolve, 100)); }, }; export const Disabled = { args: { children: "Disabled Button", disabled: true, }, parameters: { docs: { description: { story: "Disabled button state for visual regression testing.", }, }, }, }; // Size variants export const XSmall = { args: { children: "XSmall Button", size: "xsmall", }, parameters: { docs: { description: { story: "Extra small button size for visual regression testing.", }, }, }, }; export const Small = { args: { children: "Small Button", size: "small", }, parameters: { docs: { description: { story: "Small button size for visual regression testing.", }, }, }, }; export const Medium = { args: { children: "Medium Button", size: "medium", }, parameters: { docs: { description: { story: "Medium button size for visual regression testing.", }, }, }, }; export const Large = { args: { children: "Large Button", size: "large", }, parameters: { docs: { description: { story: "Large button size for visual regression testing.", }, }, }, }; export const XLarge = { args: { children: "XLarge Button", size: "xlarge", }, parameters: { docs: { description: { story: "Extra large button size for visual regression testing.", }, }, }, }; // Variant styles export const HomeVariant = { args: { children: "Home Button", buttonType: "filled", palette: "default", }, parameters: { docs: { description: { story: "Home variant button for visual regression testing.", }, }, }, }; // Button with icon/content export const WithIcon = { args: { children: ( <> Button with Icon > ), }, parameters: { docs: { description: { story: "Button with icon for visual regression testing.", }, }, }, }; export const LongText = { args: { children: "This is a button with very long text content that might wrap or overflow", }, parameters: { docs: { description: { story: "Button with long text for visual regression testing.", }, }, }, }; // Button grid for comparison export const SizeComparison = { render: () => (