fix issues

This commit is contained in:
2026-01-02 00:21:24 +01:00
parent 79913bb45e
commit 8693dde21e
46 changed files with 1680 additions and 302 deletions

View File

@@ -298,8 +298,22 @@ describe('RecordRaceRatingEventsUseCase', () => {
],
});
// Only set rating for first user, second will fail
// Set ratings for both users
mockUserRatingRepository.setRating('user-123', UserRating.create('user-123'));
mockUserRatingRepository.setRating('user-456', UserRating.create('user-456'));
// Make the repository throw an error for user-456
const originalSave = mockRatingEventRepository.save;
let user456CallCount = 0;
mockRatingEventRepository.save = async (event: RatingEvent) => {
if (event.userId === 'user-456') {
user456CallCount++;
if (user456CallCount === 1) { // Fail on first save attempt
throw new Error('Database constraint violation for user-456');
}
}
return event;
};
const result = await useCase.execute({ raceId: 'race-123' });
@@ -308,6 +322,10 @@ describe('RecordRaceRatingEventsUseCase', () => {
expect(result.driversUpdated).toContain('user-123');
expect(result.errors).toBeDefined();
expect(result.errors!.length).toBeGreaterThan(0);
expect(result.errors![0]).toContain('user-456');
// Restore
mockRatingEventRepository.save = originalSave;
});
it('should return success with no events when no valid events created', async () => {