perf(test): merge block-streaming scenarios into single fixture run

This commit is contained in:
Peter Steinberger
2026-02-13 23:54:22 +00:00
parent 9bd2ccb017
commit 23e8f3a20a

View File

@@ -98,7 +98,7 @@ describe("block streaming", () => {
]);
});
it("waits for block replies and preserves ordering when typing start is slow", async () => {
it("handles ordering, timeout fallback, and telegram streamMode block", async () => {
await withTempHome(async (home) => {
let releaseTyping: (() => void) | undefined;
const typingGate = new Promise<void>((resolve) => {
@@ -161,13 +161,9 @@ describe("block streaming", () => {
const res = await replyPromise;
expect(res).toBeUndefined();
expect(seen).toEqual(["first\n\nsecond"]);
});
});
it("falls back to final payloads and respects telegram streamMode block", async () => {
await withTempHome(async (home) => {
let sawAbort = false;
const onBlockReply = vi.fn((_, context) => {
const onBlockReplyTimeout = vi.fn((_, context) => {
return new Promise<void>((resolve) => {
context?.abortSignal?.addEventListener(
"abort",
@@ -180,7 +176,7 @@ describe("block streaming", () => {
});
});
const impl = async (params: RunEmbeddedPiAgentParams) => {
const timeoutImpl = async (params: RunEmbeddedPiAgentParams) => {
void params.onBlockReply?.({ text: "streamed" });
return {
payloads: [{ text: "final" }],
@@ -190,9 +186,9 @@ describe("block streaming", () => {
},
};
};
piEmbeddedMock.runEmbeddedPiAgent.mockImplementation(impl);
piEmbeddedMock.runEmbeddedPiAgent.mockImplementation(timeoutImpl);
const replyPromise = getReplyFromConfig(
const timeoutReplyPromise = getReplyFromConfig(
{
Body: "ping",
From: "+1004",
@@ -201,7 +197,7 @@ describe("block streaming", () => {
Provider: "telegram",
},
{
onBlockReply,
onBlockReply: onBlockReplyTimeout,
blockReplyTimeoutMs: 1,
disableBlockStreaming: false,
},
@@ -217,8 +213,8 @@ describe("block streaming", () => {
},
);
const res = await replyPromise;
expect(res).toMatchObject({ text: "final" });
const timeoutRes = await timeoutReplyPromise;
expect(timeoutRes).toMatchObject({ text: "final" });
expect(sawAbort).toBe(true);
const onBlockReplyStreamMode = vi.fn().mockResolvedValue(undefined);