import type { Meta, StoryObj } from '@storybook/react'; import { expect, userEvent, within } from 'storybook/test'; import { Tabs, TabsList, TabsTrigger, TabsContent } from './tabs'; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '../card'; import { Button } from '../button'; import { Input } from '../input'; import { Label } from '../label'; import React from 'react'; const meta: Meta = { title: 'UI/Tabs', component: Tabs, render: args => , argTypes: { defaultValue: { control: 'text', description: 'The value of the tab that should be active by default.', }, className: { control: 'text', description: 'Additional CSS classes for the tabs container.', }, }, }; export default meta; type Story = StoryObj; export const Default: Story = { args: { defaultValue: 'account', className: 'w-[400px]', }, render: args => ( Account Password Account Make changes to your account here. Click save when you're done.
Password Change your password here. After saving, you'll be logged out.
), }; export const Analytics: Story = { render: () => ( Overview Analytics Reports Notifications Overview content goes here. Reports table content goes here. Notifications configuration goes here. ), }; export const SwitchTab: Story = { args: { defaultValue: 'account', className: 'w-[400px]' }, render: args => ( Account Password

Account content

Password content

), play: async ({ canvasElement }) => { const canvas = within(canvasElement); const accountTab = canvas.getByRole('tab', { name: 'Account' }); const passwordTab = canvas.getByRole('tab', { name: 'Password' }); await expect(accountTab).toHaveAttribute('aria-selected', 'true'); await expect(passwordTab).toHaveAttribute('aria-selected', 'false'); await userEvent.click(passwordTab); await expect(passwordTab).toHaveAttribute('aria-selected', 'true'); await expect(accountTab).toHaveAttribute('aria-selected', 'false'); }, };