import { Meta, StoryObj } from '@storybook/react-webpack5'; import { ArrowRight, ChevronRight, Freeze } from '@transferwise/icons'; import { Flag } from '@wise/art'; import { expect, userEvent, within } from 'storybook/test'; import Button from '../Button.resolver'; import { ButtonPriority } from '../Button.types'; import { withVariantConfig } from '../../../.storybook/helpers'; const meta: Meta = { component: Button, title: 'Actions/Button/Tests', tags: ['!autodocs', '!manifest'], }; export default meta; type Story = StoryObj; export const FocusTertiary: Story = { render: () => ( ), play: async ({ canvasElement }) => { await userEvent.tab(); const canvas = within(canvasElement); const buttonElement: HTMLButtonElement = canvas.getByRole('button'); await expect(buttonElement).toHaveFocus(); }, }; const buttonPriorities = ['primary', 'secondary', 'secondary-neutral', 'tertiary'] as const; const buttonSizes = ['sm', 'md', 'lg'] as const; export const AllVariants: Story = { tags: ['!autodocs'], ...withVariantConfig(['default', 'dark', 'bright-green', 'forest-green', 'rtl'], { parameters: { padding: '0', }, }), render: () => (
{buttonPriorities.map((priority) => buttonSizes.map((size) => (
)), )} {['primary', 'secondary'].map((priority) => buttonSizes.map((size) => (
)), )}
), }; export const Disabled: Story = { args: { v2: true, disabled: true, children: 'Disabled button', }, }; export const Loading: Story = { args: { v2: true, loading: true, children: 'Loading button', }, }; export const AccessibilityAddons: Story = { args: { v2: true, addonStart: { type: 'avatar', value: [{ asset: }, { asset: }], }, 'aria-label': 'Convert Real to Yen', children: 'Convert', size: 'md', }, };