Files
syndarix/frontend/tests/features/issues/components/ActivityTimeline.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

95 lines
3.1 KiB
TypeScript

/**
* ActivityTimeline Component Tests
*/
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { ActivityTimeline } from '@/features/issues/components/ActivityTimeline';
import type { IssueActivity } from '@/features/issues/types';
const mockActivities: IssueActivity[] = [
{
id: 'act-1',
type: 'status_change',
actor: { id: 'user-1', name: 'Test User', type: 'human' },
message: 'moved issue from "Open" to "In Progress"',
timestamp: '2 hours ago',
},
{
id: 'act-2',
type: 'comment',
actor: { id: 'agent-1', name: 'Backend Agent', type: 'agent' },
message: 'Started working on this issue',
timestamp: '3 hours ago',
},
{
id: 'act-3',
type: 'created',
actor: { id: 'user-2', name: 'Product Owner', type: 'human' },
message: 'created this issue',
timestamp: '1 day ago',
},
];
describe('ActivityTimeline', () => {
it('renders all activities', () => {
render(<ActivityTimeline activities={mockActivities} />);
expect(screen.getByText('Test User')).toBeInTheDocument();
expect(screen.getByText('Backend Agent')).toBeInTheDocument();
expect(screen.getByText('Product Owner')).toBeInTheDocument();
});
it('renders activity messages', () => {
render(<ActivityTimeline activities={mockActivities} />);
expect(screen.getByText(/moved issue from "Open" to "In Progress"/)).toBeInTheDocument();
expect(screen.getByText(/Started working on this issue/)).toBeInTheDocument();
expect(screen.getByText(/created this issue/)).toBeInTheDocument();
});
it('renders timestamps', () => {
render(<ActivityTimeline activities={mockActivities} />);
expect(screen.getByText('2 hours ago')).toBeInTheDocument();
expect(screen.getByText('3 hours ago')).toBeInTheDocument();
expect(screen.getByText('1 day ago')).toBeInTheDocument();
});
it('shows add comment button when callback provided', () => {
const mockOnAddComment = jest.fn();
render(<ActivityTimeline activities={mockActivities} onAddComment={mockOnAddComment} />);
expect(screen.getByRole('button', { name: /add comment/i })).toBeInTheDocument();
});
it('calls onAddComment when button is clicked', async () => {
const user = userEvent.setup();
const mockOnAddComment = jest.fn();
render(<ActivityTimeline activities={mockActivities} onAddComment={mockOnAddComment} />);
await user.click(screen.getByRole('button', { name: /add comment/i }));
expect(mockOnAddComment).toHaveBeenCalled();
});
it('shows empty state when no activities', () => {
render(<ActivityTimeline activities={[]} />);
expect(screen.getByText('No activity yet')).toBeInTheDocument();
});
it('applies custom className', () => {
const { container } = render(
<ActivityTimeline activities={mockActivities} className="custom-class" />
);
expect(container.firstChild).toHaveClass('custom-class');
});
it('has proper list role for accessibility', () => {
render(<ActivityTimeline activities={mockActivities} />);
expect(screen.getByRole('list', { name: /issue activity/i })).toBeInTheDocument();
});
});