- update client and server dependencies within their ranges, keeping all playwright packages aligned at 1.63 - fix code flagged by react-hooks 7.1: refs written during render and synchronous setState in effects - add stories for the ui components that had none, with interaction tests, and cover all DescriptionList layouts - drop the unused mdx stories pattern - run the storybook tests as part of the pre-commit checks - bump version to 1.20.1
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import React from 'react';
|
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
import { expect, userEvent, within } from 'storybook/test';
|
|
import { ToastProvider } from '../../src/ui/Toast/ToastProvider';
|
|
import { useToast } from '../../src/ui/Toast/useToast';
|
|
import { Button } from '../../src/ui/Button/Button';
|
|
|
|
function ToastButtons() {
|
|
const toast = useToast();
|
|
return (
|
|
<div style={{ display: 'flex', gap: 8 }}>
|
|
<Button onClick={() => toast.success('Scenario run started')}>Success</Button>
|
|
<Button variant="danger" onClick={() => toast.error('Environment not found')}>
|
|
Error
|
|
</Button>
|
|
<Button variant="secondary" onClick={() => toast.info('Traces are off')}>
|
|
Info
|
|
</Button>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const meta: Meta<typeof ToastProvider> = {
|
|
title: 'UI/Toast',
|
|
component: ToastProvider,
|
|
parameters: { layout: 'centered' },
|
|
tags: ['autodocs'],
|
|
args: { durationMs: 3500, children: <ToastButtons /> },
|
|
};
|
|
export default meta;
|
|
type Story = StoryObj<typeof ToastProvider>;
|
|
|
|
export const Default: Story = {};
|
|
|
|
export const ShowsToast: Story = {
|
|
play: async ({ canvasElement }) => {
|
|
const canvas = within(canvasElement);
|
|
await userEvent.click(canvas.getByRole('button', { name: 'Success' }));
|
|
await expect(await within(document.body).findByText('Scenario run started')).toBeVisible();
|
|
},
|
|
};
|