





























@@ -13,7 +13,7 @@ type BlockReplyPipelineLike = NonNullable<
1313>;
14141515describe("createBlockReplyDeliveryHandler", () => {
16-it("keeps captioned media-bearing block replies buffered when block streaming is disabled", async () => {
16+it("sends captioned media-bearing block replies when block streaming is disabled", async () => {
1717const onBlockReply = vi.fn(async () => {});
1818const normalizeStreamingText = vi.fn((payload: { text?: string }) => ({
1919text: payload.text,
@@ -40,11 +40,57 @@ describe("createBlockReplyDeliveryHandler", () => {
4040replyToCurrent: true,
4141});
424243-expect(onBlockReply).not.toHaveBeenCalled();
44-expect(directlySentBlockKeys).toEqual(new Set());
43+const expectedPayload = {
44+text: "here's the vibe",
45+mediaUrl: "/tmp/generated.png",
46+mediaUrls: ["/tmp/generated.png"],
47+replyToCurrent: true,
48+replyToId: undefined,
49+replyToTag: undefined,
50+audioAsVoice: false,
51+};
52+53+expect(onBlockReply).toHaveBeenCalledWith(expectedPayload);
54+expect(directlySentBlockKeys).toEqual(new Set([createBlockReplyContentKey(expectedPayload)]));
4555expect(typingSignals.signalTextDelta).toHaveBeenCalledWith("here's the vibe");
4656});
475758+it("sends captioned audio-as-voice block replies when block streaming is disabled", async () => {
59+const onBlockReply = vi.fn(async () => {});
60+const directlySentBlockKeys = new Set<string>();
61+62+const handler = createBlockReplyDeliveryHandler({
63+ onBlockReply,
64+normalizeStreamingText: (payload) => ({ text: payload.text, skip: false }),
65+applyReplyToMode: (payload) => payload,
66+typingSignals: {
67+signalTextDelta: vi.fn(async () => {}),
68+} as unknown as TypingSignaler,
69+blockStreamingEnabled: false,
70+blockReplyPipeline: null,
71+ directlySentBlockKeys,
72+});
73+74+await handler({
75+text: "spoken confirmation",
76+mediaUrls: ["/tmp/voice.opus"],
77+audioAsVoice: true,
78+});
79+80+const expectedPayload = {
81+text: "spoken confirmation",
82+mediaUrl: "/tmp/voice.opus",
83+mediaUrls: ["/tmp/voice.opus"],
84+replyToId: undefined,
85+replyToCurrent: undefined,
86+replyToTag: undefined,
87+audioAsVoice: true,
88+};
89+90+expect(onBlockReply).toHaveBeenCalledWith(expectedPayload);
91+expect(directlySentBlockKeys).toEqual(new Set([createBlockReplyContentKey(expectedPayload)]));
92+});
93+4894it("sends media-only block replies when block streaming is disabled", async () => {
4995const onBlockReply = vi.fn(async () => {});
5096const directlySentBlockKeys = new Set<string>();
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。