import '../../src/i18n'; import type { Meta, StoryObj } from '@storybook/react-vite'; import { expect, fn, userEvent, within } from 'storybook/test'; import { SignOutControl } from '../../src/pages/auth/SignOutControl'; const meta: Meta = { title: 'Authentication/Sign out', component: SignOutControl, parameters: { layout: 'centered' }, tags: ['autodocs'], args: { onSignOut: fn() }, }; export default meta; type Story = StoryObj; export const Ready: Story = {}; export const Pending: Story = { args: { pending: true }, play: async ({ canvasElement }) => { const button = within(canvasElement).getByRole('button', { name: 'Signing out…' }); await expect(button).toBeDisabled(); }, }; export const FailureAndRetry: Story = { args: { failed: true }, play: async ({ canvasElement, args }) => { const canvas = within(canvasElement); await expect(canvas.getByRole('alert')).toHaveTextContent("Couldn't sign out. Try again."); await userEvent.click(canvas.getByRole('button', { name: 'Retry' })); await expect(args.onSignOut).toHaveBeenCalledTimes(1); }, };