This commit is contained in:
@@ -88,6 +88,31 @@ async function live() {
|
||||
};
|
||||
}
|
||||
|
||||
it('retains totals through spending, missing fields, duplicate/stale reports and delayed completion', async () => {
|
||||
await report('one', 1, 'game_start');
|
||||
const first = await report('one', 2, 'heartbeat', 17, [
|
||||
player('ace', { score: 32000, score_total: 62000 })
|
||||
]);
|
||||
const id = first.timing!.matchId;
|
||||
await report('one', 3, 'heartbeat', 17, [player('ace', { score: 28000, score_total: 63000 })]);
|
||||
// A retried sequence cannot change the total even if its body differs.
|
||||
await report('one', 3, 'heartbeat', 17, [player('ace', { score: 99000, score_total: 999999 })]);
|
||||
// A legacy-shaped snapshot cannot erase a known total.
|
||||
await report('one', 6, 'heartbeat', 18, [player('ace', { score: 29000 })]);
|
||||
await report('one', 4, 'heartbeat', 18, [player('ace', { score: 99000, score_total: 999999 })]);
|
||||
expect(await participation(id)).toMatchObject([{ best_score: 32000, score_total: 63000 }]);
|
||||
// An unseen older end can complete the match and preserve its final total.
|
||||
await report('one', 5, 'game_end', 18, [player('ace', { score: 25200, score_total: 65000 })]);
|
||||
expect(await participation(id)).toMatchObject([{ best_score: 32000, score_total: 65000 }]);
|
||||
const { getMatchDetail } = await import('../../src/lib/server/fleet/match-history.js');
|
||||
expect(getMatchDetail(id)?.players[0]).toMatchObject({ bestScore: 32000, scoreTotal: 65000 });
|
||||
const { closeDb } = await import('../../src/lib/server/db/index.js');
|
||||
closeDb();
|
||||
expect(getMatchDetail(id)?.players[0].scoreTotal).toBe(65000);
|
||||
const next = await report('two', 1, 'game_start');
|
||||
expect(await participation(next.timing!.matchId)).toMatchObject([{ score_total: null }]);
|
||||
});
|
||||
|
||||
it('deduplicates a retried sequence after intervening reports and a database reopen', async () => {
|
||||
await report('one', 1, 'game_start');
|
||||
await report('one', 2, 'round_change', 2, [player('ace', { kills: 10 })]);
|
||||
|
||||
Reference in New Issue
Block a user