fix issues
This commit is contained in:
@@ -38,7 +38,8 @@ export class CloseRaceEventStewardingUseCase {
|
||||
private readonly output: UseCaseOutputPort<CloseRaceEventStewardingResult>,
|
||||
) {}
|
||||
|
||||
async execute(_: CloseRaceEventStewardingInput): Promise<Result<void, ApplicationErrorCode<'RACE_NOT_FOUND' | 'STEWARDING_ALREADY_CLOSED' | 'REPOSITORY_ERROR'>>> {
|
||||
async execute(input: CloseRaceEventStewardingInput): Promise<Result<void, ApplicationErrorCode<'RACE_NOT_FOUND' | 'STEWARDING_ALREADY_CLOSED' | 'REPOSITORY_ERROR'>>> {
|
||||
void input;
|
||||
try {
|
||||
// Find all race events awaiting stewarding that have expired windows
|
||||
const expiredEvents = await this.raceEventRepository.findAwaitingStewardingClose();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
|
||||
import { describe, it, expect, beforeEach, afterEach, vi, Mock } from 'vitest';
|
||||
import {
|
||||
CompleteDriverOnboardingUseCase,
|
||||
type CompleteDriverOnboardingInput,
|
||||
@@ -19,6 +19,8 @@ describe('CompleteDriverOnboardingUseCase', () => {
|
||||
let output: { present: Mock } & UseCaseOutputPort<CompleteDriverOnboardingResult>;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date('2020-01-01T00:00:00.000Z'));
|
||||
driverRepository = {
|
||||
findById: vi.fn(),
|
||||
create: vi.fn(),
|
||||
@@ -36,6 +38,10 @@ describe('CompleteDriverOnboardingUseCase', () => {
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('should create driver successfully when driver does not exist', async () => {
|
||||
const command: CompleteDriverOnboardingInput = {
|
||||
userId: 'user-1',
|
||||
|
||||
@@ -950,7 +950,7 @@ describe('DashboardOverviewUseCase', () => {
|
||||
// Mock output port to capture presented data
|
||||
const outputPort: UseCaseOutputPort<DashboardOverviewResult> = {
|
||||
present: (_data: DashboardOverviewResult) => {
|
||||
// No-op
|
||||
void _data;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1141,7 +1141,7 @@ describe('DashboardOverviewUseCase', () => {
|
||||
// Mock output port to capture presented data
|
||||
const outputPort: UseCaseOutputPort<DashboardOverviewResult> = {
|
||||
present: (_data: DashboardOverviewResult) => {
|
||||
// No-op
|
||||
void _data;
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ export class GetAllLeaguesWithCapacityAndScoringUseCase {
|
||||
>
|
||||
>
|
||||
> {
|
||||
void _input;
|
||||
try {
|
||||
const leagues = await this.leagueRepository.findAll();
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ export class GetAllLeaguesWithCapacityUseCase {
|
||||
ApplicationErrorCode<GetAllLeaguesWithCapacityErrorCode, { message: string }>
|
||||
>
|
||||
> {
|
||||
void _input;
|
||||
try {
|
||||
const leagues = await this.leagueRepository.findAll();
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ export class GetAllRacesPageDataUseCase {
|
||||
async execute(
|
||||
_input: GetAllRacesPageDataInput,
|
||||
): Promise<Result<void, ApplicationErrorCode<GetAllRacesPageDataErrorCode, { message: string }>>> {
|
||||
void _input;
|
||||
this.logger.debug('Executing GetAllRacesPageDataUseCase');
|
||||
try {
|
||||
const [allRaces, allLeagues] = await Promise.all([
|
||||
|
||||
@@ -33,6 +33,7 @@ export class GetAllRacesUseCase {
|
||||
async execute(
|
||||
_input: GetAllRacesInput,
|
||||
): Promise<Result<void, ApplicationErrorCode<GetAllRacesErrorCode, { message: string }>>> {
|
||||
void _input;
|
||||
this.logger.debug('Executing GetAllRacesUseCase');
|
||||
try {
|
||||
const races = await this.raceRepository.findAll();
|
||||
|
||||
@@ -39,6 +39,7 @@ export class GetAllTeamsUseCase {
|
||||
async execute(
|
||||
_input: GetAllTeamsInput = {},
|
||||
): Promise<Result<void, ApplicationErrorCode<GetAllTeamsErrorCode, { message: string }>>> {
|
||||
void _input;
|
||||
this.logger.debug('Executing GetAllTeamsUseCase');
|
||||
|
||||
try {
|
||||
|
||||
@@ -31,6 +31,7 @@ export class GetSponsorshipPricingUseCase {
|
||||
): Promise<
|
||||
Result<void, ApplicationErrorCode<GetSponsorshipPricingErrorCode, { message: string }>>
|
||||
> {
|
||||
void _input;
|
||||
try {
|
||||
const result: GetSponsorshipPricingResult = {
|
||||
entityType: 'season',
|
||||
|
||||
@@ -53,6 +53,7 @@ export class GetTeamsLeaderboardUseCase {
|
||||
async execute(
|
||||
_input: GetTeamsLeaderboardInput,
|
||||
): Promise<Result<void, ApplicationErrorCode<GetTeamsLeaderboardErrorCode, { message: string }>>> {
|
||||
void _input;
|
||||
try {
|
||||
const allTeams = await this.teamRepository.findAll();
|
||||
const items: TeamLeaderboardItem[] = [];
|
||||
|
||||
@@ -25,6 +25,7 @@ export class GetTotalDriversUseCase implements UseCase<GetTotalDriversInput, Get
|
||||
async execute(
|
||||
_input: GetTotalDriversInput,
|
||||
): Promise<Result<GetTotalDriversResult, ApplicationErrorCode<GetTotalDriversErrorCode, { message: string }>>> {
|
||||
void _input;
|
||||
try {
|
||||
const drivers = await this.driverRepository.findAll();
|
||||
const result: GetTotalDriversResult = { totalDrivers: drivers.length };
|
||||
|
||||
@@ -20,6 +20,7 @@ export class GetTotalLeaguesUseCase {
|
||||
async execute(
|
||||
_input: GetTotalLeaguesInput,
|
||||
): Promise<Result<void, ApplicationErrorCode<GetTotalLeaguesErrorCode, { message: string }>>> {
|
||||
void _input;
|
||||
try {
|
||||
const leagues = await this.leagueRepository.findAll();
|
||||
const result: GetTotalLeaguesResult = { totalLeagues: leagues.length };
|
||||
|
||||
@@ -21,6 +21,7 @@ export class GetTotalRacesUseCase {
|
||||
async execute(_input: GetTotalRacesInput): Promise<
|
||||
Result<void, ApplicationErrorCode<GetTotalRacesErrorCode, { message: string }>>
|
||||
> {
|
||||
void _input;
|
||||
try {
|
||||
const races = await this.raceRepository.findAll();
|
||||
|
||||
|
||||
@@ -23,6 +23,13 @@ describe('ListLeagueScoringPresetsUseCase', () => {
|
||||
dropPolicySummary: 'Drop 1',
|
||||
sessionSummary: 'Session 1',
|
||||
bonusSummary: 'Bonus 1',
|
||||
defaultTimings: {
|
||||
practiceMinutes: 15,
|
||||
qualifyingMinutes: 10,
|
||||
sprintRaceMinutes: 20,
|
||||
mainRaceMinutes: 30,
|
||||
sessionCount: 2,
|
||||
},
|
||||
createConfig: vi.fn(),
|
||||
},
|
||||
{
|
||||
@@ -33,6 +40,13 @@ describe('ListLeagueScoringPresetsUseCase', () => {
|
||||
dropPolicySummary: 'Drop 2',
|
||||
sessionSummary: 'Session 2',
|
||||
bonusSummary: 'Bonus 2',
|
||||
defaultTimings: {
|
||||
practiceMinutes: 20,
|
||||
qualifyingMinutes: 15,
|
||||
sprintRaceMinutes: 25,
|
||||
mainRaceMinutes: 40,
|
||||
sessionCount: 3,
|
||||
},
|
||||
createConfig: vi.fn(),
|
||||
},
|
||||
];
|
||||
@@ -69,6 +83,13 @@ describe('ListLeagueScoringPresetsUseCase', () => {
|
||||
sessionSummary: 'Session 1',
|
||||
bonusSummary: 'Bonus 1',
|
||||
dropPolicySummary: 'Drop 1',
|
||||
defaultTimings: {
|
||||
practiceMinutes: 15,
|
||||
qualifyingMinutes: 10,
|
||||
sprintRaceMinutes: 20,
|
||||
mainRaceMinutes: 30,
|
||||
sessionCount: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'preset-2',
|
||||
@@ -78,6 +99,13 @@ describe('ListLeagueScoringPresetsUseCase', () => {
|
||||
sessionSummary: 'Session 2',
|
||||
bonusSummary: 'Bonus 2',
|
||||
dropPolicySummary: 'Drop 2',
|
||||
defaultTimings: {
|
||||
practiceMinutes: 20,
|
||||
qualifyingMinutes: 15,
|
||||
sprintRaceMinutes: 25,
|
||||
mainRaceMinutes: 40,
|
||||
sessionCount: 3,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@@ -28,6 +28,7 @@ export class ListLeagueScoringPresetsUseCase {
|
||||
): Promise<
|
||||
Result<void, ApplicationErrorCode<ListLeagueScoringPresetsErrorCode, { message: string }>>
|
||||
> {
|
||||
void _input;
|
||||
try {
|
||||
const presets: LeagueScoringPreset[] = this.presets.map(p => ({
|
||||
id: p.id,
|
||||
|
||||
@@ -102,8 +102,8 @@ export class RaceResultGeneratorWithIncidents {
|
||||
// Generate specific incidents
|
||||
const incidents: IncidentRecord[] = [];
|
||||
for (let i = 0; i < incidentCount; i++) {
|
||||
const incidentType = this.selectIncidentType(position, totalDrivers, i);
|
||||
const lap = this.selectIncidentLap(i + 1, incidentCount);
|
||||
const incidentType = this.selectIncidentType(position, totalDrivers);
|
||||
const lap = this.selectIncidentLap(i + 1);
|
||||
|
||||
incidents.push({
|
||||
type: incidentType,
|
||||
@@ -119,7 +119,7 @@ export class RaceResultGeneratorWithIncidents {
|
||||
/**
|
||||
* Select appropriate incident type based on context
|
||||
*/
|
||||
private static selectIncidentType(position: number, totalDrivers: number, _incidentIndex: number): IncidentType {
|
||||
private static selectIncidentType(position: number, totalDrivers: number): IncidentType {
|
||||
// Different incident types have different probabilities
|
||||
const incidentProbabilities: Array<{ type: IncidentType; weight: number }> = [
|
||||
{ type: 'track_limits', weight: 40 }, // Most common
|
||||
@@ -154,7 +154,7 @@ export class RaceResultGeneratorWithIncidents {
|
||||
/**
|
||||
* Select appropriate lap for incident
|
||||
*/
|
||||
private static selectIncidentLap(incidentNumber: number, _totalIncidents: number): number {
|
||||
private static selectIncidentLap(incidentNumber: number): number {
|
||||
// Spread incidents throughout the race
|
||||
const lapRanges = [
|
||||
{ min: 1, max: 5 }, // Early race
|
||||
|
||||
Reference in New Issue
Block a user