



























@@ -4,6 +4,10 @@ import {
44emitAssistantTextDeltaAndEnd,
55} from "./pi-embedded-subscribe.e2e-harness.js";
667+function blockReplyTexts(onBlockReply: ReturnType<typeof vi.fn>): string[] {
8+return onBlockReply.mock.calls.map(([payload]) => (payload as { text?: string }).text ?? "");
9+}
10+711describe("subscribeEmbeddedPiSession", () => {
812it("streams soft chunks with paragraph preference", () => {
913const onBlockReply = vi.fn();
@@ -20,8 +24,7 @@ describe("subscribeEmbeddedPiSession", () => {
2024emitAssistantTextDeltaAndEnd({ emit, text });
21252226expect(onBlockReply).toHaveBeenCalledTimes(2);
23-expect(onBlockReply.mock.calls.at(0)?.[0]?.text).toBe("First block line");
24-expect(onBlockReply.mock.calls.at(1)?.[0]?.text).toBe("Second block line");
27+expect(blockReplyTexts(onBlockReply)).toEqual(["First block line", "Second block line"]);
2528expect(subscription.assistantTexts).toEqual(["First block line", "Second block line"]);
2629});
2730it("avoids splitting inside fenced code blocks", () => {
@@ -39,8 +42,6 @@ describe("subscribeEmbeddedPiSession", () => {
3942emitAssistantTextDeltaAndEnd({ emit, text });
40434144expect(onBlockReply).toHaveBeenCalledTimes(3);
42-expect(onBlockReply.mock.calls.at(0)?.[0]?.text).toBe("Intro");
43-expect(onBlockReply.mock.calls.at(1)?.[0]?.text).toBe("```bash\nline1\nline2\n```");
44-expect(onBlockReply.mock.calls.at(2)?.[0]?.text).toBe("Outro");
45+expect(blockReplyTexts(onBlockReply)).toEqual(["Intro", "```bash\nline1\nline2\n```", "Outro"]);
4546});
4647});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。