feat: enhance auction interactions and player statistics UI

This commit is contained in:
dahyeon committed 2026-11-11 20:06:22 +09:00
1 parent 6c582ba3cf
commit be4de61bb7
115 files changed
+13292 -2871

No files matched your search

@@ -5,6 +5,72 @@ import { MatchHistoryService } from './match-history.service';
const SEASON_START = Date.parse('2026-01-01T00:00:00Z');
describe('MatchHistoryService champion filtering', () => {
it('selects a lane before limiting and uses only the requested participant, including legacy individualPosition', async () => {
const { service, scope, find } = createHarness();
const result = await service.getRecentMatches({
...scope,
filters: { rank: 'solo', lane: 'MIDDLE', limit: 20 },
});
expect(result.matches.map((game) => game.matchId)).toEqual([
'KR_3',
'KR_2',
'KR_1',
]);
expect(result.matches.every((game) => game.teamPosition === 'MIDDLE')).toBe(
true,
);
expect(result.matches[0].damageShare).toBe(100);
expect(find.mock.calls[0][0]['raw.info.participants']?.$elemMatch).toEqual({
puuid: 'player',
$or: [
{ teamPosition: 'MIDDLE' },
{ teamPosition: { $in: ['', null] }, individualPosition: 'MIDDLE' },
],
});
});
it('combines champion and lane filtering and rejects invalid lanes', async () => {
const { service, scope } = createHarness();
const result = await service.getRecentMatches({
...scope,
filters: { rank: 'solo', championId: 1, lane: 'MIDDLE', limit: 20 },
});
expect(result.matches).toEqual([]);
await expect(
service.getRecentMatches({ ...scope, filters: { lane: 'unknown' } }),
).rejects.toThrow('Invalid lane');
});
it('counts independent lane windows across the season and caps each at twenty', async () => {
const { service, scope, aggregate } = createHarness();
const result = await service.getRecentMatches({
...scope,
filters: {
rank: 'solo',
lane: 'MIDDLE',
limit: 20,
includePositionCounts: true,
},
});
expect(result.positionCounts).toEqual({
ALL: 20,
TOP: 20,
JUNGLE: 0,
MIDDLE: 3,
BOTTOM: 0,
UTILITY: 0,
});
expect(aggregate.mock.calls[0][0][0]).toEqual({
$match: {
participantPuuids: 'player',
queueId: { $in: [420] },
gameCreation: { $gte: SEASON_START },
},
});
expect(JSON.stringify(aggregate.mock.calls[0][0])).toContain('$$p.puuid');
expect(JSON.stringify(aggregate.mock.calls[0][0])).not.toContain('$limit');
});
it('paginates matching games beyond 120 newer games and excludes opponents using the champion', async () => {
const harness = createHarness();
const filters = { championId: 99, rank: 'solo', limit: 2 };
@@ -77,7 +143,14 @@ interface HistoryQuery {
queueId: { $in: number[] };
gameCreation?: { $gte?: number; $lt?: number };
'raw.info.participants'?: {
$elemMatch: { puuid: string; championId: number };
$elemMatch: {
puuid: string;
championId?: number;
$or?: Array<{
teamPosition: string | { $in: (string | null)[] };
individualPosition?: string;
}>;
};
};
}
@@ -122,7 +195,18 @@ function createHarness() {
row.raw.info.participants.some(
(entry) =>
entry.puuid === participant.puuid &&
entry.championId === participant.championId,
(participant.championId === undefined ||
entry.championId === participant.championId) &&
(!participant.$or ||
participant.$or.some((condition) =>
typeof condition.teamPosition === 'string'
? entry.teamPosition === condition.teamPosition
: condition.teamPosition.$in.includes(
entry.teamPosition ?? null,
) &&
entry.individualPosition ===
condition.individualPosition,
)),
)),
)
.sort((a, b) => b.gameCreation - a.gameCreation)
@@ -133,6 +217,15 @@ function createHarness() {
};
return query;
});
const aggregate = jest.fn<
{ exec: () => Promise<Array<{ _id: string; count: number }>> },
[unknown[]]
>(() => ({
exec: async () => [
{ _id: 'TOP', count: 127 },
{ _id: 'MIDDLE', count: 3 },
],
}));
const models = {
user: {
find: () => ({
@@ -179,7 +272,7 @@ function createHarness() {
}),
}),
},
riotMatch: { find },
riotMatch: { find, aggregate },
};
const connection = {
getModel: async (name: keyof typeof models) => models[name],
@@ -190,6 +283,7 @@ function createHarness() {
find,
select,
returnedCounts,
aggregate,
};
}
@@ -198,6 +292,9 @@ function storedMatch(sequence: number, championId: number, queueId = 420) {
const participant = {
puuid: 'player',
championId,
teamPosition:
sequence === 2 ? undefined : championId === 99 ? 'MIDDLE' : 'TOP',
individualPosition: championId === 99 ? 'MIDDLE' : 'TOP',
teamId: 100,
win: true,
kills: 5,
@@ -229,6 +326,7 @@ function storedMatch(sequence: number, championId: number, queueId = 420) {
puuid: 'opponent',
teamId: 200,
championId: 99,
teamPosition: 'MIDDLE',
win: false,
},
],