Files
syndarix/frontend/tests/components/projects/AgentStatusIndicator.test.tsx
Felipe Cardoso 5b1e2852ea feat(frontend): implement main dashboard page (#48)
Implement the main dashboard / projects list page for Syndarix as the landing
page after login. The implementation includes:

Dashboard Components:
- QuickStats: Overview cards showing active projects, agents, issues, approvals
- ProjectsSection: Grid/list view with filtering and sorting controls
- ProjectCardGrid: Rich project cards for grid view
- ProjectRowList: Compact rows for list view
- ActivityFeed: Real-time activity sidebar with connection status
- PerformanceCard: Performance metrics display
- EmptyState: Call-to-action for new users
- ProjectStatusBadge: Status indicator with icons
- ComplexityIndicator: Visual complexity dots
- ProgressBar: Accessible progress bar component

Features:
- Projects grid/list view with view mode toggle
- Filter by status (all, active, paused, completed, archived)
- Sort by recent, name, progress, or issues
- Quick stats overview with counts
- Real-time activity feed sidebar with live/reconnecting status
- Performance metrics card
- Create project button linking to wizard
- Responsive layout for mobile/desktop
- Loading skeleton states
- Empty state for new users

API Integration:
- useProjects hook for fetching projects (mock data until backend ready)
- useDashboardStats hook for statistics
- TanStack Query for caching and data fetching

Testing:
- 37 unit tests covering all dashboard components
- E2E test suite for dashboard functionality
- Accessibility tests (keyboard nav, aria attributes, heading hierarchy)

Technical:
- TypeScript strict mode compliance
- ESLint passing
- WCAG AA accessibility compliance
- Mobile-first responsive design
- Dark mode support via semantic tokens
- Follows design system guidelines

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 23:46:50 +01:00

82 lines
3.2 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import { AgentStatusIndicator } from '@/components/projects/AgentStatusIndicator';
describe('AgentStatusIndicator', () => {
it('renders idle status with correct color', () => {
const { container } = render(<AgentStatusIndicator status="idle" />);
const indicator = container.querySelector('span > span');
expect(indicator).toHaveClass('bg-yellow-500');
});
it('renders active status with correct color', () => {
const { container } = render(<AgentStatusIndicator status="active" />);
const indicator = container.querySelector('span > span');
expect(indicator).toHaveClass('bg-green-500');
});
it('renders working status with animation', () => {
const { container } = render(<AgentStatusIndicator status="working" />);
const indicator = container.querySelector('span > span');
expect(indicator).toHaveClass('bg-green-500');
expect(indicator).toHaveClass('animate-pulse');
});
it('renders pending status with correct color', () => {
const { container } = render(<AgentStatusIndicator status="pending" />);
const indicator = container.querySelector('span > span');
expect(indicator).toHaveClass('bg-gray-400');
});
it('renders error status with correct color', () => {
const { container } = render(<AgentStatusIndicator status="error" />);
const indicator = container.querySelector('span > span');
expect(indicator).toHaveClass('bg-red-500');
});
it('renders terminated status with correct color', () => {
const { container } = render(<AgentStatusIndicator status="terminated" />);
const indicator = container.querySelector('span > span');
expect(indicator).toHaveClass('bg-gray-600');
});
it('applies small size by default', () => {
const { container } = render(<AgentStatusIndicator status="active" />);
const indicator = container.querySelector('span > span');
expect(indicator).toHaveClass('h-2', 'w-2');
});
it('applies medium size when specified', () => {
const { container } = render(<AgentStatusIndicator status="active" size="md" />);
const indicator = container.querySelector('span > span');
expect(indicator).toHaveClass('h-3', 'w-3');
});
it('applies large size when specified', () => {
const { container } = render(<AgentStatusIndicator status="active" size="lg" />);
const indicator = container.querySelector('span > span');
expect(indicator).toHaveClass('h-4', 'w-4');
});
it('shows label when showLabel is true', () => {
render(<AgentStatusIndicator status="active" showLabel />);
expect(screen.getByText('Active')).toBeInTheDocument();
});
it('does not show label by default', () => {
render(<AgentStatusIndicator status="active" />);
expect(screen.queryByText('Active')).not.toBeInTheDocument();
});
it('has accessible status role and label', () => {
render(<AgentStatusIndicator status="active" />);
expect(screen.getByRole('status')).toHaveAttribute('aria-label', 'Status: Active');
});
it('applies custom className', () => {
const { container } = render(
<AgentStatusIndicator status="active" className="custom-class" />
);
expect(container.firstChild).toHaveClass('custom-class');
});
});