Files
syndarix/frontend/tests/components/dashboard/EmptyState.test.tsx
Felipe Cardoso c7b2c82700 test(frontend): add unit tests for Dashboard components
Add comprehensive test coverage for dashboard components:
- Dashboard.test.tsx: Main component integration tests
- WelcomeHeader.test.tsx: User greeting and time-based messages
- DashboardQuickStats.test.tsx: Stats cards rendering and links
- RecentProjects.test.tsx: Project cards grid and navigation
- PendingApprovals.test.tsx: Approval items and actions
- EmptyState.test.tsx: New user onboarding experience

46 tests covering rendering, interactions, and edge cases.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 17:20:34 +01:00

58 lines
1.8 KiB
TypeScript

/**
* EmptyState Component Tests
*/
import { render, screen } from '@testing-library/react';
import { EmptyState } from '@/components/dashboard/EmptyState';
// Mock next-intl navigation
jest.mock('@/lib/i18n/routing', () => ({
Link: ({ children, href }: { children: React.ReactNode; href: string }) => (
<a href={href}>{children}</a>
),
}));
describe('EmptyState', () => {
it('displays welcome message with user name', () => {
render(<EmptyState userName="John" />);
expect(screen.getByText(/Welcome to Syndarix, John!/)).toBeInTheDocument();
});
it('displays default greeting when no userName provided', () => {
render(<EmptyState />);
expect(screen.getByText(/Welcome to Syndarix, there!/)).toBeInTheDocument();
});
it('displays description text', () => {
render(<EmptyState />);
expect(screen.getByText(/Get started by creating your first project/)).toBeInTheDocument();
});
it('displays Create Your First Project button', () => {
render(<EmptyState />);
const createButton = screen.getByRole('link', { name: /Create Your First Project/i });
expect(createButton).toBeInTheDocument();
expect(createButton).toHaveAttribute('href', '/projects/new');
});
it('displays quick action links', () => {
render(<EmptyState />);
const agentsLink = screen.getByRole('link', { name: /Set up AI agent types/i });
expect(agentsLink).toHaveAttribute('href', '/agents');
const settingsLink = screen.getByRole('link', { name: /Configure your account/i });
expect(settingsLink).toHaveAttribute('href', '/settings');
});
it('applies custom className', () => {
const { container } = render(<EmptyState className="custom-class" />);
expect(container.firstChild).toHaveClass('custom-class');
});
});