



























@@ -228,22 +228,17 @@ describe("sessionsCleanupCommand", () => {
228228expect(payload.appliedCount).toBe(1);
229229expect(payload.pruned).toBe(0);
230230expect(payload.capped).toBe(2);
231-expect(payload.diskBudget).toEqual(
232-expect.objectContaining({
233-removedFiles: 0,
234-removedEntries: 0,
235-}),
236-);
237-expect(mocks.runSessionsCleanup).toHaveBeenCalledWith(
238-expect.objectContaining({
239-cfg: { session: { store: "/cfg/sessions.json" } },
240-opts: expect.objectContaining({
241-enforce: true,
242-activeKey: "agent:main:main",
243-}),
244-targets: [{ agentId: "main", storePath: "/resolved/sessions.json" }],
245-}),
246-);
231+const diskBudget = payload.diskBudget as Record<string, unknown>;
232+expect(diskBudget.removedFiles).toBe(0);
233+expect(diskBudget.removedEntries).toBe(0);
234+expect(mocks.runSessionsCleanup).toHaveBeenCalledOnce();
235+const cleanupCall = mocks.runSessionsCleanup.mock.calls[0]?.[0];
236+expect(cleanupCall?.cfg).toEqual({ session: { store: "/cfg/sessions.json" } });
237+expect(cleanupCall?.opts.enforce).toBe(true);
238+expect(cleanupCall?.opts.activeKey).toBe("agent:main:main");
239+expect(cleanupCall?.targets).toEqual([
240+{ agentId: "main", storePath: "/resolved/sessions.json" },
241+]);
247242});
248243249244it("delegates non-store enforcing cleanup through the Gateway writer when reachable", async () => {
@@ -273,15 +268,13 @@ describe("sessionsCleanupCommand", () => {
273268runtime,
274269);
275270276-expect(mocks.callGateway).toHaveBeenCalledWith(
277-expect.objectContaining({
278-method: "sessions.cleanup",
279-params: expect.objectContaining({ enforce: true }),
280-requiredMethods: ["sessions.cleanup"],
281-}),
282-);
271+expect(mocks.callGateway).toHaveBeenCalledOnce();
272+const gatewayCall = mocks.callGateway.mock.calls[0]?.[0];
273+expect(gatewayCall?.method).toBe("sessions.cleanup");
274+expect(gatewayCall?.params.enforce).toBe(true);
275+expect(gatewayCall?.requiredMethods).toEqual(["sessions.cleanup"]);
283276expect(mocks.updateSessionStore).not.toHaveBeenCalled();
284-expect(JSON.parse(logs[0] ?? "{}")).toEqual(expect.objectContaining({ appliedCount: 1 }));
277+expect(JSON.parse(logs[0] ?? "{}").appliedCount).toBe(1);
285278});
286279287280it("returns dry-run JSON without mutating the store", async () => {
@@ -338,12 +331,9 @@ describe("sessionsCleanupCommand", () => {
338331expect(payload.applied).toBeUndefined();
339332expect(mocks.runSessionsCleanup).toHaveBeenCalled();
340333expect(mocks.updateSessionStore).not.toHaveBeenCalled();
341-expect(payload.diskBudget).toEqual(
342-expect.objectContaining({
343-removedFiles: 1,
344-removedEntries: 1,
345-}),
346-);
334+const diskBudget = payload.diskBudget as Record<string, unknown>;
335+expect(diskBudget.removedFiles).toBe(1);
336+expect(diskBudget.removedEntries).toBe(1);
347337});
348338349339it("counts missing transcript entries when --fix-missing is enabled in dry-run", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。