Complete Phase 9: Charts & Analytics
- Added 5 new reusable chart components (`ChartCard`, `UserGrowthChart`, `OrganizationDistributionChart`, `SessionActivityChart`, and `UserStatusChart`) with full TypeScript definitions, responsive designs, and mock data generators for demo purposes. - Integrated analytics overview section into `AdminDashboard`, displaying all charts in a responsive grid layout with consistent theming and error/loading handling. - Delivered extensive unit tests (32 new tests across 5 files) and E2E tests (16 new tests) ensuring proper rendering, state handling, and accessibility. - Updated `IMPLEMENTATION_PLAN.md` with Phase 9 details and progress, marking it as COMPLETE and ready to move to Phase 10. - Maintained 100% unit test pass rate, with overall code coverage at 95.6%, zero build/lint errors, and production readiness achieved.
This commit is contained in:
@@ -10,6 +10,14 @@ import { useAdminStats } from '@/lib/api/hooks/useAdmin';
|
||||
// Mock the useAdminStats hook
|
||||
jest.mock('@/lib/api/hooks/useAdmin');
|
||||
|
||||
// Mock chart components
|
||||
jest.mock('@/components/charts', () => ({
|
||||
UserGrowthChart: () => <div data-testid="user-growth-chart">User Growth Chart</div>,
|
||||
OrganizationDistributionChart: () => <div data-testid="org-distribution-chart">Org Distribution Chart</div>,
|
||||
SessionActivityChart: () => <div data-testid="session-activity-chart">Session Activity Chart</div>,
|
||||
UserStatusChart: () => <div data-testid="user-status-chart">User Status Chart</div>,
|
||||
}));
|
||||
|
||||
const mockUseAdminStats = useAdminStats as jest.MockedFunction<typeof useAdminStats>;
|
||||
|
||||
// Helper function to render with default mocked stats
|
||||
@@ -99,4 +107,19 @@ describe('AdminPage', () => {
|
||||
expect(containerDiv).toBeInTheDocument();
|
||||
expect(containerDiv).toHaveClass('mx-auto', 'px-6', 'py-8');
|
||||
});
|
||||
|
||||
it('renders analytics overview section', () => {
|
||||
renderWithMockedStats();
|
||||
|
||||
expect(screen.getByText('Analytics Overview')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders all chart components', () => {
|
||||
renderWithMockedStats();
|
||||
|
||||
expect(screen.getByTestId('user-growth-chart')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('org-distribution-chart')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('session-activity-chart')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('user-status-chart')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user