release/86 #2

Merged
dahyeon merged 108 commits from release/86 into main 2026-07-15 08:56:05 +00:00
Showing only changes of commit 0c2c7b59fc - Show all commits
@@ -124,15 +124,15 @@ describe('projectCompetition', () => {
loserTeamId: 'team-3',
},
});
expect(projectedSeries(projection, 'WB_FINAL')).toMatchObject({
entries: expect.arrayContaining([
{ slot: 'B', teamId: 'team-8', gameWins: 0 },
]),
expect(projectedSeries(projection, 'WB_FINAL').entries).toContainEqual({
slot: 'B',
teamId: 'team-8',
gameWins: 0,
});
expect(projectedSeries(projection, 'LB_R2_M1')).toMatchObject({
entries: expect.arrayContaining([
{ slot: 'B', teamId: 'team-3', gameWins: 0 },
]),
expect(projectedSeries(projection, 'LB_R2_M1').entries).toContainEqual({
slot: 'B',
teamId: 'team-3',
gameWins: 0,
});
expect(projection.games).toHaveLength(7);
expect(
@@ -306,6 +306,65 @@ describe('projectCompetition', () => {
expect(projection.gameSlots[0]).toMatchObject({ status: 'ready' });
expect(projection.games).toEqual([]);
});
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) =>
seededTeam(`team-${index + 1}`, index + 1),
);
const format = doubleEliminationFormat({ upperWinsRequired: 1 });
const seriesGraph = generateSeriesGraph({ competitionId, teams, format });
const accept = acceptedGameFactory(competitionId);
const facts: ReturnType<typeof accept>[] = [];
let projection = projectCompetition({
competitionId,
revision: 0,
projectorVersion: 1,
teams,
format,
seriesGraph,
facts,
});
for (let guard = 0; projection.phase !== 'completed'; guard += 1) {
if (guard > seriesGraph.length) {
throw new Error('Double-elimination projection did not converge.');
}
const playable = projection.series.find(
(series) => series.status === 'ready',
);
if (!playable) throw new Error('Missing playable Series.');
const definition = seriesGraph.find(
(series) => series.id === playable.seriesId,
);
const [entryA, entryB] = playable.entries;
if (!definition || !entryA.teamId || !entryB.teamId) {
throw new Error('Playable Series has unresolved participants.');
}
facts.push(
accept(definition, 1, entryA.teamId, entryB.teamId, entryA.teamId),
);
projection = projectCompetition({
competitionId,
revision: facts.length,
projectorVersion: 1,
teams,
format,
seriesGraph,
facts,
});
}
expect(projection.outcome?.type).toBe('double-elimination');
if (projection.outcome?.type !== 'double-elimination') {
throw new Error('Expected a double-elimination outcome.');
}
expect(typeof projection.outcome.championTeamId).toBe('string');
expect(projection.outcome.placements).toHaveLength(8);
expect(projection.placements?.map(({ rank }) => rank)).toEqual([
1, 2, 3, 4, 5, 5, 7, 7,
]);
});
});
function fixedGames(gameCount: number) {