From 074db2f547405012eb7c5f4865932a72539c797b Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 14 Jul 2026 10:47:40 +0000 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_0136N3FnyuUmLJbMNJiZd6YX --- .../server/src/stores/__tests__/runtimeState.test.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/server/src/stores/__tests__/runtimeState.test.ts b/apps/server/src/stores/__tests__/runtimeState.test.ts index 8d8415545..fbc16e0ba 100644 --- a/apps/server/src/stores/__tests__/runtimeState.test.ts +++ b/apps/server/src/stores/__tests__/runtimeState.test.ts @@ -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