gateway: add chat.send block streaming regression coverage

This commit is contained in:
Gustavo Madeira Santana
2026-02-18 16:07:01 -05:00
parent 2076ce96af
commit 0e45297f4e

View File

@@ -136,6 +136,42 @@ describe("gateway server chat", () => {
});
});
test("chat.send does not force-disable block streaming", async () => {
await withGatewayChatHarness(async ({ ws, createSessionDir }) => {
const spy = vi.mocked(getReplyFromConfig) as unknown as ReturnType<typeof vi.fn>;
await connectOk(ws);
await createSessionDir();
await writeMainSessionStore();
testState.agentConfig = { blockStreamingDefault: "on" };
try {
spy.mockReset();
let capturedOpts: Record<string, unknown> | undefined;
spy.mockImplementationOnce(async (_ctx, opts) => {
capturedOpts = opts as Record<string, unknown> | undefined;
});
const sendRes = await rpcReq(ws, "chat.send", {
sessionKey: "main",
message: "hello",
idempotencyKey: "idem-block-streaming",
});
expect(sendRes.ok).toBe(true);
await vi.waitFor(
() => {
expect(spy.mock.calls.length).toBeGreaterThan(0);
},
{ timeout: 2_000, interval: 10 },
);
expect(capturedOpts?.disableBlockStreaming).toBeUndefined();
} finally {
testState.agentConfig = undefined;
}
});
});
test("chat.history hard-caps single oversized nested payloads", async () => {
await withGatewayChatHarness(async ({ ws, createSessionDir }) => {
const historyMaxBytes = 64 * 1024;