release/86 #2

Merged
dahyeon merged 108 commits from release/86 into main 2026-07-15 08:56:05 +00:00
2 changed files with 72 additions and 71 deletions
Showing only changes of commit bbcb2f43dc - Show all commits

No files matched your search

@@ -210,9 +210,7 @@ describe('generateSeriesGraph', () => {
pairing(1, 2, 'team-3', 'team-4'), pairing(1, 2, 'team-3', 'team-4'),
]); ]);
expect(() => generateSeriesGraph(input)).toThrow( expectGraphError(input, 'INVALID_ROUND_ROBIN_PAIRING');
expect.objectContaining({ code: 'INVALID_ROUND_ROBIN_PAIRING' }),
);
}, },
); );
@@ -234,9 +232,7 @@ describe('generateSeriesGraph', () => {
code: 'DUPLICATE_ROUND_ROBIN_OPPONENTS', code: 'DUPLICATE_ROUND_ROBIN_OPPONENTS',
}, },
])('rejects a duplicate explicit $name', ({ pairings, code }) => { ])('rejects a duplicate explicit $name', ({ pairings, code }) => {
expect(() => expectGraphError(explicitRoundRobinInput(pairings), code);
generateSeriesGraph(explicitRoundRobinInput(pairings)),
).toThrow(expect.objectContaining({ code }));
}); });
}); });
@@ -244,6 +240,15 @@ function firstTo(winsRequired: number, maxGames: number) {
return { type: 'first-to' as const, winsRequired, maxGames }; return { type: 'first-to' as const, winsRequired, maxGames };
} }
function expectGraphError(input: GraphInput, code: string): void {
try {
generateSeriesGraph(input);
throw new Error(`Expected graph error ${code}.`);
} catch (error) {
expect(error).toMatchObject({ code });
}
}
function fixedGames(gameCount: number) { function fixedGames(gameCount: number) {
return { return {
type: 'fixed-games' as const, type: 'fixed-games' as const,
@@ -63,12 +63,11 @@ describe('planCompetitionMigration', () => {
riotMatchId: 'KR_WITH_ARCHIVE', riotMatchId: 'KR_WITH_ARCHIVE',
}, },
}); });
expect(games[1]).toMatchObject({ expect(games[1].evidence.type).toBe('legacy');
evidence: { if (games[1].evidence.type !== 'legacy') {
type: 'legacy', throw new Error('Expected normalized-only legacy evidence.');
legacyReference: expect.stringContaining('KR_NORMALIZED_ONLY'), }
}, expect(games[1].evidence.legacyReference).toContain('KR_NORMALIZED_ONLY');
});
}); });
it('turns a winner-only Series into an adjudication without fabricating games', () => { it('turns a winner-only Series into an adjudication without fabricating games', () => {
@@ -131,12 +130,7 @@ describe('planCompetitionMigration', () => {
const plan = planCompetitionMigration(legacy); const plan = planCompetitionMigration(legacy);
expect(plan).toMatchObject({ expectQuarantineReason(plan, 'AMBIGUOUS_GAME_ASSIGNMENT');
status: 'quarantined',
reasons: expect.arrayContaining([
expect.objectContaining({ code: 'AMBIGUOUS_GAME_ASSIGNMENT' }),
]),
});
}); });
it('preserves a persisted non-canonical round-robin schedule', () => { it('preserves a persisted non-canonical round-robin schedule', () => {
@@ -187,17 +181,19 @@ describe('planCompetitionMigration', () => {
const plan = requireReady(planCompetitionMigration(legacy)); const plan = requireReady(planCompetitionMigration(legacy));
expect(plan.competition.format).toMatchObject({ expect(plan.competition.format.type).toBe('round-robin');
type: 'round-robin', if (plan.competition.format.type !== 'round-robin') {
pairings: expect.arrayContaining([ throw new Error('Expected a round-robin format.');
expect.objectContaining({ }
roundNumber: 3, expect(
matchNumber: 4, plan.competition.format.pairings?.some(
teamAId: plan.competition.teams[5].teamId, (pairing) =>
teamBId: plan.competition.teams[6].teamId, pairing.roundNumber === 3 &&
}), pairing.matchNumber === 4 &&
]), pairing.teamAId === plan.competition.teams[5].teamId &&
}); pairing.teamBId === plan.competition.teams[6].teamId,
),
).toBe(true);
expect( expect(
plan.facts.filter(({ type }) => type === 'game-accepted'), plan.facts.filter(({ type }) => type === 'game-accepted'),
).toHaveLength(12); ).toHaveLength(12);
@@ -284,14 +280,7 @@ describe('planCompetitionMigration', () => {
const plan = planCompetitionMigration(legacy); const plan = planCompetitionMigration(legacy);
expect(plan).toMatchObject({ expectQuarantineReason(plan, 'TOURNAMENT_CODE_ASSIGNMENT_CONFLICT');
status: 'quarantined',
reasons: expect.arrayContaining([
expect.objectContaining({
code: 'TOURNAMENT_CODE_ASSIGNMENT_CONFLICT',
}),
]),
});
}); });
it('quarantines conflicting Riot evidence and global game number', () => { it('quarantines conflicting Riot evidence and global game number', () => {
@@ -322,14 +311,10 @@ describe('planCompetitionMigration', () => {
], ],
}); });
expect(planCompetitionMigration(legacy)).toMatchObject({ expectQuarantineReason(
status: 'quarantined', planCompetitionMigration(legacy),
reasons: expect.arrayContaining([ 'TOURNAMENT_CODE_ASSIGNMENT_CONFLICT',
expect.objectContaining({ );
code: 'TOURNAMENT_CODE_ASSIGNMENT_CONFLICT',
}),
]),
});
}); });
it('quarantines a TournamentCode game number outside the Competition topology', () => { it('quarantines a TournamentCode game number outside the Competition topology', () => {
@@ -346,14 +331,10 @@ describe('planCompetitionMigration', () => {
], ],
}); });
expect(planCompetitionMigration(legacy)).toMatchObject({ expectQuarantineReason(
status: 'quarantined', planCompetitionMigration(legacy),
reasons: expect.arrayContaining([ 'TOURNAMENT_CODE_ASSIGNMENT_MAPPING_NOT_FOUND',
expect.objectContaining({ );
code: 'TOURNAMENT_CODE_ASSIGNMENT_MAPPING_NOT_FOUND',
}),
]),
});
}); });
it('does not guess the first slot of a multi-slot Series without exact slot evidence', () => { it('does not guess the first slot of a multi-slot Series without exact slot evidence', () => {
@@ -372,14 +353,10 @@ describe('planCompetitionMigration', () => {
const plan = planCompetitionMigration(legacy); const plan = planCompetitionMigration(legacy);
expect(plan).toMatchObject({ expectQuarantineReason(
status: 'quarantined', plan,
reasons: expect.arrayContaining([ 'TOURNAMENT_CODE_ASSIGNMENT_MAPPING_NOT_FOUND',
expect.objectContaining({ );
code: 'TOURNAMENT_CODE_ASSIGNMENT_MAPPING_NOT_FOUND',
}),
]),
});
}); });
it('repairs the data.txt WB_R2_M2 positional bug from accepted game evidence', () => { it('repairs the data.txt WB_R2_M2 positional bug from accepted game evidence', () => {
@@ -418,16 +395,22 @@ describe('planCompetitionMigration', () => {
loserTeamId: team3!.teamId, loserTeamId: team3!.teamId,
}, },
}); });
expect(series('WB_FINAL')).toMatchObject({ expect(
entries: expect.arrayContaining([ series('WB_FINAL')?.entries.some(
{ slot: 'B', teamId: team8!.teamId, gameWins: 0 }, (entry) =>
]), entry.slot === 'B' &&
}); entry.teamId === team8!.teamId &&
expect(series('LB_R2_M1')).toMatchObject({ entry.gameWins === 0,
entries: expect.arrayContaining([ ),
{ slot: 'B', teamId: team3!.teamId, gameWins: 0 }, ).toBe(true);
]), expect(
}); series('LB_R2_M1')?.entries.some(
(entry) =>
entry.slot === 'B' &&
entry.teamId === team3!.teamId &&
entry.gameWins === 0,
),
).toBe(true);
}); });
}); });
@@ -484,6 +467,19 @@ function requireReady(
return plan; return plan;
} }
function expectQuarantineReason(
plan: ReturnType<typeof planCompetitionMigration>,
code: string,
): void {
expect(plan.status).toBe('quarantined');
if (plan.status !== 'quarantined') {
throw new Error(
`Expected a quarantined migration plan, got ${plan.status}.`,
);
}
expect(plan.reasons.some((reason) => reason.code === code)).toBe(true);
}
function loadDataTxtFixture(): LegacyMatchInput { function loadDataTxtFixture(): LegacyMatchInput {
const seededTeamIndexes = [1, 8, 3, 4, 5, 6, 7, 2]; const seededTeamIndexes = [1, 8, 3, 4, 5, 6, 7, 2];
const games = [ const games = [