fix: close competition cutover integrity gaps
This commit is contained in:
1 parent
7ea2002975
commit
683d602d63
57 files changed
+4805
-1582
No files matched your search
@@ -307,6 +307,114 @@ describe('projectCompetition', () => {
|
||||
expect(projection.games).toEqual([]);
|
||||
});
|
||||
|
||||
it('rejects an accepted game that targets a Series outside the graph', () => {
|
||||
const competitionId = 'competition-unknown-game-series';
|
||||
const teams = [seededTeam('team-1', 1), seededTeam('team-2', 2)];
|
||||
const format = {
|
||||
type: 'paired-series' as const,
|
||||
rule: fixedGames(1),
|
||||
};
|
||||
const seriesGraph = generateSeriesGraph({ competitionId, teams, format });
|
||||
const accepted = acceptedGameFactory(competitionId)(
|
||||
seriesGraph[0],
|
||||
1,
|
||||
'team-1',
|
||||
'team-2',
|
||||
'team-1',
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
projectCompetition({
|
||||
competitionId,
|
||||
revision: 1,
|
||||
projectorVersion: 1,
|
||||
teams,
|
||||
format,
|
||||
seriesGraph,
|
||||
facts: [{ ...accepted, seriesId: 'series-does-not-exist' }],
|
||||
}),
|
||||
).toThrow(
|
||||
expect.objectContaining({
|
||||
code: 'GAME_SERIES_MISMATCH',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects an accepted game that targets an unknown GameSlot', () => {
|
||||
const competitionId = 'competition-unknown-game-slot';
|
||||
const teams = [seededTeam('team-1', 1), seededTeam('team-2', 2)];
|
||||
const format = {
|
||||
type: 'paired-series' as const,
|
||||
rule: fixedGames(1),
|
||||
};
|
||||
const seriesGraph = generateSeriesGraph({ competitionId, teams, format });
|
||||
const accepted = acceptedGameFactory(competitionId)(
|
||||
seriesGraph[0],
|
||||
1,
|
||||
'team-1',
|
||||
'team-2',
|
||||
'team-1',
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
projectCompetition({
|
||||
competitionId,
|
||||
revision: 1,
|
||||
projectorVersion: 1,
|
||||
teams,
|
||||
format,
|
||||
seriesGraph,
|
||||
facts: [{ ...accepted, gameSlotId: 'slot-does-not-exist' }],
|
||||
}),
|
||||
).toThrow(
|
||||
expect.objectContaining({
|
||||
code: 'GAME_SLOT_INVALID',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects an adjudication that targets a Series outside the graph', () => {
|
||||
const competitionId = 'competition-unknown-adjudication-series';
|
||||
const teams = [seededTeam('team-1', 1), seededTeam('team-2', 2)];
|
||||
const format = {
|
||||
type: 'paired-series' as const,
|
||||
rule: fixedGames(1),
|
||||
};
|
||||
const seriesGraph = generateSeriesGraph({ competitionId, teams, format });
|
||||
|
||||
expect(() =>
|
||||
projectCompetition({
|
||||
competitionId,
|
||||
revision: 1,
|
||||
projectorVersion: 1,
|
||||
teams,
|
||||
format,
|
||||
seriesGraph,
|
||||
facts: [
|
||||
{
|
||||
id: 'fact-unknown-adjudication-series',
|
||||
type: 'series-adjudicated',
|
||||
competitionId,
|
||||
revision: 1,
|
||||
ordinalWithinRevision: 1,
|
||||
commandId: 'command-unknown-adjudication-series',
|
||||
schemaVersion: 1,
|
||||
actor: { type: 'user' },
|
||||
occurredAt: new Date('2026-07-12T00:00:01.000Z'),
|
||||
recordedAt: new Date('2026-07-12T00:00:02.000Z'),
|
||||
seriesId: 'series-does-not-exist',
|
||||
decision: { type: 'administrative', winnerTeamId: 'team-1' },
|
||||
reason: 'Manual correction',
|
||||
},
|
||||
],
|
||||
}),
|
||||
).toThrow(
|
||||
expect.objectContaining({
|
||||
code: 'ADJUDICATION_INVALID',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('completes an eight-team double elimination with shared elimination-round placements', () => {
|
||||
const competitionId = 'competition-eight-team-completion';
|
||||
const teams = Array.from({ length: 8 }, (_, index) =>
|
||||
|
||||
Reference in new issue
Block a user