mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
test(auto-reply): dedupe heartbeat typing flow setup
This commit is contained in:
@@ -49,43 +49,34 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe("getReplyFromConfig typing (heartbeat)", () => {
|
||||
async function runReplyFlow(isHeartbeat: boolean): Promise<ReturnType<typeof vi.fn>> {
|
||||
const onReplyStart = vi.fn();
|
||||
await withTempHome(async (home) => {
|
||||
runEmbeddedPiAgentMock.mockResolvedValueOnce({
|
||||
payloads: [{ text: "ok" }],
|
||||
meta: {},
|
||||
});
|
||||
|
||||
await getReplyFromConfig(
|
||||
{ Body: "hi", From: "+1000", To: "+2000", Provider: "whatsapp" },
|
||||
{ onReplyStart, isHeartbeat },
|
||||
makeReplyConfig(home) as unknown as OpenClawConfig,
|
||||
);
|
||||
});
|
||||
return onReplyStart;
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||
});
|
||||
|
||||
it("starts typing for normal runs", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
runEmbeddedPiAgentMock.mockResolvedValueOnce({
|
||||
payloads: [{ text: "ok" }],
|
||||
meta: {},
|
||||
});
|
||||
const onReplyStart = vi.fn();
|
||||
|
||||
await getReplyFromConfig(
|
||||
{ Body: "hi", From: "+1000", To: "+2000", Provider: "whatsapp" },
|
||||
{ onReplyStart, isHeartbeat: false },
|
||||
makeReplyConfig(home) as unknown as OpenClawConfig,
|
||||
);
|
||||
|
||||
expect(onReplyStart).toHaveBeenCalled();
|
||||
});
|
||||
const onReplyStart = await runReplyFlow(false);
|
||||
expect(onReplyStart).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not start typing for heartbeat runs", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
runEmbeddedPiAgentMock.mockResolvedValueOnce({
|
||||
payloads: [{ text: "ok" }],
|
||||
meta: {},
|
||||
});
|
||||
const onReplyStart = vi.fn();
|
||||
|
||||
await getReplyFromConfig(
|
||||
{ Body: "hi", From: "+1000", To: "+2000", Provider: "whatsapp" },
|
||||
{ onReplyStart, isHeartbeat: true },
|
||||
makeReplyConfig(home) as unknown as OpenClawConfig,
|
||||
);
|
||||
|
||||
expect(onReplyStart).not.toHaveBeenCalled();
|
||||
});
|
||||
const onReplyStart = await runReplyFlow(true);
|
||||
expect(onReplyStart).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user