fix: normalize missing legacy match game mode

This commit is contained in:
dahyeon committed 2026-07-13 03:13:28 +00:00
1 parent 683d602d63
commit ee96f8d48b
3 files changed
+66

No files matched your search

@@ -39,6 +39,61 @@ describe('migrateCompetitionDomain', () => {
expect(db.createdIndexes).toHaveLength(0);
});
it.each([
['absent', (match: AnyDoc) => delete match.gameMode],
['null', (match: AnyDoc) => (match.gameMode = null)],
])(
'restores the historical pair default when raw Mongo Match gameMode is %s',
async (_label, omitGameMode) => {
const match = readyMatch();
omitGameMode(match);
const before = canonical(match);
const db = new MemoryMigrationDb({
match: [match],
riotMatch: [riotArchive()],
tournamentCode: [usedTournamentCode(match)],
});
const result = await migrateCompetitionDomain(db);
expect(result.summary).toMatchObject({
scanned: 1,
ready: 1,
quarantined: 0,
failed: 0,
});
expect(result.matches[0]).toMatchObject({
status: 'ready',
factCount: 1,
assignmentCount: 1,
});
expect(canonical(db.docs('match')[0])).toBe(before);
expect(db.writeCount).toBe(0);
},
);
it('keeps an explicitly unknown raw Mongo Match gameMode quarantined', async () => {
const match = readyMatch();
match.gameMode = 'future-mode';
const db = new MemoryMigrationDb({ match: [match] });
const result = await migrateCompetitionDomain(db);
expect(result.summary).toMatchObject({
scanned: 1,
ready: 0,
quarantined: 1,
failed: 0,
});
expect(result.matches[0]).toMatchObject({
status: 'quarantined',
reasons: [
expect.objectContaining({ code: 'UNSUPPORTED_LEGACY_GAME_MODE' }),
],
});
expect(db.writeCount).toBe(0);
});
it('applies one Match atomically and converges on an already-applied replay', async () => {
const match = readyMatch();
const originalResult = canonical(match.result);