website refactor

This commit is contained in:
2026-01-16 18:21:06 +01:00
parent 2f53727702
commit 095885544b
146 changed files with 970 additions and 524 deletions

View File

@@ -3,7 +3,8 @@ import { beforeEach, describe, expect, it, Mock, vi } from 'vitest';
import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository';
import type { ProtestRepository } from '../../domain/repositories/ProtestRepository';
import type { RaceRepository } from '../../domain/repositories/RaceRepository';
import { FileProtestUseCase, type FileProtestErrorCode, type FileProtestInput, type FileProtestResult } from './FileProtestUseCase';
import { FileProtestUseCase, type FileProtestErrorCode, type FileProtestInput } from './FileProtestUseCase';
import { Protest } from '../../domain/entities/Protest';
describe('FileProtestUseCase', () => {
let mockProtestRepo: {
@@ -29,9 +30,11 @@ describe('FileProtestUseCase', () => {
});
it('should return error when race does not exist', async () => {
const useCase = new FileProtestUseCase(mockProtestRepo as any,
mockRaceRepo as any,
mockLeagueMembershipRepo as any);
const useCase = new FileProtestUseCase(
mockProtestRepo as unknown as ProtestRepository,
mockRaceRepo as unknown as RaceRepository,
mockLeagueMembershipRepo as unknown as LeagueMembershipRepository
);
mockRaceRepo.findById.mockResolvedValue(null);
@@ -49,9 +52,11 @@ describe('FileProtestUseCase', () => {
});
it('should return error when protesting against self', async () => {
const useCase = new FileProtestUseCase(mockProtestRepo as any,
mockRaceRepo as any,
mockLeagueMembershipRepo as any);
const useCase = new FileProtestUseCase(
mockProtestRepo as unknown as ProtestRepository,
mockRaceRepo as unknown as RaceRepository,
mockLeagueMembershipRepo as unknown as LeagueMembershipRepository
);
mockRaceRepo.findById.mockResolvedValue({ id: 'race1', leagueId: 'league1' });
@@ -69,9 +74,11 @@ describe('FileProtestUseCase', () => {
});
it('should return error when protesting driver is not an active member', async () => {
const useCase = new FileProtestUseCase(mockProtestRepo as any,
mockRaceRepo as any,
mockLeagueMembershipRepo as any);
const useCase = new FileProtestUseCase(
mockProtestRepo as unknown as ProtestRepository,
mockRaceRepo as unknown as RaceRepository,
mockLeagueMembershipRepo as unknown as LeagueMembershipRepository
);
mockRaceRepo.findById.mockResolvedValue({ id: 'race1', leagueId: 'league1' });
mockLeagueMembershipRepo.getLeagueMembers.mockResolvedValue([
@@ -92,9 +99,11 @@ describe('FileProtestUseCase', () => {
});
it('should create protest and return protestId on success', async () => {
const useCase = new FileProtestUseCase(mockProtestRepo as any,
mockRaceRepo as any,
mockLeagueMembershipRepo as any);
const useCase = new FileProtestUseCase(
mockProtestRepo as unknown as ProtestRepository,
mockRaceRepo as unknown as RaceRepository,
mockLeagueMembershipRepo as unknown as LeagueMembershipRepository
);
mockRaceRepo.findById.mockResolvedValue({ id: 'race1', leagueId: 'league1' });
mockLeagueMembershipRepo.getLeagueMembers.mockResolvedValue([
@@ -114,7 +123,7 @@ describe('FileProtestUseCase', () => {
expect(result.isOk()).toBe(true);
const presented = result.unwrap();
expect(mockProtestRepo.create).toHaveBeenCalledTimes(1);
const created = (mockProtestRepo.create as unknown as Mock).mock.calls[0]?.[0] as any;
const created = (mockProtestRepo.create as unknown as Mock).mock.calls[0]?.[0] as Protest;
expect(created.raceId.toString()).toBe('race1');
expect(created.protestingDriverId.toString()).toBe('driver1');