import { Meta, StoryObj } from '@storybook/react-webpack5'; import { userEvent, within, expect } from 'storybook/test'; import { useState } from 'react'; import Button from '../..'; import LegacyButton from '../LegacyButton'; import { useRtlDiffI18n, withRTLDiff } from '../../../../.storybook/decorators/RtlDiffDecorator'; LegacyButton.displayName = 'Button'; const meta: Meta = { component: LegacyButton, title: 'Actions/Button/Legacy Button/Tests', tags: ['!autodocs', '!manifest', 'deprecated'], }; export default meta; type Story = StoryObj; export const Focused: Story = { play: async ({ canvasElement }: { canvasElement: HTMLElement }) => { const canvas = within(canvasElement); const button = canvas.getByRole('button'); await userEvent.tab(); await expect(button).toHaveFocus(); await expect(button).toHaveTextContent('Focused!'); }, render: function Render(args: React.ComponentProps) { const [focused, setFocused] = useState(false); return ( ); }, }; export const RTLDiff: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( <> {/* default (inline) layout */} {i18n.defaultButton} {/* block layout — full width */} {i18n.blockButton} {/* loading state — appends ProcessIndicator inside button */} {i18n.loadingButton} {/* loading + block combined */} {i18n.loadingBlockButton} ); }, ...withRTLDiff({ i18n: { defaultButton: { en: 'Default button', ar: 'زر افتراضي' }, blockButton: { en: 'Block button', ar: 'زر بعرض كامل' }, loadingButton: { en: 'Loading button', ar: 'زر قيد التحميل' }, loadingBlockButton: { en: 'Loading block button', ar: 'زر بعرض كامل قيد التحميل' }, }, }), };