import type { Meta, StoryObj } from '@storybook/react-vite'; import { useState } from 'react'; import { expect, within } from 'storybook/test'; import { Button } from '../../src/ui/Button/Button'; import { UuidBadge } from '../../src/ui/UuidBadge/UuidBadge'; const meta: Meta = { title: 'UI/UuidBadge', component: UuidBadge, parameters: { layout: 'centered' }, tags: ['autodocs'], }; export default meta; type Story = StoryObj; export const Default: Story = { args: { id: '61d2b1c2-7664-4dca-974f-436c2ee90b2e' }, play: async ({ canvasElement }) => { // Shows a shortened id and keeps the full one in the tooltip const badge = within(canvasElement).getByTitle('61d2b1c2-7664-4dca-974f-436c2ee90b2e'); await expect(badge).toHaveTextContent('61d2…0b2e'); }, }; const SAMPLE_IDS = [ '61d2b1c2-7664-4dca-974f-436c2ee90b2e', 'e83f0a5d-1b9c-4f27-8d6e-2a4c9b7f1e03', '0c7a94f1-3e52-4b8d-a1f6-9d2e5c8b4a70', 'f4b21e8c-9a07-4c63-b5d2-7e1f0a3c6d98', '8d5e3a10-c4f7-4e29-9b81-5f6a2d0c7e14', '2a9fc067-58d3-4a1e-86b4-c3e7f19d5b2a', ]; function Gallery() { const [ids, setIds] = useState(SAMPLE_IDS); return (
{ids.map((id) => ( ))}
); } export const Colors: Story = { render: () => , play: async ({ canvasElement }) => { // Each sample id gets its own badge const canvas = within(canvasElement); for (const id of SAMPLE_IDS) { await expect(canvas.getByTitle(id)).toBeInTheDocument(); } }, };