

























@@ -199,8 +199,12 @@ describe("matrix group chat history — scenario 1: basic accumulation", () => {
199199const ctx = finalizeInboundContext.mock.calls[1]?.[0] as Record<string, unknown>;
200200const history = ctx["InboundHistory"] as Array<{ body: string }>;
201201expect(history).toHaveLength(2);
202-expect(history.map((h) => h.body).some((b) => b.includes("msg A"))).toBe(true);
203-expect(history.map((h) => h.body).some((b) => b.includes("msg B"))).toBe(true);
202+expect(history.map((h) => h.body)).toEqual(
203+expect.arrayContaining([expect.stringContaining("msg A")]),
204+);
205+expect(history.map((h) => h.body)).toEqual(
206+expect.arrayContaining([expect.stringContaining("msg B")]),
207+);
204208}
205209206210// @agent_b trigger D — A/B/C consumed; history is empty
@@ -393,7 +397,9 @@ describe("matrix group chat history — scenario 1: basic accumulation", () => {
393397expect(finalizeInboundContext).toHaveBeenCalledOnce();
394398const ctx = finalizeInboundContext.mock.calls[0]?.[0] as Record<string, unknown>;
395399const history = ctx["InboundHistory"] as Array<{ body: string }> | undefined;
396-expect(history?.some((entry) => entry.body.includes("[matrix image attachment]"))).toBe(true);
400+expect(history?.map((entry) => entry.body)).toEqual(
401+expect.arrayContaining([expect.stringContaining("[matrix image attachment]")]),
402+);
397403});
398404399405it("includes skipped poll updates in next trigger history", async () => {
@@ -458,7 +464,9 @@ describe("matrix group chat history — scenario 1: basic accumulation", () => {
458464expect(getRelations).toHaveBeenCalledOnce();
459465const ctx = finalizeInboundContext.mock.calls[0]?.[0] as Record<string, unknown>;
460466const history = ctx["InboundHistory"] as Array<{ body: string }> | undefined;
461-expect(history?.some((entry) => entry.body.includes("Lunch?"))).toBe(true);
467+expect(history?.map((entry) => entry.body)).toEqual(
468+expect.arrayContaining([expect.stringContaining("Lunch?")]),
469+);
462470});
463471});
464472@@ -511,8 +519,12 @@ describe("matrix group chat history — scenario 2: race condition safety", () =
511519expect(finalizeInboundContext).toHaveBeenCalledTimes(2);
512520const ctxForC = finalizeInboundContext.mock.calls[1]?.[0] as Record<string, unknown>;
513521const history = ctxForC["InboundHistory"] as Array<{ body: string }>;
514-expect(history.some((h) => h.body.includes("msg B"))).toBe(true);
515-expect(history.every((h) => !h.body.includes("msg A"))).toBe(true);
522+expect(history.map((h) => h.body)).toEqual(
523+expect.arrayContaining([expect.stringContaining("msg B")]),
524+);
525+expect(history.map((h) => h.body)).not.toEqual(
526+expect.arrayContaining([expect.stringContaining("msg A")]),
527+);
516528});
517529518530it("watermark does not advance when final reply delivery fails (retry sees same history)", async () => {
@@ -546,7 +558,9 @@ describe("matrix group chat history — scenario 2: race condition safety", () =
546558{
547559const ctx = finalizeInboundContext.mock.calls[1]?.[0] as Record<string, unknown>;
548560const history = ctx["InboundHistory"] as Array<{ body: string }> | undefined;
549-expect(history?.some((h) => h.body.includes("pending msg"))).toBe(true);
561+expect(history?.map((h) => h.body)).toEqual(
562+expect.arrayContaining([expect.stringContaining("pending msg")]),
563+);
550564}
551565});
552566@@ -624,7 +638,9 @@ describe("matrix group chat history — scenario 2: race condition safety", () =
624638625639const ctx = finalizeInboundContext.mock.calls[0]?.[0] as Record<string, unknown>;
626640const history = ctx["InboundHistory"] as Array<{ body: string }> | undefined;
627-expect(history?.some((entry) => entry.body.includes("plain before trigger"))).toBe(true);
641+expect(history?.map((entry) => entry.body)).toEqual(
642+expect.arrayContaining([expect.stringContaining("plain before trigger")]),
643+);
628644});
629645630646it("preserves arrival order when a plain message starts before a later trigger", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。