Retain live history and warn on silent equities feeds
- Keep pausable live snapshots visible while stale - Surface a connected-but-silent equities warning - Add coverage for history retention and warning timing
This commit is contained in:
parent
89aaf63d34
commit
da942079f3
2 changed files with 161 additions and 15 deletions
|
|
@ -5,7 +5,10 @@ import {
|
|||
flushPausableTapeData,
|
||||
getLiveFeedStatus,
|
||||
nextFlowFilterPopoverState,
|
||||
projectPausableTapeState,
|
||||
reducePausableTapeData,
|
||||
shouldRetainLiveSnapshotHistory,
|
||||
shouldShowEquitiesSilentFeedWarning,
|
||||
toggleFilterValue
|
||||
} from "./terminal";
|
||||
|
||||
|
|
@ -53,6 +56,55 @@ describe("live tape pausable helpers", () => {
|
|||
expect(getLiveFeedStatus("connected", 1000, 500, 1601)).toBe("stale");
|
||||
expect(getLiveFeedStatus("disconnected", 1000, 500, 1601)).toBe("disconnected");
|
||||
});
|
||||
|
||||
it("keeps visible history even when live status is stale", () => {
|
||||
const projected = projectPausableTapeState([makeItem("stale", 7, 1000)], "stale", 2000);
|
||||
expect(projected.items.map((item) => item.trace_id)).toEqual(["stale"]);
|
||||
expect(projected.lastUpdate).toBeNull();
|
||||
});
|
||||
|
||||
it("flags connected equities feeds that stay silent past threshold", () => {
|
||||
expect(
|
||||
shouldShowEquitiesSilentFeedWarning({
|
||||
wsStatus: "connected",
|
||||
equitiesSubscribed: true,
|
||||
connectedAt: 1_000,
|
||||
lastEquitiesEventAt: null,
|
||||
now: 20_000,
|
||||
thresholdMs: 25_000
|
||||
})
|
||||
).toBe(false);
|
||||
|
||||
expect(
|
||||
shouldShowEquitiesSilentFeedWarning({
|
||||
wsStatus: "connected",
|
||||
equitiesSubscribed: true,
|
||||
connectedAt: 1_000,
|
||||
lastEquitiesEventAt: null,
|
||||
now: 27_000,
|
||||
thresholdMs: 25_000
|
||||
})
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
shouldShowEquitiesSilentFeedWarning({
|
||||
wsStatus: "connected",
|
||||
equitiesSubscribed: true,
|
||||
connectedAt: 1_000,
|
||||
lastEquitiesEventAt: 20_000,
|
||||
now: 40_000,
|
||||
thresholdMs: 25_000
|
||||
})
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("retains live history when freshness-gated snapshots are empty", () => {
|
||||
expect(shouldRetainLiveSnapshotHistory("options", true, 0, 3)).toBe(true);
|
||||
expect(shouldRetainLiveSnapshotHistory("equities", true, 0, 2)).toBe(true);
|
||||
expect(shouldRetainLiveSnapshotHistory("alerts", true, 0, 3)).toBe(false);
|
||||
expect(shouldRetainLiveSnapshotHistory("options", true, 1, 3)).toBe(false);
|
||||
expect(shouldRetainLiveSnapshotHistory("options", false, 0, 3)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("flow filter popup helpers", () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue