






















@@ -67,6 +67,17 @@ vi.mock("../config/sessions.js", () => {
6767const announceSpy = vi.fn(async (_params: unknown) => true);
6868const runSubagentEndedHookMock = vi.fn(async (_event?: unknown, _ctx?: unknown) => {});
6969const emitSessionLifecycleEventMock = vi.fn();
70+71+function countMatching<T>(items: readonly T[], predicate: (item: T) => boolean) {
72+let count = 0;
73+for (const item of items) {
74+if (predicate(item)) {
75+count += 1;
76+}
77+}
78+return count;
79+}
80+7081const noopContextEngine = {
7182info: { id: "test-context-engine", name: "Test context engine" },
7283ingest: async () => ({ ingested: false }),
@@ -687,23 +698,23 @@ describe("subagent registry steer restarts", () => {
687698const childRunIds = announceSpy.mock.calls.map(
688699(call) => ((call[0] ?? {}) as { childRunId?: string }).childRunId,
689700);
690-expect(childRunIds.filter((id) => id === "run-parent")).toHaveLength(1);
701+expect(countMatching(childRunIds, (id) => id === "run-parent")).toBe(1);
691702});
692703693704emitLifecycleEnd("run-child");
694705await waitForRegistrySideEffect(() => {
695706const childRunIds = announceSpy.mock.calls.map(
696707(call) => ((call[0] ?? {}) as { childRunId?: string }).childRunId,
697708);
698-expect(childRunIds.filter((id) => id === "run-parent")).toHaveLength(2);
699-expect(childRunIds.filter((id) => id === "run-child")).toHaveLength(1);
709+expect(countMatching(childRunIds, (id) => id === "run-parent")).toBe(2);
710+expect(countMatching(childRunIds, (id) => id === "run-child")).toBe(1);
700711});
701712702713const childRunIds = announceSpy.mock.calls.map(
703714(call) => ((call[0] ?? {}) as { childRunId?: string }).childRunId,
704715);
705-expect(childRunIds.filter((id) => id === "run-parent")).toHaveLength(2);
706-expect(childRunIds.filter((id) => id === "run-child")).toHaveLength(1);
716+expect(countMatching(childRunIds, (id) => id === "run-parent")).toBe(2);
717+expect(countMatching(childRunIds, (id) => id === "run-child")).toBe(1);
707718});
708719709720it("retries completion-mode announce delivery with backoff and then gives up after retry limit", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。