Files
gridpilot.gg/tests/integration/onboarding/onboarding-personal-info-use-cases.integration.test.ts
Marc Mintel 597bb48248
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 4m51s
Contract Testing / contract-snapshot (pull_request) Has been skipped
integration tests
2026-01-22 17:29:06 +01:00

85 lines
2.9 KiB
TypeScript

/**
* Integration Test: Onboarding Personal Information Use Case Orchestration
*
* Tests the orchestration logic of personal information-related Use Cases:
* - CompleteDriverOnboardingUseCase: Handles the initial driver profile creation
*
* Validates that Use Cases correctly interact with their Ports (Repositories)
* Uses In-Memory adapters for fast, deterministic testing
*
* Focus: Business logic orchestration, NOT UI rendering
*/
import { describe, it, expect, beforeAll, beforeEach } from 'vitest';
import { InMemoryDriverRepository } from '../../../adapters/racing/persistence/inmemory/InMemoryDriverRepository';
import { CompleteDriverOnboardingUseCase } from '../../../core/racing/application/use-cases/CompleteDriverOnboardingUseCase';
import { Logger } from '../../../core/shared/domain/Logger';
describe('Onboarding Personal Information Use Case Orchestration', () => {
let driverRepository: InMemoryDriverRepository;
let completeDriverOnboardingUseCase: CompleteDriverOnboardingUseCase;
let mockLogger: Logger;
beforeAll(() => {
mockLogger = {
info: () => {},
debug: () => {},
warn: () => {},
error: () => {},
} as unknown as Logger;
driverRepository = new InMemoryDriverRepository(mockLogger);
completeDriverOnboardingUseCase = new CompleteDriverOnboardingUseCase(
driverRepository,
mockLogger
);
});
beforeEach(async () => {
await driverRepository.clear();
});
describe('CompleteDriverOnboardingUseCase - Personal Info Scenarios', () => {
it('should create driver with valid personal information', async () => {
// Scenario: Valid personal info
// Given: A new user
const input = {
userId: 'user-789',
firstName: 'Alice',
lastName: 'Wonderland',
displayName: 'AliceRacer',
country: 'UK',
};
// When: CompleteDriverOnboardingUseCase.execute() is called
const result = await completeDriverOnboardingUseCase.execute(input);
// Then: Validation should pass and driver be created
expect(result.isOk()).toBe(true);
const { driver } = result.unwrap();
expect(driver.name.toString()).toBe('AliceRacer');
expect(driver.country.toString()).toBe('UK');
});
it('should handle bio as optional personal information', async () => {
// Scenario: Optional bio field
// Given: Personal info with bio
const input = {
userId: 'user-bio',
firstName: 'Bob',
lastName: 'Builder',
displayName: 'BobBuilds',
country: 'AU',
bio: 'I build fast cars',
};
// When: CompleteDriverOnboardingUseCase.execute() is called
const result = await completeDriverOnboardingUseCase.execute(input);
// Then: Bio should be saved
expect(result.isOk()).toBe(true);
expect(result.unwrap().driver.bio?.toString()).toBe('I build fast cars');
});
});
});