wip league admin tools

This commit is contained in:
2025-12-28 12:04:12 +01:00
parent 5dc8c2399c
commit 6edf12fda8
401 changed files with 15365 additions and 6047 deletions

View File

@@ -22,10 +22,12 @@ describe('LeagueStewardingService', () => {
mockProtestService = {
findByRaceId: vi.fn(),
getProtestById: vi.fn(),
} as Mocked<ProtestService>;
mockPenaltyService = {
findByRaceId: vi.fn(),
getPenaltyTypesReference: vi.fn(),
} as Mocked<PenaltyService>;
mockDriverService = {
@@ -144,4 +146,35 @@ describe('LeagueStewardingService', () => {
expect(mockPenaltyService.applyPenalty).toHaveBeenCalledWith(input);
});
});
describe('getProtestDetailViewModel', () => {
it('should combine protest details + penalty types into a page-ready view model', async () => {
const leagueId = 'league-123';
const protestId = 'protest-1';
mockProtestService.getProtestById.mockResolvedValue({
protest: { id: protestId, raceId: 'race-1', protestingDriverId: 'd1', accusedDriverId: 'd2', status: 'pending', submittedAt: '2023-10-01T10:00:00Z', description: 'desc' } as any,
race: { id: 'race-1' } as any,
protestingDriver: { id: 'd1', name: 'Driver 1' } as any,
accusedDriver: { id: 'd2', name: 'Driver 2' } as any,
});
mockPenaltyService.getPenaltyTypesReference.mockResolvedValue({
penaltyTypes: [
{ type: 'time_penalty', requiresValue: true, valueKind: 'seconds' },
{ type: 'warning', requiresValue: false, valueKind: 'none' },
],
defaultReasons: { upheld: 'Upheld reason', dismissed: 'Dismissed reason' },
} as any);
const result = await service.getProtestDetailViewModel(leagueId, protestId);
expect(mockProtestService.getProtestById).toHaveBeenCalledWith(leagueId, protestId);
expect(mockPenaltyService.getPenaltyTypesReference).toHaveBeenCalled();
expect(result.protest.id).toBe(protestId);
expect(result.penaltyTypes.length).toBe(2);
expect(result.defaultReasons.upheld).toBe('Upheld reason');
expect(result.initialPenaltyType).toBe('time_penalty');
});
});
});