feat: expand intelligent investigation workspace
This commit is contained in:
@@ -158,3 +158,44 @@ describe("live investigation presentation following", () => {
|
||||
} finally { oldDisplay.resolve(); test.follower.stop(); }
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it("buffers live events while saved history is loading and drains only after that boundary", async () => {
|
||||
const ready = deferred<void>();
|
||||
const loadHistory = vi.fn(async () => ready.promise);
|
||||
const test = setup({ loadHistory });
|
||||
test.follower.start(); test.channel.publish({ type: "open" });
|
||||
try {
|
||||
await vi.waitFor(() => expect(loadHistory).toHaveBeenCalledTimes(1));
|
||||
test.channel.publish({ type: "events", events: [event(11, openChart)] });
|
||||
expect(test.execute).not.toHaveBeenCalled();
|
||||
ready.resolve();
|
||||
await vi.waitFor(() => expect(test.execute).toHaveBeenCalledTimes(1));
|
||||
} finally { test.follower.stop(); }
|
||||
});
|
||||
|
||||
it("loads saved history without live following and aborts an unfinished history load on stop", async () => {
|
||||
const ready = deferred<void>();
|
||||
const loadHistory = vi.fn(async (_cursor: InvestigationPresentationCursor, _signal: AbortSignal) => ready.promise);
|
||||
const subscribe = vi.fn();
|
||||
const test = setup({ follow: false, loadHistory, subscribe });
|
||||
test.follower.start();
|
||||
await vi.waitFor(() => expect(loadHistory).toHaveBeenCalledTimes(1));
|
||||
expect(subscribe).not.toHaveBeenCalled();
|
||||
test.follower.stop();
|
||||
expect(loadHistory.mock.calls[0][1].aborted).toBe(true);
|
||||
ready.resolve();
|
||||
expect(test.execute).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
it("reads saved history even before the live event stream opens", async () => {
|
||||
const loadHistory = vi.fn(async () => undefined);
|
||||
const test = setup({ loadHistory });
|
||||
test.follower.start();
|
||||
try {
|
||||
await vi.waitFor(() => expect(loadHistory).toHaveBeenCalledTimes(1));
|
||||
await vi.waitFor(() => expect(test.onStatus).toHaveBeenCalledWith("history"));
|
||||
expect(test.execute).not.toHaveBeenCalled();
|
||||
} finally { test.follower.stop(); }
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user