From 146fdd04e433f21fbc9b1998ca9d9e711f824282 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Fri, 17 Jul 2026 16:02:07 +0100 Subject: [PATCH] test(frontend): capture cache timestamps once in the happy-path hit assertion Same millisecond-tick flake as the boundary test fixed in 63c2118a1, one test further down the file: the assertion recomputed now() - 5_000 after the write, so any tick between the two calls failed the exact oldestDataTimestamp comparison in CI. --- .../infrastructureSummaryCache.branchcov0717.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend-modern/src/utils/__tests__/infrastructureSummaryCache.branchcov0717.test.ts b/frontend-modern/src/utils/__tests__/infrastructureSummaryCache.branchcov0717.test.ts index 6ff73574b9..521fc0c345 100644 --- a/frontend-modern/src/utils/__tests__/infrastructureSummaryCache.branchcov0717.test.ts +++ b/frontend-modern/src/utils/__tests__/infrastructureSummaryCache.branchcov0717.test.ts @@ -299,12 +299,15 @@ describe('readInfrastructureSummaryCache — hit / miss / expiry / empty boundar }); it('returns a cache hit with the exact cachedAt timestamp on the happy path', () => { + // Capture both timestamps once: calling now() again in the assertion + // fails whenever a millisecond ticks between the write and the expect. const cachedAt = now() - 1_000; + const oldestDataTimestamp = now() - 5_000; storePayload( '1h', buildPayload({ cachedAt, - oldestDataTimestamp: now() - 5_000, + oldestDataTimestamp, charts: { 'node-1': { cpu: makeSeries(2), memory: [], disk: [], diskread: [], diskwrite: [], netin: [], netout: [] }, }, @@ -313,7 +316,7 @@ describe('readInfrastructureSummaryCache — hit / miss / expiry / empty boundar const hit = readInfrastructureSummaryCache('1h'); expect(hit).not.toBeNull(); expect(hit?.cachedAt).toBe(cachedAt); - expect(hit?.oldestDataTimestamp).toBe(now() - 5_000); + expect(hit?.oldestDataTimestamp).toBe(oldestDataTimestamp); expect(hit?.map.get('node-1')?.cpu?.length).toBe(2); });