import { describe, it, expect, vi } from 'vitest' import { render, screen, fireEvent } from '@testing-library/react' import { ConfirmDialog } from './ConfirmDialog' // useTranslation is mocked globally in setup.ts (t returns the key string) describe('ConfirmDialog', () => { const onConfirmMock = vi.fn() const onOpenChangeMock = vi.fn() const defaultProps = { open: true, onOpenChange: onOpenChangeMock, title: 'Test Title', description: 'Test Description', onConfirm: onConfirmMock, } it('should render correct titles and descriptions', () => { render() expect(screen.getByText('Test Title')).toBeInTheDocument() expect(screen.getByText('Test Description')).toBeInTheDocument() expect(screen.getByText('common.confirm')).toBeInTheDocument() expect(screen.getByText('common.cancel')).toBeInTheDocument() }) it('should call onConfirm when confirm button is clicked', () => { render() const confirmBtn = screen.getByText('common.confirm') fireEvent.click(confirmBtn) expect(onConfirmMock).toHaveBeenCalledTimes(1) }) it('should show custom confirm text if provided', () => { render() expect(screen.getByText('Delete Now')).toBeInTheDocument() }) it('should show loading state and disable buttons', () => { render() const confirmBtn = screen.getByText('common.confirm').closest('button') const cancelBtn = screen.getByText('common.cancel').closest('button') expect(confirmBtn).toBeDisabled() expect(cancelBtn).toBeDisabled() }) })