mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 06:01:23 +00:00
test(auto-reply): dedupe heartbeat typing flow setup
This commit is contained in:
@@ -49,43 +49,34 @@ afterEach(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("getReplyFromConfig typing (heartbeat)", () => {
|
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(() => {
|
beforeEach(() => {
|
||||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("starts typing for normal runs", async () => {
|
it("starts typing for normal runs", async () => {
|
||||||
await withTempHome(async (home) => {
|
const onReplyStart = await runReplyFlow(false);
|
||||||
runEmbeddedPiAgentMock.mockResolvedValueOnce({
|
expect(onReplyStart).toHaveBeenCalled();
|
||||||
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();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not start typing for heartbeat runs", async () => {
|
it("does not start typing for heartbeat runs", async () => {
|
||||||
await withTempHome(async (home) => {
|
const onReplyStart = await runReplyFlow(true);
|
||||||
runEmbeddedPiAgentMock.mockResolvedValueOnce({
|
expect(onReplyStart).not.toHaveBeenCalled();
|
||||||
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();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user