Simplify match history with filters and persistent pagination

This commit is contained in:
2026-10-06 19:23:19 -04:00
parent 1370873cba
commit 711191c388
13 changed files with 419 additions and 103 deletions
+5 -5
View File
@@ -68,7 +68,7 @@ it('publishes round 2 or higher games only after game end, preserving early stat
await report('round_change', 1, [player(undefined, { kills: 6, score: 1000 }), departed]);
expect(getLeaderboard()).toMatchObject({ entries: [], maps: [], total: 0, summary: { players: 0, matches: 0, kills: 0 } });
expect(getPlayerProfile(player().guid)).toBeNull();
expect(serverMatchHistory()).toEqual({ total: 0, matches: [] });
expect(serverMatchHistory()).toEqual({ total: 0, matches: [], maps: [], page: 1, limit: 25 });
await report('round_change', 2, [player(undefined, { kills: 6, score: 500 })]);
expect(getLeaderboard()).toMatchObject({ entries: [], maps: [], total: 0, summary: { players: 0, matches: 0, kills: 0 } });
expect(getPlayerProfile(player().guid)).toBeNull();
@@ -94,9 +94,9 @@ it('publishes round 2 or higher games only after game end, preserving early stat
expect(getPlayerProfile(player().guid)).toMatchObject({ stats: profile!.stats, maps: profile!.maps, matches: profile!.matches });
expect(serverMatchHistory()).toEqual(history);
const { GET } = await import('../../src/routes/api/matches/+server.js');
expect(await GET({ url: new URL('http://localhost/api/matches?limit=1') }).json()).toEqual(history);
expect(await GET({ url: new URL('http://localhost/api/matches?limit=1') }).json()).toEqual({ ...history, limit: 1 });
const { GET: serverGET } = await import('../../src/routes/api/servers/[name]/matches/+server.js');
expect(await serverGET({ params: { name: server }, url: new URL('http://localhost/?limit=1') }).json()).toEqual(history);
expect(await serverGET({ params: { name: server }, url: new URL('http://localhost/?limit=1') }).json()).toEqual({ ...history, limit: 1 });
});
it('records server match counts, unique rejoins, duration, and final round durably', async () => {
@@ -108,11 +108,11 @@ it('records server match counts, unique rejoins, duration, and final round durab
const { closeDb } = await import('../../src/lib/server/db/index.js');
closeDb();
const { serverMatchHistory } = await import('../../src/lib/server/fleet/match-history.js');
expect(serverMatchHistory(server)).toEqual({ total: 1, matches: [expect.objectContaining({
expect(serverMatchHistory(server)).toMatchObject({ total: 1, matches: [expect.objectContaining({
status: 'completed', startPlayers: 2, uniquePlayers: 3, endPlayers: 1,
durationMs: 3000, finalRound: 7, endedAt: '2026-09-18T20:00:03.000Z'
})] });
expect(serverMatchHistory('other')).toEqual({ total: 0, matches: [] });
expect(serverMatchHistory('other')).toEqual({ total: 0, matches: [], maps: [], page: 1, limit: 25 });
});
it('preserves unknown boundaries and distinguishes empty rosters from missing observations', async () => {