view data fixes
Some checks failed
Contract Testing / contract-snapshot (pull_request) Has been cancelled
Contract Testing / contract-tests (pull_request) Has been cancelled

This commit is contained in:
2026-01-25 00:12:30 +01:00
parent 1b0a1f4aee
commit 6c07abe5e7
37 changed files with 400 additions and 185 deletions

View File

@@ -3,7 +3,7 @@ import { RequireSystemAdmin, REQUIRE_SYSTEM_ADMIN_METADATA_KEY } from './Require
// Mock SetMetadata
vi.mock('@nestjs/common', () => ({
SetMetadata: vi.fn(() => () => {}),
SetMetadata: vi.fn(() => (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => descriptor),
}));
describe('RequireSystemAdmin', () => {
@@ -30,7 +30,7 @@ describe('RequireSystemAdmin', () => {
const result = decorator(mockTarget, mockPropertyKey, mockDescriptor);
// The decorator should return the descriptor
// The decorator should return the descriptor (SetMetadata returns the descriptor)
expect(result).toBe(mockDescriptor);
});

View File

@@ -1,6 +1,4 @@
import { AdminUser } from '@core/admin/domain/entities/AdminUser';
import { AuthorizationService } from '@core/admin/domain/services/AuthorizationService';
import { Result } from '@core/shared/domain/Result';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { GetDashboardStatsUseCase } from './GetDashboardStatsUseCase';
@@ -413,15 +411,15 @@ describe('GetDashboardStatsUseCase', () => {
// Check that today has 1 user
const todayEntry = stats.userGrowth[6];
expect(todayEntry.value).toBe(1);
expect(todayEntry?.value).toBe(1);
// Check that yesterday has 1 user
const yesterdayEntry = stats.userGrowth[5];
expect(yesterdayEntry.value).toBe(1);
expect(yesterdayEntry?.value).toBe(1);
// Check that two days ago has 1 user
const twoDaysAgoEntry = stats.userGrowth[4];
expect(twoDaysAgoEntry.value).toBe(1);
expect(twoDaysAgoEntry?.value).toBe(1);
});
it('should calculate activity timeline for last 7 days', async () => {
@@ -643,8 +641,9 @@ describe('GetDashboardStatsUseCase', () => {
status: 'active',
});
const users = Array.from({ length: 1000 }, (_, i) =>
AdminUser.create({
const users = Array.from({ length: 1000 }, (_, i) => {
const hasRecentLogin = i % 10 === 0;
return AdminUser.create({
id: `user-${i}`,
email: `user${i}@example.com`,
displayName: `User ${i}`,
@@ -652,9 +651,9 @@ describe('GetDashboardStatsUseCase', () => {
status: i % 4 === 0 ? 'suspended' : i % 4 === 1 ? 'deleted' : 'active',
createdAt: new Date(Date.now() - i * 3600000),
updatedAt: new Date(Date.now() - i * 3600000),
lastLoginAt: i % 10 === 0 ? new Date(Date.now() - i * 3600000) : undefined,
})
);
...(hasRecentLogin && { lastLoginAt: new Date(Date.now() - i * 3600000) }),
});
});
mockAdminUserRepo.findById.mockResolvedValue(actor);
mockAdminUserRepo.list.mockResolvedValue({ users });

View File

@@ -3,7 +3,7 @@ import { Public, PUBLIC_ROUTE_METADATA_KEY } from './Public';
// Mock SetMetadata
vi.mock('@nestjs/common', () => ({
SetMetadata: vi.fn(() => () => {}),
SetMetadata: vi.fn(() => (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => descriptor),
}));
describe('Public', () => {

View File

@@ -3,7 +3,7 @@ import { RequireAuthenticatedUser, REQUIRE_AUTHENTICATED_USER_METADATA_KEY } fro
// Mock SetMetadata
vi.mock('@nestjs/common', () => ({
SetMetadata: vi.fn(() => () => {}),
SetMetadata: vi.fn(() => (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => descriptor),
}));
describe('RequireAuthenticatedUser', () => {

View File

@@ -3,7 +3,7 @@ import { RequireRoles, REQUIRE_ROLES_METADATA_KEY } from './RequireRoles';
// Mock SetMetadata
vi.mock('@nestjs/common', () => ({
SetMetadata: vi.fn(() => () => {}),
SetMetadata: vi.fn(() => (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => descriptor),
}));
describe('RequireRoles', () => {