import { describe, it, expect } from 'vitest' import { render, screen } from '@testing-library/react' import { Button } from '@/components/ui/button' import { Tag } from '@/components/ui/tag' import { StatusTag, PriorityTag, statusTone } from '@/components/ui/status-tag' import { Field, Input } from '@/components/ui/field' import { Card } from '@/components/ui/card' import { TABLE, TH, TR, TD } from '@/components/ui/table-styles' describe('Button', () => { it('renders a primary accent button that is type=button and flush left', () => { render() const btn = screen.getByRole('button', { name: 'Save' }) expect(btn.getAttribute('type')).toBe('button') expect(btn.className).toContain('bg-accent') expect(btn.className).toContain('justify-start') expect(btn.className).not.toContain('justify-center') }) it('block buttons span the row and stay flush left', () => { render() const btn = screen.getByRole('button', { name: 'Go' }) expect(btn.className).toContain('w-full') expect(btn.className).toContain('justify-start') }) it('icon buttons are square and centered', () => { render() expect(screen.getByRole('button').className).not.toMatch(/rounded/) }) }) describe('Tag', () => { it.each([ ['accent', 'bg-accent-100'], ['neutral', 'bg-neutral-100'], ['outline', 'border-accent'], ] as const)('%s variant carries %s', (variant, cls) => { render(Label) expect(screen.getByText('Label').className).toContain(cls) }) }) describe('statusTone', () => { it.each([ ['reported', 'accent'], ['triaged', 'outline'], ['investigating', 'outline'], ['capa_pending', 'outline'], ['verification', 'outline'], ['closed', 'neutral'], ['open', 'accent'], ['in_progress', 'outline'], ['overdue', 'accent'], ['pending_verification', 'outline'], ['verified', 'neutral'], ['reopened', 'accent'], ['something_else', 'neutral'], ])('%s maps to %s', (status, tone) => { expect(statusTone(status)).toBe(tone) }) }) describe('StatusTag', () => { it('shows a humanized text label plus an icon, never color alone', () => { const { container } = render() expect(screen.getByText('CAPA Pending')).toBeTruthy() expect(container.querySelector('svg')).not.toBeNull() }) it('accepts a label override', () => { render(Late) expect(screen.getByText('Late')).toBeTruthy() }) }) describe('PriorityTag', () => { it.each([ ['high', 'bg-accent-100'], ['med', 'border-accent'], ['low', 'bg-neutral-100'], ])('%s priority uses %s', (priority, cls) => { const { container } = render() expect(container.firstElementChild?.className).toContain(cls) }) }) describe('Field and Input', () => { it('associates the label with the input', () => { render( , ) const input = screen.getByLabelText('Email') expect(input.className).toContain('bg-surface') expect(input.className).toContain('border-divider') }) }) describe('Card', () => { it('renders kicker, title, body and meta on the surface fill', () => { const { container } = render( Body text , ) expect(screen.getByText('Open')).toBeTruthy() expect(screen.getByText('Forklift')).toBeTruthy() expect(screen.getByText('Body text')).toBeTruthy() expect(screen.getByText('Due Friday')).toBeTruthy() expect(container.firstElementChild?.className).toContain('bg-surface') }) }) describe('table styles', () => { it('uses a 2px header rule and 1px row rules', () => { expect(TH).toContain('border-b-2') expect(TH).toContain('border-divider') expect(TD).toContain('border-b') expect(TR).toContain('hover:bg-ink/4') expect(TABLE).toContain('w-full') }) })