Preserve tournament result jobs through lock contention and transient failures, atomically schedule retries before acknowledgement, and publish initial polls after releasing the preparation lock. Fix Redis connection blocking, durability Hash cleanup, duplicate auction request ordering, and scheduled-job promotion. Use native Redis 8.10 stream, lock, counter, and field-expiring cache operations with invalidation fencing. Repair 90 test type errors and add a repeatable API typecheck command. Validation: 704 API tests, 129 web tests, 31 real Redis integration tests, 3 dependency checks, workspace type checks and builds, and changed-file lint.
124 lines
3.9 KiB
TypeScript
124 lines
3.9 KiB
TypeScript
import { Types } from 'mongoose';
|
|
import { presentPublicMatch } from './match-public.presenter';
|
|
|
|
describe('presentPublicMatch', () => {
|
|
it('whitelists recruiting fields and excludes result/code internals', () => {
|
|
const doubleElimination: NonNullable<
|
|
Parameters<typeof presentPublicMatch>[0]['doubleElimination']
|
|
> & { bracketMatches: Array<{ winnerTeamIndex: number }> } = {
|
|
bracketMatches: [{ winnerTeamIndex: 3 }],
|
|
};
|
|
const response = presentPublicMatch({
|
|
_id: oid('1'),
|
|
communityId: oid('2'),
|
|
competitionId: oid('3'),
|
|
shortCode: '33NW',
|
|
title: '내전',
|
|
joined: false,
|
|
description: '설명',
|
|
mapId: 11,
|
|
status: 'in-progress',
|
|
scheduledAt: new Date('2026-07-12T10:00:00.000Z'),
|
|
maxParticipants: 20,
|
|
gameCount: 3,
|
|
gameMode: 'double-elimination',
|
|
roundRobinMaxRounds: undefined,
|
|
hostUserId: oid('4'),
|
|
participants: [
|
|
{
|
|
userId: oid('5'),
|
|
puuid: 'public-roster-snapshot',
|
|
gameName: '선수',
|
|
tagLine: 'KR1',
|
|
profileIconId: 1,
|
|
tier: {
|
|
queueType: 'RANKED_SOLO_5x5',
|
|
tier: 'GOLD',
|
|
rank: 'I',
|
|
leaguePoints: 42,
|
|
wins: 10,
|
|
losses: 5,
|
|
fetchedAt: new Date('2026-07-10T00:00:00.000Z'),
|
|
puuid: 'secret-tier-puuid',
|
|
},
|
|
preferredPositions: [
|
|
{ position: 'MID', priority: 1 },
|
|
{ position: 'SUP', priority: 2 },
|
|
],
|
|
joinedAt: new Date('2026-07-01T00:00:00.000Z'),
|
|
excluded: false,
|
|
},
|
|
],
|
|
teams: [
|
|
{
|
|
teamIndex: 8,
|
|
name: '똥칼라파워',
|
|
captainUserId: oid('5'),
|
|
members: [{ userId: oid('5'), assignedPosition: 'MID', cost: 42 }],
|
|
},
|
|
],
|
|
prizes: ['상품'],
|
|
notices: ['안내'],
|
|
schedule: [{ time: '20:00', label: '시작' }],
|
|
createdAt: new Date('2026-07-01T00:00:00.000Z'),
|
|
updatedAt: new Date('2026-07-12T00:00:00.000Z'),
|
|
tournamentCodeIds: [oid('6')],
|
|
tournamentCodes: [{ code: 'SECRET' }],
|
|
result: { winnerTeamIndex: 3, games: [], seriesResults: [] },
|
|
doubleElimination,
|
|
resultPollState: { state: 'polling' },
|
|
legacyImportSource: { triggeringPuuid: 'secret' },
|
|
});
|
|
|
|
expect(response).toMatchObject({
|
|
_id: oid('1').toString(),
|
|
communityId: oid('2').toString(),
|
|
competitionId: oid('3').toString(),
|
|
title: '내전',
|
|
doubleEliminationResetFinalEnabled: false,
|
|
scheduledAt: '2026-07-12T10:00:00.000Z',
|
|
participants: [
|
|
expect.objectContaining({
|
|
userId: oid('5').toString(),
|
|
joinedAt: '2026-07-01T00:00:00.000Z',
|
|
tier: {
|
|
queueType: 'RANKED_SOLO_5x5',
|
|
tier: 'GOLD',
|
|
rank: 'I',
|
|
leaguePoints: 42,
|
|
wins: 10,
|
|
losses: 5,
|
|
fetchedAt: '2026-07-10T00:00:00.000Z',
|
|
},
|
|
}),
|
|
],
|
|
teams: [
|
|
{
|
|
teamIndex: 8,
|
|
name: '똥칼라파워',
|
|
captainUserId: oid('5').toString(),
|
|
members: [
|
|
{
|
|
userId: oid('5').toString(),
|
|
assignedPosition: 'MID',
|
|
cost: 42,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
});
|
|
expect(response).not.toHaveProperty('tournamentCodeIds');
|
|
expect(response).not.toHaveProperty('tournamentCodes');
|
|
expect(response).not.toHaveProperty('result');
|
|
expect(response).not.toHaveProperty('doubleElimination');
|
|
expect(response).not.toHaveProperty('resultPollState');
|
|
expect(response).not.toHaveProperty('legacyImportSource');
|
|
expect(response.participants[0]).not.toHaveProperty('puuid');
|
|
expect(response.participants[0]?.tier).not.toHaveProperty('puuid');
|
|
});
|
|
});
|
|
|
|
function oid(suffix: string) {
|
|
return new Types.ObjectId(suffix.padStart(24, '0'));
|
|
}
|