test(timer): assert elapsed stays frozen while paused over midnight

Make the midnight pause test's intent explicit: elapsed is active time
since start and must not advance during a pause (even one crossing
midnight). Add a frozen-elapsed assertion while paused and keep
pausedDuration - the corrupted pause count - as the headline assertion.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0136N3FnyuUmLJbMNJiZd6YX
This commit is contained in:
Claude
2026-07-14 10:47:40 +00:00
committed by Carlos Valente
parent 361b6eb875
commit a67dbd8a59
@@ -280,13 +280,19 @@ describe('mutation on runtimeState', () => {
expect(getState().timer.elapsed).toBe(8 * MILLIS_PER_MINUTE);
pause();
// resume 5 minutes later, having crossed midnight (23:58 -> 00:03)
// elapsed is active time since start, so it must not advance while paused,
// not even when the pause itself crosses midnight
vi.setSystemTime('jan 2 00:01');
update();
expect(getState().timer.elapsed).toBe(8 * MILLIS_PER_MINUTE);
// resume 5 minutes after pausing, having crossed midnight (23:58 -> 00:03)
vi.setSystemTime('jan 2 00:03');
start();
let state = getState();
// the pause lasted 5 minutes, regardless of the midnight wrap
// the accumulated pause count is 5 minutes, regardless of the midnight wrap
expect(state._timer.pausedDuration).toBe(5 * MILLIS_PER_MINUTE);
// elapsed must still exclude the paused time -> only the 8 active minutes
// and elapsed still reflects only the 8 active minutes
expect(state.timer.elapsed).toBe(8 * MILLIS_PER_MINUTE);
// 2 more active minutes after resume -> 10 minutes elapsed