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

@@ -2,6 +2,7 @@
* Tests for GetUserRatingsSummaryQuery
*/
import { describe, expect, it, beforeEach, vi } from 'vitest';
import { GetUserRatingsSummaryQuery, GetUserRatingsSummaryQueryHandler } from './GetUserRatingsSummaryQuery';
import { UserRating } from '../../domain/value-objects/UserRating';
import { ExternalGameRatingProfile } from '../../domain/entities/ExternalGameRatingProfile';
@@ -21,13 +22,13 @@ describe('GetUserRatingsSummaryQuery', () => {
beforeEach(() => {
mockUserRatingRepo = {
findByUserId: jest.fn(),
findByUserId: vi.fn(),
};
mockExternalRatingRepo = {
findByUserId: jest.fn(),
findByUserId: vi.fn(),
};
mockRatingEventRepo = {
getAllByUserId: jest.fn(),
getAllByUserId: vi.fn(),
};
handler = new GetUserRatingsSummaryQueryHandler(
@@ -54,15 +55,15 @@ describe('GetUserRatingsSummaryQuery', () => {
['iRating', ExternalRating.create(gameKey, 'iRating', 2200)],
['safetyRating', ExternalRating.create(gameKey, 'safetyRating', 4.5)],
]),
provenance: ExternalRatingProvenance.create('iRacing API', new Date()),
provenance: ExternalRatingProvenance.create({ source: 'iRacing API', lastSyncedAt: new Date() }),
});
mockExternalRatingRepo.findByUserId.mockResolvedValue([profile]);
// Mock rating events
const event = RatingEvent.create({
id: RatingEventId.create(),
id: RatingEventId.generate(),
userId,
dimension: RatingDimensionKey.create('driver'),
dimension: RatingDimensionKey.create('driving'),
delta: RatingDelta.create(5),
occurredAt: new Date('2024-01-01'),
createdAt: new Date('2024-01-01'),
@@ -113,7 +114,7 @@ describe('GetUserRatingsSummaryQuery', () => {
ratings: new Map([
['iRating', ExternalRating.create(GameKey.create('iracing'), 'iRating', 2200)],
]),
provenance: ExternalRatingProvenance.create('iRacing API', new Date()),
provenance: ExternalRatingProvenance.create({ source: 'iRacing API', lastSyncedAt: new Date() }),
});
const assettoProfile = ExternalGameRatingProfile.create({
@@ -122,7 +123,7 @@ describe('GetUserRatingsSummaryQuery', () => {
ratings: new Map([
['rating', ExternalRating.create(GameKey.create('assetto'), 'rating', 85)],
]),
provenance: ExternalRatingProvenance.create('Assetto API', new Date()),
provenance: ExternalRatingProvenance.create({ source: 'Assetto API', lastSyncedAt: new Date() }),
});
mockExternalRatingRepo.findByUserId.mockResolvedValue([iracingProfile, assettoProfile]);