website refactor

This commit is contained in:
2026-01-16 15:20:25 +01:00
parent 7e02fc3ea5
commit 37b1aa626c
325 changed files with 2167 additions and 2782 deletions

View File

@@ -1,15 +1,12 @@
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest';
import {
ReopenRaceUseCase,
type ReopenRaceInput,
type ReopenRaceResult,
type ReopenRaceErrorCode,
} from './ReopenRaceUseCase';
import type { RaceRepository } from '../../domain/repositories/RaceRepository';
import type { Logger } from '@core/shared/application';
import { Race } from '../../domain/entities/Race';
import { SessionType } from '../../domain/value-objects/SessionType';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import {
ReopenRaceUseCase,
type ReopenRaceErrorCode,
type ReopenRaceInput
} from './ReopenRaceUseCase';
describe('ReopenRaceUseCase', () => {
let raceRepository: {
@@ -37,8 +34,8 @@ describe('ReopenRaceUseCase', () => {
error: vi.fn(),
};
useCase = new ReopenRaceUseCase(raceRepository as unknown as IRaceRepository,
logger as unknown as Logger);
useCase = new ReopenRaceUseCase(raceRepository as any,
logger as any);
});
it('returns RACE_NOT_FOUND when race does not exist', async () => {
@@ -55,9 +52,9 @@ describe('ReopenRaceUseCase', () => {
>;
expect(err.code).toBe('RACE_NOT_FOUND');
expect(err.details.message).toContain('race-404');
});
});
it('reopens a completed race, persists, and presents the result', async () => {
it('reopens a completed race, persists, and returns the result', async () => {
const race = Race.create({
id: 'race-1',
leagueId: 'league-1',
@@ -81,7 +78,8 @@ describe('ReopenRaceUseCase', () => {
expect(updatedRace.id).toBe('race-1');
expect(updatedRace.status.toString()).toBe('scheduled');
const presented = (expect(presented.race.id).toBe('race-1');
const presented = result.unwrap();
expect(presented.race.id).toBe('race-1');
expect(presented.race.status.toString()).toBe('scheduled');
expect(logger.info).toHaveBeenCalled();
@@ -110,7 +108,7 @@ describe('ReopenRaceUseCase', () => {
>;
expect(err.code).toBe('INVALID_RACE_STATE');
expect(err.details.message).toContain('already scheduled');
});
});
it('returns INVALID_RACE_STATE when race is running', async () => {
const race = Race.create({
@@ -135,7 +133,7 @@ describe('ReopenRaceUseCase', () => {
>;
expect(err.code).toBe('INVALID_RACE_STATE');
expect(err.details.message).toContain('running race');
});
});
it('returns REPOSITORY_ERROR when repository throws unexpected error', async () => {
raceRepository.findById.mockRejectedValue(new Error('DB error'));
@@ -150,5 +148,5 @@ describe('ReopenRaceUseCase', () => {
>;
expect(err.code).toBe('REPOSITORY_ERROR');
expect(err.details.message).toBe('DB error');
});
});
});
});