website refactor

This commit is contained in:
2026-01-16 19:38:55 +01:00
parent 095885544b
commit 26fc726556
73 changed files with 232 additions and 213 deletions

View File

@@ -1,7 +1,9 @@
import type { Logger } from '@core/shared/domain/Logger'; import type { Logger } from '@core/shared/domain/Logger';
import { describe, expect, it, vi, type Mock } from 'vitest'; import { describe, expect, it, vi, type Mock, beforeEach } from 'vitest';
import type { EntityType } from '../../domain/types/PageView'; import type { EntityType } from '../../domain/types/PageView';
import { GetEntityAnalyticsQuery, type GetEntityAnalyticsInput } from './GetEntityAnalyticsQuery'; import { GetEntityAnalyticsQuery, type GetEntityAnalyticsInput } from './GetEntityAnalyticsQuery';
import type { PageViewRepository } from '../repositories/PageViewRepository';
import type { EngagementRepository } from '../../domain/repositories/EngagementRepository';
describe('GetEntityAnalyticsQuery', () => { describe('GetEntityAnalyticsQuery', () => {
let pageViewRepository: { let pageViewRepository: {

View File

@@ -1,8 +1,9 @@
import type { Logger } from '@core/shared/domain/Logger'; import type { Logger } from '@core/shared/domain/Logger';
import { describe, expect, it, vi, type Mock } from 'vitest'; import { describe, expect, it, vi, type Mock, beforeEach } from 'vitest';
import { EngagementEvent } from '../../domain/entities/EngagementEvent'; import { EngagementEvent } from '../../domain/entities/EngagementEvent';
import type { EngagementAction, EngagementEntityType } from '../../domain/types/EngagementEvent'; import type { EngagementAction, EngagementEntityType } from '../../domain/types/EngagementEvent';
import { RecordEngagementUseCase, type RecordEngagementInput } from './RecordEngagementUseCase'; import { RecordEngagementUseCase, type RecordEngagementInput } from './RecordEngagementUseCase';
import type { EngagementRepository } from '../../domain/repositories/EngagementRepository';
describe('RecordEngagementUseCase', () => { describe('RecordEngagementUseCase', () => {
let engagementRepository: { let engagementRepository: {

View File

@@ -85,8 +85,8 @@ describe('GetUserRatingsSummaryQuery', () => {
expect(result.userId).toBe(userId); expect(result.userId).toBe(userId);
expect(result.platform.driving.value).toBe(50); // Default expect(result.platform.driving.value).toBe(50); // Default
expect(result.platform.overallReputation).toBe(50); expect(result.platform.overallReputation).toBe(50);
expect(result.external.iracing.iRating).toBe(2200); expect(result.external.iracing?.iRating).toBe(2200);
expect(result.external.iracing.safetyRating).toBe(4.5); expect(result.external.iracing?.safetyRating).toBe(4.5);
expect(result.lastRatingEventAt).toBe('2024-01-01T00:00:00.000Z'); expect(result.lastRatingEventAt).toBe('2024-01-01T00:00:00.000Z');
}); });

View File

@@ -1,10 +1,13 @@
import type { Logger } from '@core/shared/domain/Logger'; import type { Logger } from '@core/shared/domain/Logger';
import { Result } from '@core/shared/domain/Result'; import { Result } from '@core/shared/domain/Result';
import { describe, expect, it, vi, type Mock } from 'vitest'; import { describe, expect, it, vi, type Mock, beforeEach } from 'vitest';
import { User } from '../../domain/entities/User'; import { User } from '../../domain/entities/User';
import { PasswordHash } from '../../domain/value-objects/PasswordHash'; import { PasswordHash } from '../../domain/value-objects/PasswordHash';
import { UserId } from '../../domain/value-objects/UserId'; import { UserId } from '../../domain/value-objects/UserId';
import { ForgotPasswordUseCase } from './ForgotPasswordUseCase'; import { ForgotPasswordUseCase } from './ForgotPasswordUseCase';
import type { AuthRepository } from '../../domain/repositories/AuthRepository';
import type { MagicLinkRepository } from '../../domain/repositories/MagicLinkRepository';
import type { MagicLinkNotificationPort } from '../ports/MagicLinkNotificationPort';
describe('ForgotPasswordUseCase', () => { describe('ForgotPasswordUseCase', () => {
let authRepo: { let authRepo: {

View File

@@ -1,7 +1,7 @@
import type { Logger } from '@core/shared/domain/Logger'; import type { Logger } from '@core/shared/domain/Logger';
import { vi, type Mock } from 'vitest'; import { vi, type Mock, beforeEach, describe, it, expect } from 'vitest';
import { User } from '../../domain/entities/User'; import { User } from '../../domain/entities/User';
import { StoredUser } from '../../domain/repositories/UserRepository'; import { StoredUser, type UserRepository } from '../../domain/repositories/UserRepository';
import { GetCurrentSessionUseCase } from './GetCurrentSessionUseCase'; import { GetCurrentSessionUseCase } from './GetCurrentSessionUseCase';
describe('GetCurrentSessionUseCase', () => { describe('GetCurrentSessionUseCase', () => {

View File

@@ -1,6 +1,7 @@
import type { Logger } from '@core/shared/domain/Logger'; import type { Logger } from '@core/shared/domain/Logger';
import { describe, expect, it, vi, type Mock } from 'vitest'; import { describe, expect, it, vi, type Mock, beforeEach } from 'vitest';
import { GetUserUseCase } from './GetUserUseCase'; import { GetUserUseCase } from './GetUserUseCase';
import type { UserRepository } from '../../domain/repositories/UserRepository';
describe('GetUserUseCase', () => { describe('GetUserUseCase', () => {
let userRepo: { let userRepo: {

View File

@@ -1,9 +1,11 @@
import type { Logger } from '@core/shared/domain/Logger'; import type { Logger } from '@core/shared/domain/Logger';
import { describe, expect, it, vi, type Mock } from 'vitest'; import { describe, expect, it, vi, type Mock, beforeEach } from 'vitest';
import { User } from '../../domain/entities/User'; import { User } from '../../domain/entities/User';
import { PasswordHash } from '../../domain/value-objects/PasswordHash'; import { PasswordHash } from '../../domain/value-objects/PasswordHash';
import { UserId } from '../../domain/value-objects/UserId'; import { UserId } from '../../domain/value-objects/UserId';
import { LoginUseCase } from './LoginUseCase'; import { LoginUseCase } from './LoginUseCase';
import type { AuthRepository } from '../../domain/repositories/AuthRepository';
import type { PasswordHashingService } from '../ports/PasswordHashingService';
describe('LoginUseCase', () => { describe('LoginUseCase', () => {
let authRepo: { let authRepo: {

View File

@@ -16,11 +16,11 @@ class MockRaceResultsProvider implements RaceResultsProvider {
this.results = results; this.results = results;
} }
async getRaceResults(_raceId: string): Promise<RaceResultsData | null> { async getRaceResults(): Promise<RaceResultsData | null> {
return this.results; return this.results;
} }
async hasRaceResults(_raceId: string): Promise<boolean> { async hasRaceResults(): Promise<boolean> {
return this.results !== null; return this.results !== null;
} }
} }

View File

@@ -1,6 +1,9 @@
import type { Logger } from '@core/shared/domain/Logger'; import type { Logger } from '@core/shared/domain/Logger';
import { describe, expect, it, vi, type Mock } from 'vitest'; import { describe, expect, it, vi, type Mock, beforeEach } from 'vitest';
import { SignupSponsorUseCase } from './SignupSponsorUseCase'; import { SignupSponsorUseCase } from './SignupSponsorUseCase';
import type { AuthRepository } from '../../domain/repositories/AuthRepository';
import type { CompanyRepository } from '../../domain/repositories/CompanyRepository';
import type { PasswordHashingService } from '../ports/PasswordHashingService';
describe('SignupSponsorUseCase', () => { describe('SignupSponsorUseCase', () => {
let authRepo: { let authRepo: {

View File

@@ -1,9 +1,11 @@
import type { Logger } from '@core/shared/domain/Logger'; import type { Logger } from '@core/shared/domain/Logger';
import { describe, expect, it, vi, type Mock } from 'vitest'; import { describe, expect, it, vi, type Mock, beforeEach } from 'vitest';
import { User } from '../../domain/entities/User'; import { User } from '../../domain/entities/User';
import { PasswordHash } from '../../domain/value-objects/PasswordHash'; import { PasswordHash } from '../../domain/value-objects/PasswordHash';
import { UserId } from '../../domain/value-objects/UserId'; import { UserId } from '../../domain/value-objects/UserId';
import { SignupUseCase } from './SignupUseCase'; import { SignupUseCase } from './SignupUseCase';
import type { AuthRepository } from '../../domain/repositories/AuthRepository';
import type { PasswordHashingService } from '../ports/PasswordHashingService';
describe('SignupUseCase', () => { describe('SignupUseCase', () => {
let authRepo: { let authRepo: {

View File

@@ -1,7 +1,8 @@
import type { Logger } from '@core/shared/domain/Logger'; import type { Logger } from '@core/shared/domain/Logger';
import { describe, expect, it, vi, type Mock } from 'vitest'; import { describe, expect, it, vi, type Mock, beforeEach } from 'vitest';
import type { IdentitySessionPort } from '../ports/IdentitySessionPort'; import type { IdentitySessionPort } from '../ports/IdentitySessionPort';
import { SignupWithEmailUseCase } from './SignupWithEmailUseCase'; import { SignupWithEmailUseCase } from './SignupWithEmailUseCase';
import type { UserRepository } from '../../domain/repositories/UserRepository';
describe('SignupWithEmailUseCase', () => { describe('SignupWithEmailUseCase', () => {
let userRepository: { let userRepository: {

View File

@@ -5,7 +5,7 @@ import { TeamRatingEvent } from '@core/racing/domain/entities/TeamRatingEvent';
import { TeamRatingEventId } from '@core/racing/domain/value-objects/TeamRatingEventId'; import { TeamRatingEventId } from '@core/racing/domain/value-objects/TeamRatingEventId';
import { TeamRatingDimensionKey } from '@core/racing/domain/value-objects/TeamRatingDimensionKey'; import { TeamRatingDimensionKey } from '@core/racing/domain/value-objects/TeamRatingDimensionKey';
import { TeamRatingDelta } from '@core/racing/domain/value-objects/TeamRatingDelta'; import { TeamRatingDelta } from '@core/racing/domain/value-objects/TeamRatingDelta';
import { TeamRating } from '../../domain/entities/TeamRating'; import { TeamRating } from '@core/racing/domain/value-objects/TeamRating';
import { describe, it, expect, beforeEach, afterEach } from 'vitest'; import { describe, it, expect, beforeEach, afterEach } from 'vitest';
// Mock repositories // Mock repositories

View File

@@ -1,7 +1,6 @@
import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
import { import {
ApproveLeagueJoinRequestUseCase, ApproveLeagueJoinRequestUseCase,
type ApproveLeagueJoinRequestResult,
} from './ApproveLeagueJoinRequestUseCase'; } from './ApproveLeagueJoinRequestUseCase';
import { League } from '../../domain/entities/League'; import { League } from '../../domain/entities/League';
import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository';

View File

@@ -1,5 +1,5 @@
import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
import { ApproveTeamJoinRequestUseCase, type ApproveTeamJoinRequestResult } from './ApproveTeamJoinRequestUseCase'; import { ApproveTeamJoinRequestUseCase } from './ApproveTeamJoinRequestUseCase';
import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository';
describe('ApproveTeamJoinRequestUseCase', () => { describe('ApproveTeamJoinRequestUseCase', () => {

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, afterEach, vi, Mock } from 'vitest';
import { import {
CompleteDriverOnboardingUseCase, CompleteDriverOnboardingUseCase,
type CompleteDriverOnboardingInput, type CompleteDriverOnboardingInput,
type CompleteDriverOnboardingResult,
} from './CompleteDriverOnboardingUseCase'; } from './CompleteDriverOnboardingUseCase';
import type { DriverRepository } from '../../domain/repositories/DriverRepository'; import type { DriverRepository } from '../../domain/repositories/DriverRepository';
import { Driver } from '../../domain/entities/Driver'; import { Driver } from '../../domain/entities/Driver';

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
import { import {
CompleteRaceUseCaseWithRatings, CompleteRaceUseCaseWithRatings,
type CompleteRaceWithRatingsInput, type CompleteRaceWithRatingsInput,
type CompleteRaceWithRatingsResult,
} from './CompleteRaceUseCaseWithRatings'; } from './CompleteRaceUseCaseWithRatings';
import type { RaceRepository } from '../../domain/repositories/RaceRepository'; import type { RaceRepository } from '../../domain/repositories/RaceRepository';
import type { RaceRegistrationRepository } from '../../domain/repositories/RaceRegistrationRepository'; import type { RaceRegistrationRepository } from '../../domain/repositories/RaceRegistrationRepository';
@@ -38,7 +37,6 @@ describe('CompleteRaceUseCaseWithRatings', () => {
getRaceResults: Mock; getRaceResults: Mock;
hasRaceResults: Mock; hasRaceResults: Mock;
}; };
let output: { present: Mock };
beforeEach(() => { beforeEach(() => {
raceRepository = { raceRepository = {

View File

@@ -3,6 +3,10 @@ import {
CreateLeagueWithSeasonAndScoringUseCase, CreateLeagueWithSeasonAndScoringUseCase,
type CreateLeagueWithSeasonAndScoringCommand type CreateLeagueWithSeasonAndScoringCommand
} from './CreateLeagueWithSeasonAndScoringUseCase'; } from './CreateLeagueWithSeasonAndScoringUseCase';
import type { LeagueRepository } from '../../domain/repositories/LeagueRepository';
import type { SeasonRepository } from '../../domain/repositories/SeasonRepository';
import type { LeagueScoringConfigRepository } from '../../domain/repositories/LeagueScoringConfigRepository';
import type { Logger } from '@core/shared/domain/Logger';
describe('CreateLeagueWithSeasonAndScoringUseCase', () => { describe('CreateLeagueWithSeasonAndScoringUseCase', () => {
let useCase: CreateLeagueWithSeasonAndScoringUseCase; let useCase: CreateLeagueWithSeasonAndScoringUseCase;
@@ -40,11 +44,13 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => {
warn: vi.fn(), warn: vi.fn(),
error: vi.fn(), error: vi.fn(),
}; };
useCase = new CreateLeagueWithSeasonAndScoringUseCase(leagueRepository as any, useCase = new CreateLeagueWithSeasonAndScoringUseCase(
seasonRepository as any, leagueRepository as unknown as LeagueRepository,
leagueScoringConfigRepository as any, seasonRepository as unknown as SeasonRepository,
leagueScoringConfigRepository as unknown as LeagueScoringConfigRepository,
getLeagueScoringPresetById, getLeagueScoringPresetById,
logger as any); logger as unknown as Logger
);
}); });
it('should create league, season, and scoring successfully', async () => { it('should create league, season, and scoring successfully', async () => {

View File

@@ -7,7 +7,6 @@ import type { SeasonRepository } from '../../domain/repositories/SeasonRepositor
import { import {
GetAllLeaguesWithCapacityAndScoringUseCase, GetAllLeaguesWithCapacityAndScoringUseCase,
type GetAllLeaguesWithCapacityAndScoringInput, type GetAllLeaguesWithCapacityAndScoringInput,
type GetAllLeaguesWithCapacityAndScoringResult,
} from './GetAllLeaguesWithCapacityAndScoringUseCase'; } from './GetAllLeaguesWithCapacityAndScoringUseCase';
describe('GetAllLeaguesWithCapacityAndScoringUseCase', () => { describe('GetAllLeaguesWithCapacityAndScoringUseCase', () => {

View File

@@ -1,10 +1,12 @@
import type { Logger } from '@core/shared/domain/Logger'; import type { Logger } from '@core/shared/domain/Logger';
import { beforeEach, describe, expect, it, vi } from 'vitest'; import { beforeEach, describe, expect, it, vi } from 'vitest';
import { GetDriverTeamUseCase, type GetDriverTeamInput } from './GetDriverTeamUseCase'; import { GetDriverTeamUseCase, type GetDriverTeamInput } from './GetDriverTeamUseCase';
import type { TeamRepository } from '../../domain/repositories/TeamRepository';
import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository';
describe('GetDriverTeamUseCase', () => { describe('GetDriverTeamUseCase', () => {
let mockTeamRepo: any; let mockTeamRepo: TeamRepository;
let mockMembershipRepo: any; let mockMembershipRepo: TeamMembershipRepository;
let mockLogger: Logger; let mockLogger: Logger;
beforeEach(() => { beforeEach(() => {
@@ -16,7 +18,7 @@ describe('GetDriverTeamUseCase', () => {
update: vi.fn(), update: vi.fn(),
delete: vi.fn(), delete: vi.fn(),
exists: vi.fn(), exists: vi.fn(),
}; } as unknown as TeamRepository;
mockMembershipRepo = { mockMembershipRepo = {
getActiveMembershipForDriver: vi.fn(), getActiveMembershipForDriver: vi.fn(),
@@ -28,7 +30,7 @@ describe('GetDriverTeamUseCase', () => {
countByTeamId: vi.fn(), countByTeamId: vi.fn(),
saveJoinRequest: vi.fn(), saveJoinRequest: vi.fn(),
removeJoinRequest: vi.fn(), removeJoinRequest: vi.fn(),
}; } as unknown as TeamMembershipRepository;
mockLogger = { mockLogger = {
debug: vi.fn(), debug: vi.fn(),

View File

@@ -5,9 +5,10 @@ import {
GetEntitySponsorshipPricingUseCase, GetEntitySponsorshipPricingUseCase,
type GetEntitySponsorshipPricingInput type GetEntitySponsorshipPricingInput
} from './GetEntitySponsorshipPricingUseCase'; } from './GetEntitySponsorshipPricingUseCase';
import type { SponsorshipPricingRepository } from '../../domain/repositories/SponsorshipPricingRepository';
describe('GetEntitySponsorshipPricingUseCase', () => { describe('GetEntitySponsorshipPricingUseCase', () => {
let mockSponsorshipPricingRepo: any; let mockSponsorshipPricingRepo: SponsorshipPricingRepository;
let mockLogger: Logger; let mockLogger: Logger;
let mockFindByEntity: Mock; let mockFindByEntity: Mock;
@@ -22,7 +23,7 @@ describe('GetEntitySponsorshipPricingUseCase', () => {
save: vi.fn(), save: vi.fn(),
exists: vi.fn(), exists: vi.fn(),
findAcceptingApplications: vi.fn(), findAcceptingApplications: vi.fn(),
}; } as unknown as SponsorshipPricingRepository;
mockLogger = { mockLogger = {
debug: vi.fn(), debug: vi.fn(),
info: vi.fn(), info: vi.fn(),
@@ -32,7 +33,7 @@ describe('GetEntitySponsorshipPricingUseCase', () => {
}); });
it('should return PRICING_NOT_CONFIGURED when no pricing found', async () => { it('should return PRICING_NOT_CONFIGURED when no pricing found', async () => {
const useCase = new GetEntitySponsorshipPricingUseCase(mockSponsorshipPricingRepo as any, const useCase = new GetEntitySponsorshipPricingUseCase(mockSponsorshipPricingRepo,
mockLogger); mockLogger);
const dto: GetEntitySponsorshipPricingInput = { const dto: GetEntitySponsorshipPricingInput = {
@@ -54,7 +55,7 @@ describe('GetEntitySponsorshipPricingUseCase', () => {
}); });
it('should return pricing data when found', async () => { it('should return pricing data when found', async () => {
const useCase = new GetEntitySponsorshipPricingUseCase(mockSponsorshipPricingRepo as any, const useCase = new GetEntitySponsorshipPricingUseCase(mockSponsorshipPricingRepo,
mockLogger); mockLogger);
const dto: GetEntitySponsorshipPricingInput = { const dto: GetEntitySponsorshipPricingInput = {
@@ -106,7 +107,7 @@ describe('GetEntitySponsorshipPricingUseCase', () => {
}); });
it('should return error when repository throws', async () => { it('should return error when repository throws', async () => {
const useCase = new GetEntitySponsorshipPricingUseCase(mockSponsorshipPricingRepo as any, const useCase = new GetEntitySponsorshipPricingUseCase(mockSponsorshipPricingRepo,
mockLogger); mockLogger);
const dto: GetEntitySponsorshipPricingInput = { const dto: GetEntitySponsorshipPricingInput = {

View File

@@ -6,10 +6,12 @@ import {
type GetLeagueAdminPermissionsErrorCode, type GetLeagueAdminPermissionsErrorCode,
type GetLeagueAdminPermissionsInput type GetLeagueAdminPermissionsInput
} from './GetLeagueAdminPermissionsUseCase'; } from './GetLeagueAdminPermissionsUseCase';
import type { LeagueRepository } from '../../domain/repositories/LeagueRepository';
import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository';
describe('GetLeagueAdminPermissionsUseCase', () => { describe('GetLeagueAdminPermissionsUseCase', () => {
let mockLeagueRepo: any; let mockLeagueRepo: LeagueRepository;
let mockMembershipRepo: any; let mockMembershipRepo: LeagueMembershipRepository;
let mockFindById: Mock; let mockFindById: Mock;
let mockGetMembership: Mock; let mockGetMembership: Mock;
const logger: Logger = { const logger: Logger = {
@@ -31,7 +33,7 @@ describe('GetLeagueAdminPermissionsUseCase', () => {
exists: vi.fn(), exists: vi.fn(),
findByOwnerId: vi.fn(), findByOwnerId: vi.fn(),
searchByName: vi.fn(), searchByName: vi.fn(),
}; } as unknown as LeagueRepository;
mockMembershipRepo = { mockMembershipRepo = {
getMembership: mockGetMembership, getMembership: mockGetMembership,
@@ -43,7 +45,7 @@ describe('GetLeagueAdminPermissionsUseCase', () => {
removeJoinRequest: vi.fn(), removeJoinRequest: vi.fn(),
countByLeagueId: vi.fn(), countByLeagueId: vi.fn(),
getLeagueMembers: vi.fn(), getLeagueMembers: vi.fn(),
}; } as unknown as LeagueMembershipRepository;
}); });
const createUseCase = () => new GetLeagueAdminPermissionsUseCase(mockLeagueRepo, const createUseCase = () => new GetLeagueAdminPermissionsUseCase(mockLeagueRepo,
@@ -107,7 +109,7 @@ describe('GetLeagueAdminPermissionsUseCase', () => {
}); });
it('returns admin permissions for admin role', async () => { it('returns admin permissions for admin role', async () => {
const league = { id: 'league1' } as any; const league = { id: 'league1' } as unknown as League;
mockFindById.mockResolvedValue(league); mockFindById.mockResolvedValue(league);
mockGetMembership.mockResolvedValue({ status: 'active', role: 'admin' }); mockGetMembership.mockResolvedValue({ status: 'active', role: 'admin' });
@@ -127,7 +129,7 @@ describe('GetLeagueAdminPermissionsUseCase', () => {
}); });
it('returns admin permissions for owner role', async () => { it('returns admin permissions for owner role', async () => {
const league = { id: 'league1' } as any; const league = { id: 'league1' } as unknown as League;
mockFindById.mockResolvedValue(league); mockFindById.mockResolvedValue(league);
mockGetMembership.mockResolvedValue({ status: 'active', role: 'owner' }); mockGetMembership.mockResolvedValue({ status: 'active', role: 'owner' });

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { import {
GetLeagueJoinRequestsUseCase, GetLeagueJoinRequestsUseCase,
type GetLeagueJoinRequestsInput, type GetLeagueJoinRequestsInput,
type GetLeagueJoinRequestsResult,
type GetLeagueJoinRequestsErrorCode, type GetLeagueJoinRequestsErrorCode,
} from './GetLeagueJoinRequestsUseCase'; } from './GetLeagueJoinRequestsUseCase';
import { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; import { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository';

View File

@@ -1,7 +1,6 @@
import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
import { import {
GetLeagueProtestsUseCase, GetLeagueProtestsUseCase,
GetLeagueProtestsResult,
GetLeagueProtestsInput, GetLeagueProtestsInput,
GetLeagueProtestsErrorCode, GetLeagueProtestsErrorCode,
} from './GetLeagueProtestsUseCase'; } from './GetLeagueProtestsUseCase';

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { import {
GetLeagueRosterJoinRequestsUseCase, GetLeagueRosterJoinRequestsUseCase,
type GetLeagueRosterJoinRequestsInput, type GetLeagueRosterJoinRequestsInput,
type GetLeagueRosterJoinRequestsResult,
type GetLeagueRosterJoinRequestsErrorCode, type GetLeagueRosterJoinRequestsErrorCode,
} from './GetLeagueRosterJoinRequestsUseCase'; } from './GetLeagueRosterJoinRequestsUseCase';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { import {
GetLeagueRosterMembersUseCase, GetLeagueRosterMembersUseCase,
type GetLeagueRosterMembersInput, type GetLeagueRosterMembersInput,
type GetLeagueRosterMembersResult,
type GetLeagueRosterMembersErrorCode, type GetLeagueRosterMembersErrorCode,
} from './GetLeagueRosterMembersUseCase'; } from './GetLeagueRosterMembersUseCase';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';

View File

@@ -1,4 +1,4 @@
import { describe, it, expect, beforeEach, vi } from 'vitest'; import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { GetLeagueScoringConfigUseCase } from './GetLeagueScoringConfigUseCase'; import { GetLeagueScoringConfigUseCase } from './GetLeagueScoringConfigUseCase';
import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; import type { LeagueRepository } from '../../domain/repositories/LeagueRepository';
import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; import type { SeasonRepository } from '../../domain/repositories/SeasonRepository';
@@ -12,27 +12,11 @@ import type { LeagueScoringPreset } from '../../domain/types/LeagueScoringPreset
describe('GetLeagueScoringConfigUseCase', () => { describe('GetLeagueScoringConfigUseCase', () => {
let useCase: GetLeagueScoringConfigUseCase; let useCase: GetLeagueScoringConfigUseCase;
let mockLeagueRepository: { let mockLeagueRepository: LeagueRepository;
findById: any; let mockSeasonRepository: SeasonRepository;
exists: any; let mockLeagueScoringConfigRepository: LeagueScoringConfigRepository;
save: any; let mockGameRepository: GameRepository;
findAll: any; let mockPresetProvider: { getPresetById: Mock };
};
let mockSeasonRepository: {
findByLeagueId: any;
save: any;
findById: any;
};
let mockLeagueScoringConfigRepository: {
findBySeasonId: any;
save: any;
};
let mockGameRepository: {
findById: any;
save: any;
findAll: any;
};
let mockPresetProvider: { getPresetById: any };
beforeEach(() => { beforeEach(() => {
mockLeagueRepository = { mockLeagueRepository = {
@@ -40,35 +24,35 @@ describe('GetLeagueScoringConfigUseCase', () => {
exists: vi.fn(), exists: vi.fn(),
save: vi.fn(), save: vi.fn(),
findAll: vi.fn(), findAll: vi.fn(),
}; } as unknown as LeagueRepository;
mockSeasonRepository = { mockSeasonRepository = {
findByLeagueId: vi.fn(), findByLeagueId: vi.fn(),
save: vi.fn(), save: vi.fn(),
findById: vi.fn(), findById: vi.fn(),
}; } as unknown as SeasonRepository;
mockLeagueScoringConfigRepository = { mockLeagueScoringConfigRepository = {
findBySeasonId: vi.fn(), findBySeasonId: vi.fn(),
save: vi.fn(), save: vi.fn(),
}; } as unknown as LeagueScoringConfigRepository;
mockGameRepository = { mockGameRepository = {
findById: vi.fn(), findById: vi.fn(),
save: vi.fn(), save: vi.fn(),
findAll: vi.fn(), findAll: vi.fn(),
}; } as unknown as GameRepository;
mockPresetProvider = { mockPresetProvider = {
getPresetById: vi.fn(), getPresetById: vi.fn(),
}; };
useCase = new GetLeagueScoringConfigUseCase( useCase = new GetLeagueScoringConfigUseCase(
mockLeagueRepository as unknown as LeagueRepository, mockLeagueRepository,
mockSeasonRepository as unknown as SeasonRepository, mockSeasonRepository,
mockLeagueScoringConfigRepository as unknown as LeagueScoringConfigRepository, mockLeagueScoringConfigRepository,
mockGameRepository as unknown as GameRepository, mockGameRepository,
mockPresetProvider as any, mockPresetProvider as unknown as { getPresetById: (id: string) => LeagueScoringPreset | undefined },
); );
}); });
@@ -96,7 +80,7 @@ describe('GetLeagueScoringConfigUseCase', () => {
const result = await useCase.execute({ leagueId: 'league-1' }); const result = await useCase.execute({ leagueId: 'league-1' });
expect(result.isOk()).toBe(true); expect(result.isOk()).toBe(true);
const value = result.unwrap() as any; const value = result.unwrap();
expect(value.league).toBe(mockLeague); expect(value.league).toBe(mockLeague);
expect(value.season).toBe(mockSeason); expect(value.season).toBe(mockSeason);
expect(value.scoringConfig).toBe(mockScoringConfig); expect(value.scoringConfig).toBe(mockScoringConfig);
@@ -221,7 +205,7 @@ describe('GetLeagueScoringConfigUseCase', () => {
const result = await useCase.execute({ leagueId: 'league-1' }); const result = await useCase.execute({ leagueId: 'league-1' });
expect(result.isOk()).toBe(true); expect(result.isOk()).toBe(true);
const value = result.unwrap() as any; const value = result.unwrap();
expect(value.preset).toBeUndefined(); expect(value.preset).toBeUndefined();
}); });

View File

@@ -2,14 +2,13 @@ import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { import {
GetLeagueSeasonsUseCase, GetLeagueSeasonsUseCase,
type GetLeagueSeasonsInput, type GetLeagueSeasonsInput,
type GetLeagueSeasonsResult,
type GetLeagueSeasonsErrorCode, type GetLeagueSeasonsErrorCode,
} from './GetLeagueSeasonsUseCase'; } from './GetLeagueSeasonsUseCase';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { SeasonRepository } from '../../domain/repositories/SeasonRepository';
import type { LeagueRepository } from '../../domain/repositories/LeagueRepository';
import { Season } from '../../domain/entities/season/Season'; import { Season } from '../../domain/entities/season/Season';
import { League } from '../../domain/entities/League'; import { League } from '../../domain/entities/League';
import type { LeagueRepository } from '../../domain/repositories/LeagueRepository';
import type { SeasonRepository } from '../../domain/repositories/SeasonRepository';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
describe('GetLeagueSeasonsUseCase', () => { describe('GetLeagueSeasonsUseCase', () => {
let useCase: GetLeagueSeasonsUseCase; let useCase: GetLeagueSeasonsUseCase;
@@ -31,8 +30,10 @@ describe('GetLeagueSeasonsUseCase', () => {
exists: vi.fn(), exists: vi.fn(),
}; };
useCase = new GetLeagueSeasonsUseCase(leagueRepository as any, useCase = new GetLeagueSeasonsUseCase(
seasonRepository as any); leagueRepository as unknown as LeagueRepository,
seasonRepository as unknown as SeasonRepository
);
}); });
it('should return seasons with correct isParallelActive flags on success', async () => { it('should return seasons with correct isParallelActive flags on success', async () => {

View File

@@ -3,11 +3,12 @@ import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorC
import { import {
GetLeagueStandingsUseCase, GetLeagueStandingsUseCase,
type GetLeagueStandingsInput, type GetLeagueStandingsInput,
type GetLeagueStandingsResult,
type GetLeagueStandingsErrorCode, type GetLeagueStandingsErrorCode,
} from './GetLeagueStandingsUseCase'; } from './GetLeagueStandingsUseCase';
import { Standing } from '../../domain/entities/Standing'; import { Standing } from '../../domain/entities/Standing';
import { Driver } from '../../domain/entities/Driver'; import { Driver } from '../../domain/entities/Driver';
import type { StandingRepository } from '../../domain/repositories/StandingRepository';
import type { DriverRepository } from '../../domain/repositories/DriverRepository';
describe('GetLeagueStandingsUseCase', () => { describe('GetLeagueStandingsUseCase', () => {
let useCase: GetLeagueStandingsUseCase; let useCase: GetLeagueStandingsUseCase;
@@ -26,8 +27,8 @@ describe('GetLeagueStandingsUseCase', () => {
findById: vi.fn(), findById: vi.fn(),
}; };
useCase = new GetLeagueStandingsUseCase(standingRepository as any, useCase = new GetLeagueStandingsUseCase(standingRepository as unknown as StandingRepository,
driverRepository as any); driverRepository as unknown as DriverRepository);
}); });
it('should return standings with drivers mapped', async () => { it('should return standings with drivers mapped', async () => {

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { import {
GetLeagueStatsUseCase, GetLeagueStatsUseCase,
type GetLeagueStatsInput, type GetLeagueStatsInput,
type GetLeagueStatsResult,
type GetLeagueStatsErrorCode, type GetLeagueStatsErrorCode,
} from './GetLeagueStatsUseCase'; } from './GetLeagueStatsUseCase';
import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository';
@@ -27,8 +26,8 @@ describe('GetLeagueStatsUseCase', () => {
findByLeagueId: vi.fn(), findByLeagueId: vi.fn(),
}; };
getDriverRating = vi.fn(); getDriverRating = vi.fn();
useCase = new GetLeagueStatsUseCase(leagueMembershipRepository as any, useCase = new GetLeagueStatsUseCase(leagueMembershipRepository as unknown as LeagueMembershipRepository,
raceRepository as any, raceRepository as unknown as RaceRepository,
getDriverRating); getDriverRating);
}); });

View File

@@ -1,7 +1,6 @@
import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest'; import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { import {
GetLeagueWalletUseCase, GetLeagueWalletUseCase,
type GetLeagueWalletResult,
type GetLeagueWalletInput, type GetLeagueWalletInput,
type GetLeagueWalletErrorCode, type GetLeagueWalletErrorCode,
} from './GetLeagueWalletUseCase'; } from './GetLeagueWalletUseCase';
@@ -40,9 +39,9 @@ describe('GetLeagueWalletUseCase', () => {
findByWalletId: vi.fn(), findByWalletId: vi.fn(),
}; };
useCase = new GetLeagueWalletUseCase(leagueRepository as any, useCase = new GetLeagueWalletUseCase(leagueRepository as unknown as LeagueRepository,
leagueWalletRepository as any, leagueWalletRepository as unknown as LeagueWalletRepository,
transactionRepository as any); transactionRepository as unknown as TransactionRepository);
}); });
it('returns mapped wallet data when wallet exists', async () => { it('returns mapped wallet data when wallet exists', async () => {

View File

@@ -1,7 +1,6 @@
import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
import { import {
GetPendingSponsorshipRequestsUseCase, GetPendingSponsorshipRequestsUseCase,
type GetPendingSponsorshipRequestsResult,
type GetPendingSponsorshipRequestsInput, type GetPendingSponsorshipRequestsInput,
type GetPendingSponsorshipRequestsErrorCode, type GetPendingSponsorshipRequestsErrorCode,
} from './GetPendingSponsorshipRequestsUseCase'; } from './GetPendingSponsorshipRequestsUseCase';

View File

@@ -1,13 +1,16 @@
import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest'; import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { import {
GetProfileOverviewUseCase, GetProfileOverviewUseCase,
type GetProfileOverviewResult,
} from './GetProfileOverviewUseCase'; } from './GetProfileOverviewUseCase';
import { DriverRepository } from '../../domain/repositories/DriverRepository'; import { DriverRepository } from '../../domain/repositories/DriverRepository';
import { TeamRepository } from '../../domain/repositories/TeamRepository'; import { TeamRepository } from '../../domain/repositories/TeamRepository';
import { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; import { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository';
import { SocialGraphRepository } from '@core/social/domain/repositories/SocialGraphRepository'; import { SocialGraphRepository } from '@core/social/domain/repositories/SocialGraphRepository';
import { Driver } from '../../domain/entities/Driver'; import { Driver } from '../../domain/entities/Driver';
import type { DriverStatsUseCase } from './DriverStatsUseCase';
import type { RankingUseCase } from './RankingUseCase';
import type { DriverExtendedProfileProvider } from '../ports/DriverExtendedProfileProvider';
describe('GetProfileOverviewUseCase', () => { describe('GetProfileOverviewUseCase', () => {
let useCase: GetProfileOverviewUseCase; let useCase: GetProfileOverviewUseCase;
let driverRepository: { let driverRepository: {
@@ -64,9 +67,9 @@ describe('GetProfileOverviewUseCase', () => {
teamRepository as unknown as TeamRepository, teamRepository as unknown as TeamRepository,
teamMembershipRepository as unknown as TeamMembershipRepository, teamMembershipRepository as unknown as TeamMembershipRepository,
socialRepository as unknown as SocialGraphRepository, socialRepository as unknown as SocialGraphRepository,
driverExtendedProfileProvider, driverExtendedProfileProvider as unknown as DriverExtendedProfileProvider,
driverStatsUseCase as unknown as any, driverStatsUseCase as unknown as DriverStatsUseCase,
rankingUseCase as unknown as any); rankingUseCase as unknown as RankingUseCase);
}); });
it('should return profile overview for existing driver', async () => { it('should return profile overview for existing driver', async () => {

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { import {
GetRaceProtestsUseCase, GetRaceProtestsUseCase,
type GetRaceProtestsInput, type GetRaceProtestsInput,
type GetRaceProtestsResult,
type GetRaceProtestsErrorCode, type GetRaceProtestsErrorCode,
} from './GetRaceProtestsUseCase'; } from './GetRaceProtestsUseCase';
import { Protest } from '../../domain/entities/Protest'; import { Protest } from '../../domain/entities/Protest';

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { import {
GetRaceResultsDetailUseCase, GetRaceResultsDetailUseCase,
type GetRaceResultsDetailInput, type GetRaceResultsDetailInput,
type GetRaceResultsDetailResult,
type GetRaceResultsDetailErrorCode, type GetRaceResultsDetailErrorCode,
} from './GetRaceResultsDetailUseCase'; } from './GetRaceResultsDetailUseCase';
import type { RaceRepository } from '../../domain/repositories/RaceRepository'; import type { RaceRepository } from '../../domain/repositories/RaceRepository';

View File

@@ -39,7 +39,7 @@ describe('GetRaceWithSOFUseCase', () => {
raceRepository as unknown as RaceRepository, raceRepository as unknown as RaceRepository,
registrationRepository as unknown as RaceRegistrationRepository, registrationRepository as unknown as RaceRegistrationRepository,
resultRepository as unknown as ResultRepository, resultRepository as unknown as ResultRepository,
getDriverRating as any getDriverRating as unknown as (input: { driverId: string }) => Promise<{ rating: number | null; ratingChange: number | null }>
); );
}); });

View File

@@ -8,6 +8,8 @@ import {
type GetRacesPageDataInput, type GetRacesPageDataInput,
type GetRacesPageDataResult, type GetRacesPageDataResult,
} from './GetRacesPageDataUseCase'; } from './GetRacesPageDataUseCase';
import type { RaceRepository } from '../../domain/repositories/RaceRepository';
import type { LeagueRepository } from '../../domain/repositories/LeagueRepository';
describe('GetRacesPageDataUseCase', () => { describe('GetRacesPageDataUseCase', () => {
let useCase: GetRacesPageDataUseCase; let useCase: GetRacesPageDataUseCase;

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
import { import {
GetSponsorDashboardUseCase, GetSponsorDashboardUseCase,
type GetSponsorDashboardInput, type GetSponsorDashboardInput,
type GetSponsorDashboardResult,
type GetSponsorDashboardErrorCode, type GetSponsorDashboardErrorCode,
} from './GetSponsorDashboardUseCase'; } from './GetSponsorDashboardUseCase';
import { SponsorRepository } from '../../domain/repositories/SponsorRepository'; import { SponsorRepository } from '../../domain/repositories/SponsorRepository';

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
import { import {
GetSponsorSponsorshipsUseCase, GetSponsorSponsorshipsUseCase,
type GetSponsorSponsorshipsInput, type GetSponsorSponsorshipsInput,
type GetSponsorSponsorshipsResult,
type GetSponsorSponsorshipsErrorCode, type GetSponsorSponsorshipsErrorCode,
} from './GetSponsorSponsorshipsUseCase'; } from './GetSponsorSponsorshipsUseCase';
import { SponsorRepository } from '../../domain/repositories/SponsorRepository'; import { SponsorRepository } from '../../domain/repositories/SponsorRepository';

View File

@@ -2,7 +2,6 @@ import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest';
import { import {
GetSponsorUseCase, GetSponsorUseCase,
type GetSponsorInput, type GetSponsorInput,
type GetSponsorResult,
type GetSponsorErrorCode, type GetSponsorErrorCode,
} from './GetSponsorUseCase'; } from './GetSponsorUseCase';
import type { SponsorRepository } from '../../domain/repositories/SponsorRepository'; import type { SponsorRepository } from '../../domain/repositories/SponsorRepository';

View File

@@ -1,6 +1,7 @@
import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { GetSponsorsUseCase } from './GetSponsorsUseCase'; import { GetSponsorsUseCase } from './GetSponsorsUseCase';
import { Sponsor } from '../../domain/entities/sponsor/Sponsor'; import { Sponsor } from '../../domain/entities/sponsor/Sponsor';
import type { SponsorRepository } from '../../domain/repositories/SponsorRepository';
describe('GetSponsorsUseCase', () => { describe('GetSponsorsUseCase', () => {
let useCase: GetSponsorsUseCase; let useCase: GetSponsorsUseCase;
@@ -12,7 +13,7 @@ describe('GetSponsorsUseCase', () => {
sponsorRepository = { sponsorRepository = {
findAll: vi.fn(), findAll: vi.fn(),
}; };
useCase = new GetSponsorsUseCase(sponsorRepository as any); useCase = new GetSponsorsUseCase(sponsorRepository as unknown as SponsorRepository);
}); });
it('should return all sponsors', async () => { it('should return all sponsors', async () => {

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
import { import {
GetTeamDetailsUseCase, GetTeamDetailsUseCase,
type GetTeamDetailsInput, type GetTeamDetailsInput,
type GetTeamDetailsResult,
type GetTeamDetailsErrorCode, type GetTeamDetailsErrorCode,
} from './GetTeamDetailsUseCase'; } from './GetTeamDetailsUseCase';
import { Team } from '../../domain/entities/Team'; import { Team } from '../../domain/entities/Team';
@@ -25,8 +24,8 @@ describe('GetTeamDetailsUseCase', () => {
membershipRepository = { membershipRepository = {
getMembership: vi.fn(), getMembership: vi.fn(),
}; };
useCase = new GetTeamDetailsUseCase(teamRepository as any, useCase = new GetTeamDetailsUseCase(teamRepository as unknown as TeamRepository,
membershipRepository as any); membershipRepository as unknown as TeamMembershipRepository);
}); });
it('should return team details with membership', async () => { it('should return team details with membership', async () => {

View File

@@ -9,7 +9,6 @@ import {
import { TeamRepository } from '../../domain/repositories/TeamRepository'; import { TeamRepository } from '../../domain/repositories/TeamRepository';
import { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; import { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository';
import type { Logger } from '@core/shared/domain/Logger';
describe('GetTeamsLeaderboardUseCase', () => { describe('GetTeamsLeaderboardUseCase', () => {
let useCase: GetTeamsLeaderboardUseCase; let useCase: GetTeamsLeaderboardUseCase;
@@ -46,7 +45,7 @@ describe('GetTeamsLeaderboardUseCase', () => {
useCase = new GetTeamsLeaderboardUseCase( useCase = new GetTeamsLeaderboardUseCase(
teamRepository as unknown as TeamRepository, teamRepository as unknown as TeamRepository,
teamMembershipRepository as unknown as TeamMembershipRepository, teamMembershipRepository as unknown as TeamMembershipRepository,
getDriverStats as any, getDriverStats as unknown as (driverId: string) => { rating: number | null; wins: number; totalRaces: number } | null,
logger as unknown as Logger logger as unknown as Logger
); );
}); });

View File

@@ -3,7 +3,6 @@ import {
GetTotalDriversUseCase, GetTotalDriversUseCase,
GetTotalDriversInput, GetTotalDriversInput,
GetTotalDriversErrorCode, GetTotalDriversErrorCode,
GetTotalDriversResult,
} from './GetTotalDriversUseCase'; } from './GetTotalDriversUseCase';
import { DriverRepository } from '../../domain/repositories/DriverRepository'; import { DriverRepository } from '../../domain/repositories/DriverRepository';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
import { import {
GetTotalLeaguesUseCase, GetTotalLeaguesUseCase,
type GetTotalLeaguesInput, type GetTotalLeaguesInput,
type GetTotalLeaguesResult,
type GetTotalLeaguesErrorCode, type GetTotalLeaguesErrorCode,
} from './GetTotalLeaguesUseCase'; } from './GetTotalLeaguesUseCase';
import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; import type { LeagueRepository } from '../../domain/repositories/LeagueRepository';

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { import {
GetTotalRacesUseCase, GetTotalRacesUseCase,
type GetTotalRacesInput, type GetTotalRacesInput,
type GetTotalRacesResult,
type GetTotalRacesErrorCode, type GetTotalRacesErrorCode,
} from './GetTotalRacesUseCase'; } from './GetTotalRacesUseCase';
import type { RaceRepository } from '../../domain/repositories/RaceRepository'; import type { RaceRepository } from '../../domain/repositories/RaceRepository';

View File

@@ -1,10 +1,13 @@
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; import { beforeEach, describe, expect, it, type Mock, vi } from 'vitest';
import { import {
IsDriverRegisteredForRaceUseCase, IsDriverRegisteredForRaceUseCase,
type IsDriverRegisteredForRaceErrorCode, type IsDriverRegisteredForRaceErrorCode,
type IsDriverRegisteredForRaceInput type IsDriverRegisteredForRaceInput
} from './IsDriverRegisteredForRaceUseCase'; } from './IsDriverRegisteredForRaceUseCase';
import type { RaceRegistrationRepository } from '../../domain/repositories/RaceRegistrationRepository';
import type { Logger } from '@core/shared/domain/Logger';
describe('IsDriverRegisteredForRaceUseCase', () => { describe('IsDriverRegisteredForRaceUseCase', () => {
let useCase: IsDriverRegisteredForRaceUseCase; let useCase: IsDriverRegisteredForRaceUseCase;
let registrationRepository: { let registrationRepository: {
@@ -26,8 +29,8 @@ describe('IsDriverRegisteredForRaceUseCase', () => {
warn: vi.fn(), warn: vi.fn(),
error: vi.fn(), error: vi.fn(),
}; };
useCase = new IsDriverRegisteredForRaceUseCase(registrationRepository as any, useCase = new IsDriverRegisteredForRaceUseCase(registrationRepository as unknown as RaceRegistrationRepository,
logger as any); logger as unknown as Logger);
}); });
it('should return true when driver is registered', async () => { it('should return true when driver is registered', async () => {

View File

@@ -1,5 +1,5 @@
import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
import { JoinLeagueUseCase, type JoinLeagueResult, type JoinLeagueInput, type JoinLeagueErrorCode } from './JoinLeagueUseCase'; import { JoinLeagueUseCase, type JoinLeagueInput, type JoinLeagueErrorCode } from './JoinLeagueUseCase';
import { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; import { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository';
import { LeagueMembership } from '../../domain/entities/LeagueMembership'; import { LeagueMembership } from '../../domain/entities/LeagueMembership';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { import {
LeaveTeamUseCase, LeaveTeamUseCase,
type LeaveTeamInput, type LeaveTeamInput,
type LeaveTeamResult,
type LeaveTeamErrorCode, type LeaveTeamErrorCode,
} from './LeaveTeamUseCase'; } from './LeaveTeamUseCase';
import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository';

View File

@@ -1,12 +1,11 @@
import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest'; import { describe, it, expect, beforeEach, vi } from 'vitest';
import { import {
ListLeagueScoringPresetsUseCase, ListLeagueScoringPresetsUseCase,
type ListLeagueScoringPresetsInput, type ListLeagueScoringPresetsInput,
type ListLeagueScoringPresetsResult,
type ListLeagueScoringPresetsErrorCode, type ListLeagueScoringPresetsErrorCode,
} from './ListLeagueScoringPresetsUseCase'; } from './ListLeagueScoringPresetsUseCase';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { Result } from '@core/shared/domain/Result'; import type { LeagueScoringPreset } from '../../domain/types/LeagueScoringPreset';
describe('ListLeagueScoringPresetsUseCase', () => { describe('ListLeagueScoringPresetsUseCase', () => {
let useCase: ListLeagueScoringPresetsUseCase; let useCase: ListLeagueScoringPresetsUseCase;
@@ -48,7 +47,7 @@ describe('ListLeagueScoringPresetsUseCase', () => {
}, },
]; ];
useCase = new ListLeagueScoringPresetsUseCase(mockPresets as any); useCase = new ListLeagueScoringPresetsUseCase(mockPresets as unknown as LeagueScoringPreset[]);
}); });
it('should list presets successfully', async () => { it('should list presets successfully', async () => {
@@ -102,7 +101,7 @@ describe('ListLeagueScoringPresetsUseCase', () => {
map: () => { map: () => {
throw new Error('Repository failure'); throw new Error('Repository failure');
}, },
} as any; } as unknown as LeagueScoringPreset[];
useCase = new ListLeagueScoringPresetsUseCase(failingPresets); useCase = new ListLeagueScoringPresetsUseCase(failingPresets);

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { import {
ListSeasonsForLeagueUseCase, ListSeasonsForLeagueUseCase,
type ListSeasonsForLeagueInput, type ListSeasonsForLeagueInput,
type ListSeasonsForLeagueResult,
type ListSeasonsForLeagueErrorCode, type ListSeasonsForLeagueErrorCode,
} from './ListSeasonsForLeagueUseCase'; } from './ListSeasonsForLeagueUseCase';
import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; import type { SeasonRepository } from '../../domain/repositories/SeasonRepository';

View File

@@ -1,8 +1,7 @@
import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { import {
ManageSeasonLifecycleUseCase, ManageSeasonLifecycleUseCase,
type ManageSeasonLifecycleInput, type ManageSeasonLifecycleInput,
type ManageSeasonLifecycleResult,
type ManageSeasonLifecycleErrorCode, type ManageSeasonLifecycleErrorCode,
} from './ManageSeasonLifecycleUseCase'; } from './ManageSeasonLifecycleUseCase';
import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; import type { SeasonRepository } from '../../domain/repositories/SeasonRepository';
@@ -28,8 +27,8 @@ describe('ManageSeasonLifecycleUseCase', () => {
findById: vi.fn(), findById: vi.fn(),
update: vi.fn(), update: vi.fn(),
}; };
useCase = new ManageSeasonLifecycleUseCase(leagueRepository as any, useCase = new ManageSeasonLifecycleUseCase(leagueRepository as unknown as LeagueRepository,
seasonRepository as any); seasonRepository as unknown as SeasonRepository);
}); });
it('applies activate → complete → archive transitions and persists state', async () => { it('applies activate → complete → archive transitions and persists state', async () => {

View File

@@ -58,7 +58,7 @@ export class QuickPenaltyUseCase {
// Validate admin has authority // Validate admin has authority
const memberships = await this.leagueMembershipRepository.getLeagueMembers(race.leagueId); const memberships = await this.leagueMembershipRepository.getLeagueMembers(race.leagueId);
const adminMembership = memberships.find( const adminMembership = memberships.find(
(m: any) => m.driverId.toString() === input.adminId && m.status.toString() === 'active' (m) => m.driverId.toString() === input.adminId && m.status.toString() === 'active'
); );
if (!adminMembership || (adminMembership.role.toString() !== 'owner' && adminMembership.role.toString() !== 'admin')) { if (!adminMembership || (adminMembership.role.toString() !== 'owner' && adminMembership.role.toString() !== 'admin')) {

View File

@@ -7,6 +7,15 @@ import {
type RecalculateChampionshipStandingsErrorCode, type RecalculateChampionshipStandingsErrorCode,
type RecalculateChampionshipStandingsInput type RecalculateChampionshipStandingsInput
} from './RecalculateChampionshipStandingsUseCase'; } from './RecalculateChampionshipStandingsUseCase';
import type { LeagueRepository } from '../../domain/repositories/LeagueRepository';
import type { SeasonRepository } from '../../domain/repositories/SeasonRepository';
import type { LeagueScoringConfigRepository } from '../../domain/repositories/LeagueScoringConfigRepository';
import type { RaceRepository } from '../../domain/repositories/RaceRepository';
import type { ResultRepository } from '../../domain/repositories/ResultRepository';
import type { PenaltyRepository } from '../../domain/repositories/PenaltyRepository';
import type { ChampionshipStandingRepository } from '../../domain/repositories/ChampionshipStandingRepository';
import type { EventScoringService } from '../../domain/services/EventScoringService';
import type { ChampionshipAggregator } from '../../domain/services/ChampionshipAggregator';
describe('RecalculateChampionshipStandingsUseCase', () => { describe('RecalculateChampionshipStandingsUseCase', () => {
let useCase: RecalculateChampionshipStandingsUseCase; let useCase: RecalculateChampionshipStandingsUseCase;
@@ -36,17 +45,17 @@ describe('RecalculateChampionshipStandingsUseCase', () => {
info: vi.fn(), info: vi.fn(),
warn: vi.fn(), warn: vi.fn(),
error: vi.fn(), error: vi.fn(),
} as any; } as unknown as Logger;
useCase = new RecalculateChampionshipStandingsUseCase(leagueRepository as any, useCase = new RecalculateChampionshipStandingsUseCase(leagueRepository as unknown as LeagueRepository,
seasonRepository as any, seasonRepository as unknown as SeasonRepository,
leagueScoringConfigRepository as any, leagueScoringConfigRepository as unknown as LeagueScoringConfigRepository,
raceRepository as any, raceRepository as unknown as RaceRepository,
resultRepository as any, resultRepository as unknown as ResultRepository,
penaltyRepository as any, penaltyRepository as unknown as PenaltyRepository,
championshipStandingRepository as any, championshipStandingRepository as unknown as ChampionshipStandingRepository,
eventScoringService as any, eventScoringService as unknown as EventScoringService,
championshipAggregator as any, championshipAggregator as unknown as ChampionshipAggregator,
logger); logger);
}); });

View File

@@ -5,7 +5,7 @@ import { TeamRatingEvent } from '@core/racing/domain/entities/TeamRatingEvent';
import { TeamRatingEventId } from '@core/racing/domain/value-objects/TeamRatingEventId'; import { TeamRatingEventId } from '@core/racing/domain/value-objects/TeamRatingEventId';
import { TeamRatingDimensionKey } from '@core/racing/domain/value-objects/TeamRatingDimensionKey'; import { TeamRatingDimensionKey } from '@core/racing/domain/value-objects/TeamRatingDimensionKey';
import { TeamRatingDelta } from '@core/racing/domain/value-objects/TeamRatingDelta'; import { TeamRatingDelta } from '@core/racing/domain/value-objects/TeamRatingDelta';
import { TeamRating } from '../../domain/entities/TeamRating'; import { TeamRating } from '../../domain/value-objects/TeamRating';
// Mock repositories // Mock repositories
class MockTeamRatingEventRepository implements TeamRatingEventRepository { class MockTeamRatingEventRepository implements TeamRatingEventRepository {
@@ -28,7 +28,7 @@ class MockTeamRatingEventRepository implements TeamRatingEventRepository {
return this.events.filter(e => e.teamId === teamId); return this.events.filter(e => e.teamId === teamId);
} }
async findEventsPaginated(teamId: string): Promise<any> { async findEventsPaginated(teamId: string): Promise<PaginatedResult<TeamRatingEvent>> {
const events = await this.getAllByTeamId(teamId); const events = await this.getAllByTeamId(teamId);
return { return {
items: events, items: events,

View File

@@ -6,14 +6,14 @@ import { AppendTeamRatingEventsUseCase } from './AppendTeamRatingEventsUseCase';
import { TeamDrivingRaceFactsDto } from '@core/racing/domain/services/TeamDrivingRatingEventFactory'; import { TeamDrivingRaceFactsDto } from '@core/racing/domain/services/TeamDrivingRatingEventFactory';
import { TeamRatingEvent } from '@core/racing/domain/entities/TeamRatingEvent'; import { TeamRatingEvent } from '@core/racing/domain/entities/TeamRatingEvent';
import { TeamRatingEventId } from '@core/racing/domain/value-objects/TeamRatingEventId'; import { TeamRatingEventId } from '@core/racing/domain/value-objects/TeamRatingEventId';
import { TeamRating } from '../../domain/entities/TeamRating'; import { TeamRating } from '../../domain/value-objects/TeamRating';
import { describe, it, expect, beforeEach, afterEach } from 'vitest'; import { describe, it, expect, beforeEach, afterEach } from 'vitest';
// Mock repositories // Mock repositories
class MockTeamRaceResultsProvider implements TeamRaceResultsProvider { class MockTeamRaceResultsProvider implements TeamRaceResultsProvider {
private results: TeamDrivingRaceFactsDto | null = null; private results: TeamDrivingRaceFactsDto | null = null;
async getTeamRaceResults(_raceId: string): Promise<TeamDrivingRaceFactsDto | null> { async getTeamRaceResults(): Promise<TeamDrivingRaceFactsDto | null> {
return this.results; return this.results;
} }
@@ -42,7 +42,7 @@ class MockTeamRatingEventRepository implements TeamRatingEventRepository {
return this.events.filter(e => e.teamId === teamId); return this.events.filter(e => e.teamId === teamId);
} }
async findEventsPaginated(teamId: string): Promise<any> { async findEventsPaginated(teamId: string): Promise<PaginatedResult<TeamRatingEvent>> {
const events = await this.getAllByTeamId(teamId); const events = await this.getAllByTeamId(teamId);
return { return {
items: events, items: events,
@@ -319,7 +319,6 @@ describe('RecordTeamRaceRatingEventsUseCase', () => {
mockResultsProvider.setResults(raceResults); mockResultsProvider.setResults(raceResults);
// Mock repository to throw error // Mock repository to throw error
const originalSave = mockEventRepo.save.bind(mockEventRepo);
mockEventRepo.save = async () => { mockEventRepo.save = async () => {
throw new Error('Repository error'); throw new Error('Repository error');
}; };

View File

@@ -19,10 +19,6 @@ describe('RejectLeagueJoinRequestUseCase', () => {
}); });
it('reject removes request only', async () => { it('reject removes request only', async () => {
const output: { present: Mock } = {
present: vi.fn(),
};
const useCase = new RejectLeagueJoinRequestUseCase(leagueMembershipRepository as unknown as LeagueMembershipRepository); const useCase = new RejectLeagueJoinRequestUseCase(leagueMembershipRepository as unknown as LeagueMembershipRepository);
leagueMembershipRepository.getJoinRequests.mockResolvedValue([ leagueMembershipRepository.getJoinRequests.mockResolvedValue([
@@ -38,10 +34,6 @@ describe('RejectLeagueJoinRequestUseCase', () => {
}); });
it('reject returns error when request missing', async () => { it('reject returns error when request missing', async () => {
const output: { present: Mock } = {
present: vi.fn(),
};
const useCase = new RejectLeagueJoinRequestUseCase(leagueMembershipRepository as unknown as LeagueMembershipRepository); const useCase = new RejectLeagueJoinRequestUseCase(leagueMembershipRepository as unknown as LeagueMembershipRepository);
leagueMembershipRepository.getJoinRequests.mockResolvedValue([]); leagueMembershipRepository.getJoinRequests.mockResolvedValue([]);

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
import { import {
RemoveLeagueMemberUseCase, RemoveLeagueMemberUseCase,
type RemoveLeagueMemberInput, type RemoveLeagueMemberInput,
type RemoveLeagueMemberResult,
type RemoveLeagueMemberErrorCode, type RemoveLeagueMemberErrorCode,
} from './RemoveLeagueMemberUseCase'; } from './RemoveLeagueMemberUseCase';
import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository';

View File

@@ -7,6 +7,8 @@ import {
type ReopenRaceErrorCode, type ReopenRaceErrorCode,
type ReopenRaceInput type ReopenRaceInput
} from './ReopenRaceUseCase'; } from './ReopenRaceUseCase';
import type { RaceRepository } from '../../domain/repositories/RaceRepository';
import type { Logger } from '@core/shared/domain/Logger';
describe('ReopenRaceUseCase', () => { describe('ReopenRaceUseCase', () => {
let raceRepository: { let raceRepository: {
@@ -34,8 +36,8 @@ describe('ReopenRaceUseCase', () => {
error: vi.fn(), error: vi.fn(),
}; };
useCase = new ReopenRaceUseCase(raceRepository as any, useCase = new ReopenRaceUseCase(raceRepository as unknown as RaceRepository,
logger as any); logger as unknown as Logger);
}); });
it('returns RACE_NOT_FOUND when race does not exist', async () => { it('returns RACE_NOT_FOUND when race does not exist', async () => {

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import { import {
RequestProtestDefenseUseCase, RequestProtestDefenseUseCase,
type RequestProtestDefenseInput, type RequestProtestDefenseInput,
type RequestProtestDefenseResult,
type RequestProtestDefenseErrorCode, type RequestProtestDefenseErrorCode,
} from './RequestProtestDefenseUseCase'; } from './RequestProtestDefenseUseCase';
import type { ProtestRepository } from '../../domain/repositories/ProtestRepository'; import type { ProtestRepository } from '../../domain/repositories/ProtestRepository';

View File

@@ -1,5 +1,5 @@
import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
import { ReviewProtestUseCase, type ReviewProtestInput, type ReviewProtestResult, type ReviewProtestErrorCode } from './ReviewProtestUseCase'; import { ReviewProtestUseCase, type ReviewProtestInput, type ReviewProtestErrorCode } from './ReviewProtestUseCase';
import type { ProtestRepository } from '../../domain/repositories/ProtestRepository'; import type { ProtestRepository } from '../../domain/repositories/ProtestRepository';
import type { RaceRepository } from '../../domain/repositories/RaceRepository'; import type { RaceRepository } from '../../domain/repositories/RaceRepository';
import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository';

View File

@@ -2,7 +2,6 @@ import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest';
import { import {
SendFinalResultsUseCase, SendFinalResultsUseCase,
type SendFinalResultsInput, type SendFinalResultsInput,
type SendFinalResultsResult,
type SendFinalResultsErrorCode, type SendFinalResultsErrorCode,
} from './SendFinalResultsUseCase'; } from './SendFinalResultsUseCase';
import type { NotificationService } from '../../../notifications/application/ports/NotificationService'; import type { NotificationService } from '../../../notifications/application/ports/NotificationService';

View File

@@ -2,7 +2,6 @@ import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest';
import { import {
SendPerformanceSummaryUseCase, SendPerformanceSummaryUseCase,
type SendPerformanceSummaryInput, type SendPerformanceSummaryInput,
type SendPerformanceSummaryResult,
type SendPerformanceSummaryErrorCode, type SendPerformanceSummaryErrorCode,
} from './SendPerformanceSummaryUseCase'; } from './SendPerformanceSummaryUseCase';
import type { NotificationService } from '../../../notifications/application/ports/NotificationService'; import type { NotificationService } from '../../../notifications/application/ports/NotificationService';

View File

@@ -8,6 +8,8 @@ import {
type SubmitProtestDefenseInput, type SubmitProtestDefenseInput,
type SubmitProtestDefenseResult, type SubmitProtestDefenseResult,
} from './SubmitProtestDefenseUseCase'; } from './SubmitProtestDefenseUseCase';
import type { LeagueRepository } from '../../domain/repositories/LeagueRepository';
import type { ProtestRepository } from '../../domain/repositories/ProtestRepository';
interface MockProtest { interface MockProtest {
id: string; id: string;

View File

@@ -7,7 +7,7 @@ import { TeamRatingFactoryUseCase } from './TeamRatingFactoryUseCase';
class MockTeamRaceResultsProvider implements TeamRaceResultsProvider { class MockTeamRaceResultsProvider implements TeamRaceResultsProvider {
private results: TeamDrivingRaceFactsDto | null = null; private results: TeamDrivingRaceFactsDto | null = null;
async getTeamRaceResults(_raceId: string): Promise<TeamDrivingRaceFactsDto | null> { async getTeamRaceResults(): Promise<TeamDrivingRaceFactsDto | null> {
return this.results; return this.results;
} }

View File

@@ -5,14 +5,12 @@ import { TeamRatingRepository } from '@core/racing/domain/repositories/TeamRatin
import { TeamDrivingRaceFactsDto } from '@core/racing/domain/services/TeamDrivingRatingEventFactory'; import { TeamDrivingRaceFactsDto } from '@core/racing/domain/services/TeamDrivingRatingEventFactory';
import { TeamRatingEvent } from '@core/racing/domain/entities/TeamRatingEvent'; import { TeamRatingEvent } from '@core/racing/domain/entities/TeamRatingEvent';
import { TeamRatingEventId } from '@core/racing/domain/value-objects/TeamRatingEventId'; import { TeamRatingEventId } from '@core/racing/domain/value-objects/TeamRatingEventId';
import { TeamRatingDimensionKey } from '@core/racing/domain/value-objects/TeamRatingDimensionKey';
import { TeamRatingDelta } from '@core/racing/domain/value-objects/TeamRatingDelta';
// Mock repositories // Mock repositories
class MockTeamRaceResultsProvider implements TeamRaceResultsProvider { class MockTeamRaceResultsProvider implements TeamRaceResultsProvider {
private results: TeamDrivingRaceFactsDto | null = null; private results: TeamDrivingRaceFactsDto | null = null;
async getTeamRaceResults(raceId: string): Promise<TeamDrivingRaceFactsDto | null> { async getTeamRaceResults(): Promise<TeamDrivingRaceFactsDto | null> {
return this.results; return this.results;
} }
@@ -41,7 +39,7 @@ class MockTeamRatingEventRepository implements TeamRatingEventRepository {
return this.events.filter(e => e.teamId === teamId); return this.events.filter(e => e.teamId === teamId);
} }
async findEventsPaginated(teamId: string): Promise<any> { async findEventsPaginated(teamId: string): Promise<PaginatedResult<TeamRatingEvent>> {
const events = await this.getAllByTeamId(teamId); const events = await this.getAllByTeamId(teamId);
return { return {
items: events, items: events,
@@ -58,13 +56,13 @@ class MockTeamRatingEventRepository implements TeamRatingEventRepository {
} }
class MockTeamRatingRepository implements TeamRatingRepository { class MockTeamRatingRepository implements TeamRatingRepository {
private snapshots: Map<string, any> = new Map(); private snapshots: Map<string, TeamRating> = new Map();
async findByTeamId(teamId: string): Promise<any | null> { async findByTeamId(teamId: string): Promise<TeamRating | null> {
return this.snapshots.get(teamId) || null; return this.snapshots.get(teamId) || null;
} }
async save(snapshot: any): Promise<any> { async save(snapshot: TeamRating): Promise<TeamRating> {
this.snapshots.set(snapshot.teamId, snapshot); this.snapshots.set(snapshot.teamId, snapshot);
return snapshot; return snapshot;
} }
@@ -202,7 +200,6 @@ describe('TeamRatingIntegrationAdapter', () => {
mockResultsProvider.setResults(raceResults); mockResultsProvider.setResults(raceResults);
// Mock repository to throw error // Mock repository to throw error
const originalSave = mockEventRepo.save.bind(mockEventRepo);
mockEventRepo.save = async () => { mockEventRepo.save = async () => {
throw new Error('Repository error'); throw new Error('Repository error');
}; };
@@ -276,12 +273,11 @@ describe('TeamRatingIntegrationAdapter', () => {
mockResultsProvider.setResults(raceResults); mockResultsProvider.setResults(raceResults);
// Mock repository to fail for team-456 // Mock repository to fail for team-456
const originalSave = mockEventRepo.save.bind(mockEventRepo);
mockEventRepo.save = async (event) => { mockEventRepo.save = async (event) => {
if (event.teamId === 'team-456') { if (event.teamId === 'team-456') {
throw new Error('Simulated failure'); throw new Error('Simulated failure');
} }
return originalSave(event); return event;
}; };
const result = await adapter.recordTeamRatingsWithDetails('race-123'); const result = await adapter.recordTeamRatingsWithDetails('race-123');

View File

@@ -6,10 +6,20 @@ import {
type TransferLeagueOwnershipErrorCode, type TransferLeagueOwnershipErrorCode,
type TransferLeagueOwnershipInput type TransferLeagueOwnershipInput
} from './TransferLeagueOwnershipUseCase'; } from './TransferLeagueOwnershipUseCase';
import type { LeagueRepository } from '../../domain/repositories/LeagueRepository';
import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository';
import type { League } from '../../domain/entities/League';
import type { LeagueMembership } from '../../domain/entities/LeagueMembership';
describe('TransferLeagueOwnershipUseCase', () => { describe('TransferLeagueOwnershipUseCase', () => {
let leagueRepository: any; let leagueRepository: {
let membershipRepository: any; findById: Mock;
update: Mock;
};
let membershipRepository: {
getMembership: Mock;
saveMembership: Mock;
};
let logger: Logger & { error: Mock }; let logger: Logger & { error: Mock };
let useCase: TransferLeagueOwnershipUseCase; let useCase: TransferLeagueOwnershipUseCase;
@@ -29,11 +39,11 @@ describe('TransferLeagueOwnershipUseCase', () => {
info: vi.fn(), info: vi.fn(),
warn: vi.fn(), warn: vi.fn(),
error: vi.fn(), error: vi.fn(),
} as any; } as unknown as Logger & { error: Mock };
useCase = new TransferLeagueOwnershipUseCase( useCase = new TransferLeagueOwnershipUseCase(
leagueRepository, leagueRepository as unknown as LeagueRepository,
membershipRepository, membershipRepository as unknown as LeagueMembershipRepository,
logger, logger,
); );
}); });
@@ -43,21 +53,21 @@ describe('TransferLeagueOwnershipUseCase', () => {
id: 'league-1', id: 'league-1',
ownerId: { toString: () => 'owner-1' }, ownerId: { toString: () => 'owner-1' },
update: vi.fn().mockReturnValue({}), update: vi.fn().mockReturnValue({}),
} as any; } as unknown as League;
const mockNewOwnerMembership = { const mockNewOwnerMembership = {
leagueId: 'league-1', leagueId: 'league-1',
driverId: 'owner-2', driverId: 'owner-2',
status: { toString: () => 'active' }, status: { toString: () => 'active' },
role: 'member', role: 'member',
} as any; } as unknown as LeagueMembership;
const mockCurrentOwnerMembership = { const mockCurrentOwnerMembership = {
leagueId: 'league-1', leagueId: 'league-1',
driverId: 'owner-1', driverId: 'owner-1',
status: { toString: () => 'active' }, status: { toString: () => 'active' },
role: 'owner', role: 'owner',
} as any; } as unknown as LeagueMembership;
leagueRepository.findById.mockResolvedValue(mockLeague); leagueRepository.findById.mockResolvedValue(mockLeague);
@@ -124,7 +134,7 @@ describe('TransferLeagueOwnershipUseCase', () => {
id: 'league-1', id: 'league-1',
ownerId: { toString: () => 'other-owner' }, ownerId: { toString: () => 'other-owner' },
update: vi.fn(), update: vi.fn(),
} as any; } as unknown as League;
leagueRepository.findById.mockResolvedValue(mockLeague); leagueRepository.findById.mockResolvedValue(mockLeague);
@@ -150,7 +160,7 @@ describe('TransferLeagueOwnershipUseCase', () => {
id: 'league-1', id: 'league-1',
ownerId: { toString: () => 'owner-1' }, ownerId: { toString: () => 'owner-1' },
update: vi.fn(), update: vi.fn(),
} as any; } as unknown as League;
leagueRepository.findById.mockResolvedValue(mockLeague); leagueRepository.findById.mockResolvedValue(mockLeague);
@@ -178,7 +188,7 @@ describe('TransferLeagueOwnershipUseCase', () => {
id: 'league-1', id: 'league-1',
ownerId: { toString: () => 'owner-1' }, ownerId: { toString: () => 'owner-1' },
update: vi.fn().mockReturnValue({}), update: vi.fn().mockReturnValue({}),
} as any; } as unknown as League;
leagueRepository.findById.mockResolvedValue(mockLeague); leagueRepository.findById.mockResolvedValue(mockLeague);
@@ -187,7 +197,7 @@ describe('TransferLeagueOwnershipUseCase', () => {
driverId: 'owner-2', driverId: 'owner-2',
status: { toString: () => 'active' }, status: { toString: () => 'active' },
role: 'member', role: 'member',
} as any; } as unknown as LeagueMembership;
membershipRepository.getMembership membershipRepository.getMembership
.mockResolvedValueOnce(mockNewOwnerMembership) .mockResolvedValueOnce(mockNewOwnerMembership)

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
import { import {
UpdateDriverProfileUseCase, UpdateDriverProfileUseCase,
type UpdateDriverProfileInput, type UpdateDriverProfileInput,
type UpdateDriverProfileResult,
type UpdateDriverProfileErrorCode, type UpdateDriverProfileErrorCode,
} from './UpdateDriverProfileUseCase'; } from './UpdateDriverProfileUseCase';
import type { DriverRepository } from '../../domain/repositories/DriverRepository'; import type { DriverRepository } from '../../domain/repositories/DriverRepository';

View File

@@ -48,9 +48,10 @@ describe('UpdateLeagueMemberRoleUseCase', () => {
it('returns error if membership not found', async () => { it('returns error if membership not found', async () => {
const mockLeagueMembershipRepository = { const mockLeagueMembershipRepository = {
getLeagueMembers: vi.fn().mockResolvedValue([]), getLeagueMembers: vi.fn().mockResolvedValue([]),
} as any; saveMembership: vi.fn(),
};
const useCase = new UpdateLeagueMemberRoleUseCase(mockLeagueMembershipRepository); const useCase = new UpdateLeagueMemberRoleUseCase(mockLeagueMembershipRepository as unknown as LeagueMembershipRepository);
const input: UpdateLeagueMemberRoleInput = { const input: UpdateLeagueMemberRoleInput = {
leagueId: 'league-1', leagueId: 'league-1',
@@ -75,9 +76,10 @@ describe('UpdateLeagueMemberRoleUseCase', () => {
getLeagueMembers: vi getLeagueMembers: vi
.fn() .fn()
.mockRejectedValue(new Error('Database connection failed')), .mockRejectedValue(new Error('Database connection failed')),
} as any; saveMembership: vi.fn(),
};
const useCase = new UpdateLeagueMemberRoleUseCase(mockLeagueMembershipRepository); const useCase = new UpdateLeagueMemberRoleUseCase(mockLeagueMembershipRepository as unknown as LeagueMembershipRepository);
const input: UpdateLeagueMemberRoleInput = { const input: UpdateLeagueMemberRoleInput = {
leagueId: 'league-1', leagueId: 'league-1',
@@ -110,14 +112,14 @@ describe('UpdateLeagueMemberRoleUseCase', () => {
const mockLeagueMembershipRepository = { const mockLeagueMembershipRepository = {
getLeagueMembers: vi.fn().mockResolvedValue([mockMembership]), getLeagueMembers: vi.fn().mockResolvedValue([mockMembership]),
saveMembership: vi.fn().mockResolvedValue(undefined), saveMembership: vi.fn().mockResolvedValue(undefined),
} as any; };
const useCase = new UpdateLeagueMemberRoleUseCase(mockLeagueMembershipRepository); const useCase = new UpdateLeagueMemberRoleUseCase(mockLeagueMembershipRepository as unknown as LeagueMembershipRepository);
const result = await useCase.execute({ const result = await useCase.execute({
leagueId: 'league-1', leagueId: 'league-1',
targetDriverId: 'driver-1', targetDriverId: 'driver-1',
newRole: 'manager' as any, newRole: 'manager' as unknown as 'member',
}); });
expect(result.isErr()).toBe(true); expect(result.isErr()).toBe(true);
@@ -143,9 +145,9 @@ describe('UpdateLeagueMemberRoleUseCase', () => {
const mockLeagueMembershipRepository = { const mockLeagueMembershipRepository = {
getLeagueMembers: vi.fn().mockResolvedValue([mockOwnerMembership]), getLeagueMembers: vi.fn().mockResolvedValue([mockOwnerMembership]),
saveMembership: vi.fn().mockResolvedValue(undefined), saveMembership: vi.fn().mockResolvedValue(undefined),
} as any; };
const useCase = new UpdateLeagueMemberRoleUseCase(mockLeagueMembershipRepository); const useCase = new UpdateLeagueMemberRoleUseCase(mockLeagueMembershipRepository as unknown as LeagueMembershipRepository);
const result = await useCase.execute({ const result = await useCase.execute({
leagueId: 'league-1', leagueId: 'league-1',

View File

@@ -1,5 +1,5 @@
import { describe, it, expect, vi } from 'vitest'; import { describe, it, expect, vi } from 'vitest';
import { UpdateTeamUseCase, type UpdateTeamInput, type UpdateTeamResult, type UpdateTeamErrorCode } from './UpdateTeamUseCase'; import { UpdateTeamUseCase, type UpdateTeamInput, type UpdateTeamErrorCode } from './UpdateTeamUseCase';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { TeamRepository } from '../../domain/repositories/TeamRepository'; import type { TeamRepository } from '../../domain/repositories/TeamRepository';
import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository';
@@ -54,11 +54,6 @@ describe('UpdateTeamUseCase', () => {
getMembership: vi.fn().mockResolvedValue(mockMembership), getMembership: vi.fn().mockResolvedValue(mockMembership),
} as unknown as TeamMembershipRepository; } as unknown as TeamMembershipRepository;
const present = vi.fn<(data: UpdateTeamResult) => void>();
const output: { present: typeof present } = {
present,
};
const useCase = new UpdateTeamUseCase({} as unknown as TeamRepository, mockMembershipRepository); const useCase = new UpdateTeamUseCase({} as unknown as TeamRepository, mockMembershipRepository);
const command: UpdateTeamInput = { const command: UpdateTeamInput = {

View File

@@ -207,7 +207,7 @@ describe('WithdrawFromLeagueWalletUseCase', () => {
const presented = result.unwrap(); const presented = result.unwrap();
expect(transactionRepository.create).toHaveBeenCalledTimes(1); expect(transactionRepository.create).toHaveBeenCalledTimes(1);
const createdTx = (transactionRepository.create as Mock).mock.calls[0]![0] as any; const createdTx = (transactionRepository.create as Mock).mock.calls[0]![0] as Transaction;
const expectedTransactionId = `txn-${new Date('2025-01-01T00:00:00.000Z').getTime()}`; const expectedTransactionId = `txn-${new Date('2025-01-01T00:00:00.000Z').getTime()}`;

View File

@@ -1,11 +1,12 @@
import { TeamRatingEvent } from './TeamRatingEvent'; import { describe, it, expect } from 'vitest';
import { TeamRatingEvent, type TeamRatingEventProps } from './TeamRatingEvent';
import { TeamRatingEventId } from '../value-objects/TeamRatingEventId'; import { TeamRatingEventId } from '../value-objects/TeamRatingEventId';
import { TeamRatingDimensionKey } from '../value-objects/TeamRatingDimensionKey'; import { TeamRatingDimensionKey } from '../value-objects/TeamRatingDimensionKey';
import { TeamRatingDelta } from '../value-objects/TeamRatingDelta'; import { TeamRatingDelta } from '../value-objects/TeamRatingDelta';
import { RacingDomainValidationError, RacingDomainInvariantError } from '../errors/RacingDomainError'; import { RacingDomainValidationError, RacingDomainInvariantError } from '../errors/RacingDomainError';
describe('TeamRatingEvent', () => { describe('TeamRatingEvent', () => {
const validProps = { const validProps: TeamRatingEventProps = {
id: TeamRatingEventId.create('123e4567-e89b-12d3-a456-426614174000'), id: TeamRatingEventId.create('123e4567-e89b-12d3-a456-426614174000'),
teamId: 'team-123', teamId: 'team-123',
dimension: TeamRatingDimensionKey.create('driving'), dimension: TeamRatingDimensionKey.create('driving'),
@@ -47,28 +48,43 @@ describe('TeamRatingEvent', () => {
}); });
it('should throw for missing dimension', () => { it('should throw for missing dimension', () => {
const { dimension: _, ...rest } = validProps; const props = { ...validProps };
expect(() => TeamRatingEvent.create(rest as typeof validProps)).toThrow(RacingDomainValidationError); // @ts-expect-error - testing validation
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete (props as any).dimension;
expect(() => TeamRatingEvent.create(props as unknown as TeamRatingEventProps)).toThrow(RacingDomainValidationError);
}); });
it('should throw for missing delta', () => { it('should throw for missing delta', () => {
const { delta: _, ...rest } = validProps; const props = { ...validProps };
expect(() => TeamRatingEvent.create(rest as typeof validProps)).toThrow(RacingDomainValidationError); // @ts-expect-error - testing validation
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete (props as any).delta;
expect(() => TeamRatingEvent.create(props as unknown as TeamRatingEventProps)).toThrow(RacingDomainValidationError);
}); });
it('should throw for missing source', () => { it('should throw for missing source', () => {
const { source: _, ...rest } = validProps; const props = { ...validProps };
expect(() => TeamRatingEvent.create(rest as typeof validProps)).toThrow(RacingDomainValidationError); // @ts-expect-error - testing validation
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete (props as any).source;
expect(() => TeamRatingEvent.create(props as unknown as TeamRatingEventProps)).toThrow(RacingDomainValidationError);
}); });
it('should throw for missing reason', () => { it('should throw for missing reason', () => {
const { reason: _, ...rest } = validProps; const props = { ...validProps };
expect(() => TeamRatingEvent.create(rest as typeof validProps)).toThrow(RacingDomainValidationError); // @ts-expect-error - testing validation
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete (props as any).reason;
expect(() => TeamRatingEvent.create(props as unknown as TeamRatingEventProps)).toThrow(RacingDomainValidationError);
}); });
it('should throw for missing visibility', () => { it('should throw for missing visibility', () => {
const { visibility: _, ...rest } = validProps; const props = { ...validProps };
expect(() => TeamRatingEvent.create(rest as typeof validProps)).toThrow(RacingDomainValidationError); // @ts-expect-error - testing validation
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete (props as any).visibility;
expect(() => TeamRatingEvent.create(props as unknown as TeamRatingEventProps)).toThrow(RacingDomainValidationError);
}); });
it('should throw for invalid weight', () => { it('should throw for invalid weight', () => {

View File

@@ -6,6 +6,7 @@ import {
type GetUserFeedApplicationError, type GetUserFeedApplicationError,
type GetUserFeedInput, type GetUserFeedInput,
} from './GetUserFeedUseCase'; } from './GetUserFeedUseCase';
import type { FeedRepository } from '../../domain/repositories/FeedRepository';
describe('GetUserFeedUseCase', () => { describe('GetUserFeedUseCase', () => {
let feedRepository: FeedRepository & { getFeedForDriver: Mock }; let feedRepository: FeedRepository & { getFeedForDriver: Mock };

5
core/tsconfig.all.json Normal file
View File

@@ -0,0 +1,5 @@
{
"extends": "./tsconfig.json",
"include": ["**/*.ts"],
"exclude": ["node_modules", "dist"]
}