mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-15 16:42:15 +00:00
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.
This commit is contained in:
+5
-2
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user