fix: normalize missing legacy match game mode
This commit is contained in:
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);
|
||||
|
||||
@@ -759,6 +759,10 @@ async function hydrateLegacyMatch(
|
||||
|
||||
return {
|
||||
...match,
|
||||
// Native collection reads bypass the MatchSchema default. Historical
|
||||
// documents without a persisted gameMode still executed as pair mode via
|
||||
// the runtime fallback.
|
||||
gameMode: match.gameMode ?? 'pair',
|
||||
...(hydratedResult ? { result: hydratedResult } : {}),
|
||||
tournamentCodes,
|
||||
riotMatchArchiveIds: [...archivedIds].sort(),
|
||||
|
||||
Reference in new issue
Block a user