






















@@ -36,6 +36,20 @@ describe("createBlockReplyPayloadKey", () => {
3636expect(a).not.toBe(b);
3737});
383839+it("produces different keys for payloads with different presentation content", () => {
40+const a = createBlockReplyPayloadKey({
41+presentation: {
42+blocks: [{ type: "buttons", buttons: [{ label: "Approve", value: "approve" }] }],
43+},
44+});
45+const b = createBlockReplyPayloadKey({
46+presentation: {
47+blocks: [{ type: "buttons", buttons: [{ label: "Reject", value: "reject" }] }],
48+},
49+});
50+expect(a).not.toBe(b);
51+});
52+3953it("trims whitespace from text for key comparison", () => {
4054const a = createBlockReplyPayloadKey({ text: " hello " });
4155const b = createBlockReplyPayloadKey({ text: "hello" });
@@ -51,6 +65,29 @@ describe("createBlockReplyContentKey", () => {
5165expect(a).toBe(b);
5266expect(a).toBe(c);
5367});
68+69+it("keeps rich content in the reply-independent content key", () => {
70+const a = createBlockReplyContentKey({
71+presentation: {
72+blocks: [{ type: "buttons", buttons: [{ label: "Approve", value: "approve" }] }],
73+},
74+replyToId: "post-1",
75+});
76+const b = createBlockReplyContentKey({
77+presentation: {
78+blocks: [{ type: "buttons", buttons: [{ label: "Approve", value: "approve" }] }],
79+},
80+replyToId: "post-2",
81+});
82+const c = createBlockReplyContentKey({
83+presentation: {
84+blocks: [{ type: "buttons", buttons: [{ label: "Reject", value: "reject" }] }],
85+},
86+replyToId: "post-1",
87+});
88+expect(a).toBe(b);
89+expect(a).not.toBe(c);
90+});
5491});
55925693describe("createBlockReplyPipeline dedup with threading", () => {
@@ -106,6 +143,30 @@ describe("createBlockReplyPipeline dedup with threading", () => {
106143]);
107144});
108145146+it("keeps separate deliveries for distinct rich-only payloads", async () => {
147+const sent: Array<{ presentation?: unknown }> = [];
148+const pipeline = createBlockReplyPipeline({
149+onBlockReply: async (payload) => {
150+sent.push({ presentation: payload.presentation });
151+},
152+timeoutMs: 5000,
153+});
154+155+pipeline.enqueue({
156+presentation: {
157+blocks: [{ type: "buttons", buttons: [{ label: "Approve", value: "approve" }] }],
158+},
159+});
160+pipeline.enqueue({
161+presentation: {
162+blocks: [{ type: "buttons", buttons: [{ label: "Reject", value: "reject" }] }],
163+},
164+});
165+await pipeline.flush({ force: true });
166+167+expect(sent).toHaveLength(2);
168+});
169+109170it("does not track media when text-only blocks are delivered", async () => {
110171const pipeline = createBlockReplyPipeline({
111172onBlockReply: async () => {},
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。