fix: resume tournament result polling after delayed codes

This commit is contained in:
dahyeon committed 2026-06-25 04:58:10 -07:00
1 parent e50a683336
commit 2984bd1604
8 files changed
+207 -21

No files matched your search

@@ -1,7 +1,11 @@
import mongoose from 'mongoose';
import type { MatchDocument } from '../global/database/schema';
import type { RiotMatchDto } from '../riot/riot.types';
import { computeGameResult, type MatchPuuidLookup } from './team-mapping.util';
import {
collectCaptainAndLimitedTeamMemberUserIds,
computeGameResult,
type MatchPuuidLookup,
} from './team-mapping.util';
function makeMatch(): {
match: MatchDocument;
@@ -9,8 +13,14 @@ function makeMatch(): {
blueUserIds: mongoose.Types.ObjectId[];
redUserIds: mongoose.Types.ObjectId[];
} {
const blueUserIds = Array.from({ length: 5 }, () => new mongoose.Types.ObjectId());
const redUserIds = Array.from({ length: 5 }, () => new mongoose.Types.ObjectId());
const blueUserIds = Array.from(
{ length: 5 },
() => new mongoose.Types.ObjectId(),
);
const redUserIds = Array.from(
{ length: 5 },
() => new mongoose.Types.ObjectId(),
);
const puuidByUserId = new Map<string, string>();
const userIdByPuuid = new Map<string, mongoose.Types.ObjectId>();
@@ -47,7 +57,12 @@ function makeMatch(): {
})),
} as unknown as MatchDocument;
return { match, lookup: { puuidByUserId, userIdByPuuid }, blueUserIds, redUserIds };
return {
match,
lookup: { puuidByUserId, userIdByPuuid },
blueUserIds,
redUserIds,
};
}
function makeRiotMatch(params: {
@@ -154,3 +169,24 @@ describe('computeGameResult', () => {
expect(result).toBeNull();
});
});
describe('collectCaptainAndLimitedTeamMemberUserIds', () => {
it('keeps captains and caps extra members per team', () => {
const { blueUserIds, match, redUserIds } = makeMatch();
match.teams[0].captainUserId = blueUserIds[0];
match.teams[1].captainUserId = redUserIds[0];
const userIds = collectCaptainAndLimitedTeamMemberUserIds(match, 2).map(
(userId) => userId.toString(),
);
expect(userIds).toEqual([
blueUserIds[0].toString(),
blueUserIds[1].toString(),
blueUserIds[2].toString(),
redUserIds[0].toString(),
redUserIds[1].toString(),
redUserIds[2].toString(),
]);
});
});