website refactor

This commit is contained in:
2026-01-17 22:55:03 +01:00
parent 64d9e7fd16
commit 69d4cce7f1
64 changed files with 1146 additions and 1014 deletions

View File

@@ -9,38 +9,39 @@ describe('DashboardService', () => {
beforeEach(() => {
mockApiClient = {
getDashboardData: vi.fn(),
getDashboardOverview: vi.fn(),
getAnalyticsMetrics: vi.fn(),
recordPageView: vi.fn(),
recordEngagement: vi.fn(),
} as Mocked<AnalyticsApiClient>;
} as any;
service = new DashboardService(mockApiClient);
service = new DashboardService();
(service as any).apiClient = mockApiClient;
(service as any).analyticsApiClient = mockApiClient;
});
describe('getDashboardData', () => {
it('should call apiClient.getDashboardData and return AnalyticsDashboardViewModel', async () => {
describe('getDashboardOverview', () => {
it('should call apiClient.getDashboardOverview and return Result with DashboardOverviewDTO', async () => {
const dto = {
totalUsers: 100,
activeUsers: 50,
totalRaces: 20,
totalLeagues: 5,
};
mockApiClient.getDashboardData.mockResolvedValue(dto);
mockApiClient.getDashboardOverview.mockResolvedValue(dto);
const result = await service.getDashboardData();
const result = await service.getDashboardOverview();
expect(mockApiClient.getDashboardData).toHaveBeenCalled();
expect(result).toBeInstanceOf(AnalyticsDashboardViewModel);
expect(result.totalUsers).toBe(100);
expect(result.activeUsers).toBe(50);
expect(result.totalRaces).toBe(20);
expect(result.totalLeagues).toBe(5);
expect(mockApiClient.getDashboardOverview).toHaveBeenCalled();
expect(result.isOk()).toBe(true);
const value = (result as any).value;
expect(value.totalUsers).toBe(100);
expect(value.activeUsers).toBe(50);
expect(value.totalRaces).toBe(20);
expect(value.totalLeagues).toBe(5);
});
});
describe('getAnalyticsMetrics', () => {
it('should call apiClient.getAnalyticsMetrics and return AnalyticsMetricsViewModel', async () => {
it('should call apiClient.getAnalyticsMetrics and return Result with AnalyticsMetricsViewModel', async () => {
const dto = {
pageViews: 1000,
uniqueVisitors: 500,
@@ -52,11 +53,12 @@ describe('DashboardService', () => {
const result = await service.getAnalyticsMetrics();
expect(mockApiClient.getAnalyticsMetrics).toHaveBeenCalled();
expect(result).toBeInstanceOf(AnalyticsMetricsViewModel);
expect(result.pageViews).toBe(1000);
expect(result.uniqueVisitors).toBe(500);
expect(result.averageSessionDuration).toBe(300);
expect(result.bounceRate).toBe(0.25);
expect(result.isOk()).toBe(true);
const value = (result as any).value;
expect(value.pageViews).toBe(1000);
expect(value.uniqueVisitors).toBe(500);
expect(value.averageSessionDuration).toBe(300);
expect(value.bounceRate).toBe(0.25);
});
});