integration tests
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m50s
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
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m50s
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
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { LeaguesTestContext } from '../LeaguesTestContext';
|
||||
import { LeagueCreateCommand } from '../../../../core/leagues/application/ports/LeagueCreateCommand';
|
||||
|
||||
describe('League Creation - Success Path', () => {
|
||||
let context: LeaguesTestContext;
|
||||
|
||||
beforeEach(() => {
|
||||
context = new LeaguesTestContext();
|
||||
context.clear();
|
||||
});
|
||||
|
||||
it('should create a league with complete configuration', async () => {
|
||||
const driverId = 'driver-123';
|
||||
const command: LeagueCreateCommand = {
|
||||
name: 'Test League',
|
||||
description: 'A test league for integration testing',
|
||||
visibility: 'public',
|
||||
ownerId: driverId,
|
||||
maxDrivers: 20,
|
||||
approvalRequired: true,
|
||||
lateJoinAllowed: true,
|
||||
raceFrequency: 'weekly',
|
||||
raceDay: 'Saturday',
|
||||
raceTime: '18:00',
|
||||
tracks: ['Monza', 'Spa', 'Nürburgring'],
|
||||
scoringSystem: { points: [25, 18, 15, 12, 10, 8, 6, 4, 2, 1] },
|
||||
bonusPointsEnabled: true,
|
||||
penaltiesEnabled: true,
|
||||
protestsEnabled: true,
|
||||
appealsEnabled: true,
|
||||
stewardTeam: ['steward-1', 'steward-2'],
|
||||
gameType: 'iRacing',
|
||||
skillLevel: 'Intermediate',
|
||||
category: 'GT3',
|
||||
tags: ['competitive', 'weekly-races'],
|
||||
};
|
||||
|
||||
const result = await context.createLeagueUseCase.execute(command);
|
||||
|
||||
expect(result).toBeDefined();
|
||||
expect(result.id).toBeDefined();
|
||||
expect(result.name).toBe('Test League');
|
||||
expect(result.ownerId).toBe(driverId);
|
||||
expect(result.status).toBe('active');
|
||||
expect(result.maxDrivers).toBe(20);
|
||||
expect(result.tracks).toEqual(['Monza', 'Spa', 'Nürburgring']);
|
||||
|
||||
const savedLeague = await context.leagueRepository.findById(result.id);
|
||||
expect(savedLeague).toBeDefined();
|
||||
expect(savedLeague?.ownerId).toBe(driverId);
|
||||
|
||||
expect(context.eventPublisher.getLeagueCreatedEventCount()).toBe(1);
|
||||
const events = context.eventPublisher.getLeagueCreatedEvents();
|
||||
expect(events[0].leagueId).toBe(result.id);
|
||||
});
|
||||
|
||||
it('should create a league with minimal configuration', async () => {
|
||||
const driverId = 'driver-123';
|
||||
const command: LeagueCreateCommand = {
|
||||
name: 'Minimal League',
|
||||
visibility: 'public',
|
||||
ownerId: driverId,
|
||||
approvalRequired: false,
|
||||
lateJoinAllowed: false,
|
||||
bonusPointsEnabled: false,
|
||||
penaltiesEnabled: false,
|
||||
protestsEnabled: false,
|
||||
appealsEnabled: false,
|
||||
};
|
||||
|
||||
const result = await context.createLeagueUseCase.execute(command);
|
||||
|
||||
expect(result).toBeDefined();
|
||||
expect(result.name).toBe('Minimal League');
|
||||
expect(result.status).toBe('active');
|
||||
expect(result.description).toBeNull();
|
||||
expect(context.eventPublisher.getLeagueCreatedEventCount()).toBe(1);
|
||||
});
|
||||
|
||||
it('should create a league with public visibility', async () => {
|
||||
const result = await context.createLeague({ name: 'Public League', visibility: 'public' });
|
||||
expect(result.visibility).toBe('public');
|
||||
});
|
||||
|
||||
it('should create a league with private visibility', async () => {
|
||||
const result = await context.createLeague({ name: 'Private League', visibility: 'private' });
|
||||
expect(result.visibility).toBe('private');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user