Skip to content

Commit 884b6af

Browse files
committed
test: tighten cron reply seam assertions
1 parent 4d6091c commit 884b6af

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

src/agents/pi-embedded-runner/run.before-agent-reply-cron.test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,18 @@ describe("runEmbeddedPiAgent cron before_agent_reply seam", () => {
3636
prompt: "__openclaw_memory_core_short_term_promotion_dream__",
3737
});
3838

39-
expect(mockedGlobalHookRunner.runBeforeAgentReply).toHaveBeenCalledWith(
40-
{ cleanedBody: "__openclaw_memory_core_short_term_promotion_dream__" },
41-
expect.objectContaining({
42-
jobId: "cron-job-123",
43-
agentId: "main",
44-
sessionId: "test-session",
45-
sessionKey: "test-key",
46-
workspaceDir: "/tmp/workspace",
47-
trigger: "cron",
48-
}),
49-
);
39+
expect(mockedGlobalHookRunner.runBeforeAgentReply).toHaveBeenCalledTimes(1);
40+
const [hookPayload, hookContext] =
41+
mockedGlobalHookRunner.runBeforeAgentReply.mock.calls[0] ?? [];
42+
expect(hookPayload).toEqual({
43+
cleanedBody: "__openclaw_memory_core_short_term_promotion_dream__",
44+
});
45+
expect(hookContext?.jobId).toBe("cron-job-123");
46+
expect(hookContext?.agentId).toBe("main");
47+
expect(hookContext?.sessionId).toBe("test-session");
48+
expect(hookContext?.sessionKey).toBe("test-key");
49+
expect(hookContext?.workspaceDir).toBe("/tmp/workspace");
50+
expect(hookContext?.trigger).toBe("cron");
5051
expect(mockedRunEmbeddedAttempt).not.toHaveBeenCalled();
5152
expect(result.payloads?.[0]?.text).toBe("dreaming claimed");
5253
});
@@ -93,11 +94,10 @@ describe("runEmbeddedPiAgent cron before_agent_reply seam", () => {
9394
promptMode: "none",
9495
});
9596

96-
expect(mockedRunEmbeddedAttempt).toHaveBeenCalledWith(
97-
expect.objectContaining({
98-
modelRun: true,
99-
promptMode: "none",
100-
}),
101-
);
97+
const [attemptParams] = (mockedRunEmbeddedAttempt.mock.calls[0] ?? []) as [
98+
{ modelRun?: boolean; promptMode?: string }?,
99+
];
100+
expect(attemptParams?.modelRun).toBe(true);
101+
expect(attemptParams?.promptMode).toBe("none");
102102
});
103103
});

0 commit comments

Comments
 (0)