refactor: remove legacy round-robin repair

This commit is contained in:
dahyeon committed 2026-06-19 01:36:34 -07:00
1 parent 7399968fe8
commit ade5735dc2
3 files changed
+39 -54

No files matched your search

@@ -10,9 +10,9 @@ type TournamentCodeServiceInternals = TournamentCodeService & {
ensureGameSchedule(match: MatchDocument): void;
};
function createService(connectionService = {} as never) {
function createService() {
return new TournamentCodeService(
connectionService,
{} as never,
) as unknown as TournamentCodeServiceInternals;
}
@@ -28,7 +28,6 @@ interface MatchOverrides {
teamAIndex: number;
teamBIndex: number;
}>;
tournamentCodeIds?: unknown[];
}
function createMatch(overrides: MatchOverrides): MatchDocument {
@@ -218,7 +217,7 @@ describe('TournamentCodeService round-robin scheduling', () => {
}
});
it('rebuilds legacy round-robin schedules without round numbers before reservation', () => {
it('leaves legacy round-robin schedules without round numbers unchanged', () => {
const service = createService();
const roundRobin = createMatch({
gameMode: 'round-robin',
@@ -226,7 +225,6 @@ describe('TournamentCodeService round-robin scheduling', () => {
teams: Array.from({ length: 6 }, (_, index) => ({
teamIndex: index + 1,
})),
tournamentCodeIds: [],
gameSchedule: [
{ gameNumber: 1, teamAIndex: 2, teamBIndex: 5 },
{ gameNumber: 2, teamAIndex: 1, teamBIndex: 2 },
@@ -237,26 +235,22 @@ describe('TournamentCodeService round-robin scheduling', () => {
],
});
const persisted = [...roundRobin.gameSchedule];
service.ensureGameSchedule(roundRobin);
for (const roundNumber of [1, 2, 3, 4, 5]) {
const round = roundRobin.gameSchedule.filter(
(game) => game.roundNumber === roundNumber,
);
expect(round).toHaveLength(3);
expect(new Set(round.flatMap((game) => [game.teamAIndex, game.teamBIndex])).size)
.toBe(6);
}
expect(roundRobin.gameSchedule).toEqual(persisted);
});
it('uses regenerated round refs for pending legacy round-robin slots', async () => {
it('does not expose round numbers for legacy round-robin slots', async () => {
const codeFindExec = jest.fn().mockResolvedValue([]);
const connectionService = {
getModel: jest.fn().mockResolvedValue({
find: jest.fn().mockReturnValue({ exec: codeFindExec }),
}),
};
const service = createService(connectionService as never);
const service = new TournamentCodeService(
connectionService as never,
) as unknown as TournamentCodeServiceInternals;
const slots = await service.buildSlots(
createMatch({
@@ -265,7 +259,6 @@ describe('TournamentCodeService round-robin scheduling', () => {
teams: Array.from({ length: 6 }, (_, index) => ({
teamIndex: index + 1,
})),
tournamentCodeIds: [],
gameSchedule: [
{ gameNumber: 1, teamAIndex: 2, teamBIndex: 5 },
{ gameNumber: 2, teamAIndex: 1, teamBIndex: 2 },
@@ -286,12 +279,16 @@ describe('TournamentCodeService round-robin scheduling', () => {
}),
);
for (const roundNumber of [1, 2, 3, 4, 5]) {
const round = slots.filter((slot) => slot.roundNumber === roundNumber);
expect(round).toHaveLength(3);
expect(new Set(round.flatMap((slot) => [slot.teamAIndex, slot.teamBIndex])).size)
.toBe(6);
}
expect(slots).toHaveLength(15);
expect(slots[0]).toEqual(
expect.objectContaining({
gameNumber: 1,
roundNumber: undefined,
teamAIndex: 2,
teamBIndex: 5,
}),
);
expect(slots.every((slot) => slot.roundNumber === undefined)).toBe(true);
});
it('does not expose fallback round-robin slots before the schedule is persisted', async () => {