




















@@ -100,3 +100,74 @@ describe("createBlockReplyPipeline dedup with threading", () => {
100100expect(sent).toEqual(["Alpha", "Beta"]);
101101});
102102});
103+104+describe("createBlockReplyPipeline content coverage dedup", () => {
105+it("matches final assembled text to successfully streamed text chunks after abort", async () => {
106+let callCount = 0;
107+const pipeline = createBlockReplyPipeline({
108+onBlockReply: async () => {
109+callCount += 1;
110+if (callCount === 3) {
111+await new Promise((resolve) => setTimeout(resolve, 50));
112+}
113+},
114+timeoutMs: 1,
115+});
116+117+pipeline.enqueue({ text: "First paragraph." });
118+pipeline.enqueue({ text: "Second paragraph." });
119+pipeline.enqueue({ text: "Third paragraph." });
120+await pipeline.flush({ force: true });
121+122+expect(pipeline.didStream()).toBe(true);
123+expect(pipeline.isAborted()).toBe(true);
124+expect(pipeline.hasSentPayload({ text: "First paragraph.\n\nSecond paragraph." })).toBe(true);
125+});
126+127+it("does not match final assembled text with content that was not streamed", async () => {
128+let callCount = 0;
129+const pipeline = createBlockReplyPipeline({
130+onBlockReply: async () => {
131+callCount += 1;
132+if (callCount === 2) {
133+await new Promise((resolve) => setTimeout(resolve, 50));
134+}
135+},
136+timeoutMs: 1,
137+});
138+139+pipeline.enqueue({ text: "First paragraph." });
140+pipeline.enqueue({ text: "Second paragraph." });
141+await pipeline.flush({ force: true });
142+143+expect(pipeline.didStream()).toBe(true);
144+expect(pipeline.isAborted()).toBe(true);
145+expect(pipeline.hasSentPayload({ text: "First paragraph.\n\nSecond paragraph." })).toBe(false);
146+});
147+148+it("does not suppress media payloads through streamed text coverage", async () => {
149+const pipeline = createBlockReplyPipeline({
150+onBlockReply: async () => {},
151+timeoutMs: 5000,
152+});
153+154+pipeline.enqueue({ text: "Description" });
155+await pipeline.flush({ force: true });
156+157+expect(pipeline.hasSentPayload({ text: "Description", mediaUrl: "file:///photo.jpg" })).toBe(
158+false,
159+);
160+});
161+162+it("does not suppress unrelated shorter text that appears inside streamed content", async () => {
163+const pipeline = createBlockReplyPipeline({
164+onBlockReply: async () => {},
165+timeoutMs: 5000,
166+});
167+168+pipeline.enqueue({ text: "Here is a summary." });
169+await pipeline.flush({ force: true });
170+171+expect(pipeline.hasSentPayload({ text: "summary" })).toBe(false);
172+});
173+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。