// @vitest-environment jsdom import '@testing-library/jest-dom' import { describe, it, expect, vi, beforeEach } from 'vitest' import { render, screen, fireEvent } from '@testing-library/react' vi.mock('@/components/ui/dialog', () => ({ Dialog: ({ open, children }: { open: boolean; onOpenChange?: (v: boolean) => void; children: React.ReactNode }) => open ?
{children}
: null, DialogContent: ({ children }: { children: React.ReactNode }) =>
{children}
, DialogHeader: ({ children }: { children: React.ReactNode }) =>
{children}
, DialogTitle: ({ children }: { children: React.ReactNode }) =>

{children}

, })) vi.mock('@/components/ui/button', () => ({ Button: ({ children, onClick, disabled, variant, }: { children?: React.ReactNode onClick?: () => void disabled?: boolean variant?: string }) => ( ), })) vi.mock('@/components/ui/tooltip', () => ({ TooltipProvider: ({ children }: { children: React.ReactNode }) => <>{children}, Tooltip: ({ children }: { children: React.ReactNode }) => <>{children}, TooltipTrigger: ({ render: r, children }: { render?: React.ReactElement; children?: React.ReactNode }) => r ? <>{r} : <>{children}, TooltipContent: ({ children }: { children: React.ReactNode }) => ( {children} ), })) import { BatchEnqueueBlockerDialog } from '@/components/solo/batch-enqueue-blocker-dialog' const DEFAULT_PROPS = { open: true, onOpenChange: vi.fn(), prefixCount: 3, blockerReason: 'task-review' as const, blockerLabel: 'Story X — Task Y (in review)', onConfirm: vi.fn(), onCancel: vi.fn(), } beforeEach(() => { vi.clearAllMocks() }) describe('BatchEnqueueBlockerDialog', () => { it('renders title and blocker info for task-review', () => { render() expect(screen.getByRole('heading')).toHaveTextContent('Blokkade gedetecteerd') expect(screen.getByText(/Een taak staat op 'review'/)).toBeInTheDocument() expect(screen.getByText(/Story X — Task Y/)).toBeInTheDocument() }) it('renders correct blocker label for pbi-blocked', () => { render( ) expect(screen.getByText(/De PBI is geblokkeerd/)).toBeInTheDocument() expect(screen.getByText(/PBI Z/)).toBeInTheDocument() }) it('calls onConfirm when primary button is clicked', () => { render() fireEvent.click(screen.getByText(/Stuur 3 taken tot aan blokkade/)) expect(DEFAULT_PROPS.onConfirm).toHaveBeenCalledTimes(1) }) it('calls onCancel when cancel button is clicked', () => { render() fireEvent.click(screen.getByText('Annuleer')) expect(DEFAULT_PROPS.onCancel).toHaveBeenCalledTimes(1) }) it('disables confirm button and shows tooltip when prefixCount is 0', () => { render() const confirmBtn = screen.getByText(/Stuur 0/).closest('button') expect(confirmBtn).toBeDisabled() expect(screen.getByTestId('tooltip-content')).toHaveTextContent('Geen taken vóór blokkade') }) it('does not render when open is false', () => { render() expect(screen.queryByTestId('dialog')).not.toBeInTheDocument() }) it('uses singular taak when prefixCount is 1', () => { render() expect(screen.getByText(/Stuur 1 taak tot aan blokkade/)).toBeInTheDocument() expect(screen.getByText(/1 taak vóór de blokkade/)).toBeInTheDocument() }) })