Add heartbeat telemetry support
This commit is contained in:
@@ -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, {}));
|
||||
|
||||
Reference in New Issue
Block a user