v0.62.0: fixed 24x world clock — frozen when fully grounded (#135)
CI / build + unit + e2e (pull_request) Successful in 14m3s

This commit is contained in:
2026-09-23 08:09:29 +00:00
parent e970f95036
commit bb4e3b96f3
14 changed files with 122 additions and 124 deletions
+6 -6
View File
@@ -1,11 +1,11 @@
import { describe, expect, it } from 'vitest';
import { advanceSimClock, type SimClockAnchor } from './useSimClock';
import { IDLE_WORLD_TIME_SCALE, WORLD_TIME_SCALE } from './worldClock';
import { WORLD_TIME_SCALE } from './worldClock';
// ISS-007 (v0.16.1) — the pure extrapolation core of lib/useSimClock.ts. The hook itself is a
// thin setInterval + re-sync wrapper covered by e2e (panes.spec.ts "ticks smoothly between polls");
// this suite pins the math: game time advances real-time × WORLD_TIME_SCALE, and slows to
// real-time × IDLE_WORLD_TIME_SCALE while idle (ISS-128).
// this suite pins the math: game time advances real-time × WORLD_TIME_SCALE while something is
// flying or in repair, and stays frozen at the anchor value while fully grounded (#135).
const anchor = (over: Partial<SimClockAnchor> = {}): SimClockAnchor => ({
clockMs: 1_750_000_000_000,
@@ -25,10 +25,10 @@ describe('advanceSimClock', () => {
expect(advanceSimClock(anchor(), 1_000_000)).toBe(1_750_000_000_000);
});
it('advances at the idle real-time rate (IDLE_WORLD_TIME_SCALE) while grounded, not frozen (ISS-128)', () => {
it('stays exactly at the anchor value while grounded (frozen, #135)', () => {
const a = anchor({ advancing: false });
expect(advanceSimClock(a, 1_000_000)).toBe(1_750_000_000_000); // zero elapsed — still the anchor value
expect(advanceSimClock(a, 1_001_000)).toBe(1_750_000_000_000 + 1_000 * IDLE_WORLD_TIME_SCALE); // a full second later — real time, not frozen
expect(advanceSimClock(a, 1_000_000)).toBe(1_750_000_000_000); // zero elapsed — the anchor value
expect(advanceSimClock(a, 1_001_000)).toBe(1_750_000_000_000); // a full second later — still frozen
});
it('clamps to the anchor value when nowMs is before the anchor (clock skew), never backwards', () => {