Fix keyed telemetry match attribution (Refs #144)
CI / checks (push) Successful in 5m26s

This commit is contained in:
2026-10-12 00:58:05 -04:00
parent 4ea291d305
commit 785cc4616b
24 changed files with 1115 additions and 112 deletions
+38
View File
@@ -104,6 +104,44 @@ it('keeps unknown durations last in either direction and retains historical and
});
expect(data.matches.find((m) => m.id === 5)?.uniquePlayers).toBe(0);
});
it('filters missing end reports and exposes sequence gaps without completed results', async () => {
const { db } = await import('../../src/lib/server/db/index.js');
db()
.prepare(
`UPDATE leaderboard_matches
SET status = 'end-report-missing', reporter_match_key = 'game-a', last_seq = 8, report_count = 6
WHERE id = 4`
)
.run();
const { serverMatchHistory, getMatchDetail } =
await import('../../src/lib/server/fleet/match-history.js');
const data = serverMatchHistory(undefined, 25, query('status=end-report-missing'));
expect(data).toMatchObject({
total: 1,
matches: [
{
id: 4,
status: 'end-report-missing',
reporterMatchKey: 'game-a',
missingReports: 2,
observedRound: 5,
finalRound: null,
durationMs: null,
endedAt: null,
endPlayers: null
}
]
});
expect(getMatchDetail(4)).toBeNull();
expect(serverMatchHistory().matches[0]).toMatchObject({
reporterMatchKey: null,
missingReports: null
});
db().prepare('UPDATE leaderboard_matches SET report_count = 8 WHERE id = 4').run();
expect(
serverMatchHistory(undefined, 25, query('status=end-report-missing')).matches[0]
).toMatchObject({ missingReports: 0 });
});
it('validates both API routes and loads the same filtered page on a direct page visit', async () => {
const { GET } = await import('../../src/routes/api/matches/+server.js');
const { GET: instanceGET } =