Add heartbeat telemetry support

This commit is contained in:
2026-09-19 21:52:05 -04:00
parent 8ac420fe61
commit ce0321a6e9
14 changed files with 63 additions and 21 deletions
+12
View File
@@ -6,6 +6,18 @@ import { gameEvent } from '../helpers/telemetry.js';
const planWith = (...kinds: Parameters<typeof requirement>[0][]): BetaPlan => ({ ...defaultPlan(), requirements: kinds.map((k, i) => requirement(k, `r${i}`)) });
describe('beta requirement evaluation', () => {
it('credits heartbeat participation during a long round without completing a match', () => {
const plan = planWith('populated-minutes', 'round', 'matches');
const m = emptyMetrics();
applyGameEvent(plan, m, gameEvent('game_start'), 0);
applyGameEvent(plan, m, gameEvent('round_change', 30), 60_000);
applyGameEvent(plan, m, gameEvent('heartbeat', 30), 120_000);
applyGameEvent(plan, m, gameEvent('heartbeat', 30), 180_000);
expect(m.values).toMatchObject({ r0: 3, r1: 30 });
expect(m.values.r2 ?? 0).toBe(0);
expect(m.match).toMatchObject({ started: 0, lastEvent: 180_000, ended: false });
});
it('copies reactive presets without mutating saved requirements', () => {
const source = defaultPlan();
const selected = parseBetaPlan(new Proxy(source, {}));