Files
gridpilot.gg/tests/integration/drivers/DriversTestContext.ts
Marc Mintel a0f41f242f
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m51s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
integration tests
2026-01-23 00:46:34 +01:00

98 lines
4.2 KiB
TypeScript

import { Logger } from '../../../core/shared/domain/Logger';
import { InMemoryDriverRepository } from '../../../adapters/racing/persistence/inmemory/InMemoryDriverRepository';
import { InMemoryTeamRepository } from '../../../adapters/racing/persistence/inmemory/InMemoryTeamRepository';
import { InMemoryTeamMembershipRepository } from '../../../adapters/racing/persistence/inmemory/InMemoryTeamMembershipRepository';
import { InMemorySocialGraphRepository } from '../../../adapters/social/persistence/inmemory/InMemorySocialAndFeed';
import { InMemoryDriverExtendedProfileProvider } from '../../../adapters/racing/ports/InMemoryDriverExtendedProfileProvider';
import { InMemoryDriverStatsRepository } from '../../../adapters/racing/persistence/inmemory/InMemoryDriverStatsRepository';
import { GetProfileOverviewUseCase } from '../../../core/racing/application/use-cases/GetProfileOverviewUseCase';
import { UpdateDriverProfileUseCase } from '../../../core/racing/application/use-cases/UpdateDriverProfileUseCase';
import { DriverStatsUseCase } from '../../../core/racing/application/use-cases/DriverStatsUseCase';
import { RankingUseCase } from '../../../core/racing/application/use-cases/RankingUseCase';
import { GetDriversLeaderboardUseCase } from '../../../core/racing/application/use-cases/GetDriversLeaderboardUseCase';
import { GetDriverUseCase } from '../../../core/racing/application/use-cases/GetDriverUseCase';
export class DriversTestContext {
public readonly logger: Logger;
public readonly driverRepository: InMemoryDriverRepository;
public readonly teamRepository: InMemoryTeamRepository;
public readonly teamMembershipRepository: InMemoryTeamMembershipRepository;
public readonly socialRepository: InMemorySocialGraphRepository;
public readonly driverExtendedProfileProvider: InMemoryDriverExtendedProfileProvider;
public readonly driverStatsRepository: InMemoryDriverStatsRepository;
public readonly driverStatsUseCase: DriverStatsUseCase;
public readonly rankingUseCase: RankingUseCase;
public readonly getProfileOverviewUseCase: GetProfileOverviewUseCase;
public readonly updateDriverProfileUseCase: UpdateDriverProfileUseCase;
public readonly getDriversLeaderboardUseCase: GetDriversLeaderboardUseCase;
public readonly getDriverUseCase: GetDriverUseCase;
private constructor() {
this.logger = {
info: () => {},
debug: () => {},
warn: () => {},
error: () => {},
} as unknown as Logger;
this.driverRepository = new InMemoryDriverRepository(this.logger);
this.teamRepository = new InMemoryTeamRepository(this.logger);
this.teamMembershipRepository = new InMemoryTeamMembershipRepository(this.logger);
this.socialRepository = new InMemorySocialGraphRepository(this.logger);
this.driverExtendedProfileProvider = new InMemoryDriverExtendedProfileProvider(this.logger);
this.driverStatsRepository = new InMemoryDriverStatsRepository(this.logger);
this.driverStatsUseCase = new DriverStatsUseCase(
{} as any,
{} as any,
this.driverStatsRepository,
this.logger
);
this.rankingUseCase = new RankingUseCase(
{} as any,
{} as any,
this.driverStatsRepository,
this.logger
);
this.getProfileOverviewUseCase = new GetProfileOverviewUseCase(
this.driverRepository,
this.teamRepository,
this.teamMembershipRepository,
this.socialRepository,
this.driverExtendedProfileProvider,
this.driverStatsUseCase,
this.rankingUseCase
);
this.updateDriverProfileUseCase = new UpdateDriverProfileUseCase(
this.driverRepository,
this.logger
);
this.getDriversLeaderboardUseCase = new GetDriversLeaderboardUseCase(
this.driverRepository,
this.rankingUseCase,
this.driverStatsUseCase,
this.logger
);
this.getDriverUseCase = new GetDriverUseCase(this.driverRepository);
}
public static create(): DriversTestContext {
return new DriversTestContext();
}
public clear(): void {
this.driverRepository.clear();
this.teamRepository.clear();
this.teamMembershipRepository.clear();
this.socialRepository.clear();
this.driverExtendedProfileProvider.clear();
this.driverStatsRepository.clear();
}
}