mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 18:41:24 +00:00
test: fix CI failures in heartbeat and typing tests
This commit is contained in:
@@ -15,6 +15,9 @@ vi.mock("jiti", () => ({ createJiti: () => () => ({}) }));
|
||||
installHeartbeatRunnerTestRuntime();
|
||||
|
||||
describe("runHeartbeatOnce ack handling", () => {
|
||||
const WHATSAPP_GROUP = "120363140186826074@g.us";
|
||||
const TELEGRAM_GROUP = "-1001234567890";
|
||||
|
||||
function createHeartbeatConfig(params: {
|
||||
tmpDir: string;
|
||||
storePath: string;
|
||||
@@ -105,7 +108,7 @@ describe("runHeartbeatOnce ack handling", () => {
|
||||
await seedMainSessionStore(params.storePath, cfg, {
|
||||
lastChannel: "telegram",
|
||||
lastProvider: "telegram",
|
||||
lastTo: "12345",
|
||||
lastTo: TELEGRAM_GROUP,
|
||||
});
|
||||
|
||||
params.replySpy.mockResolvedValue({ text: params.replyText });
|
||||
@@ -150,7 +153,7 @@ describe("runHeartbeatOnce ack handling", () => {
|
||||
await seedMainSessionStore(params.storePath, cfg, {
|
||||
lastChannel: "whatsapp",
|
||||
lastProvider: "whatsapp",
|
||||
lastTo: "+1555",
|
||||
lastTo: WHATSAPP_GROUP,
|
||||
});
|
||||
return cfg;
|
||||
}
|
||||
@@ -166,7 +169,7 @@ describe("runHeartbeatOnce ack handling", () => {
|
||||
await seedMainSessionStore(storePath, cfg, {
|
||||
lastChannel: "whatsapp",
|
||||
lastProvider: "whatsapp",
|
||||
lastTo: "+1555",
|
||||
lastTo: WHATSAPP_GROUP,
|
||||
});
|
||||
|
||||
replySpy.mockResolvedValue({ text: "HEARTBEAT_OK 🦞" });
|
||||
@@ -192,7 +195,7 @@ describe("runHeartbeatOnce ack handling", () => {
|
||||
await seedMainSessionStore(storePath, cfg, {
|
||||
lastChannel: "whatsapp",
|
||||
lastProvider: "whatsapp",
|
||||
lastTo: "+1555",
|
||||
lastTo: WHATSAPP_GROUP,
|
||||
});
|
||||
|
||||
replySpy.mockResolvedValue({ text: "HEARTBEAT_OK" });
|
||||
@@ -204,7 +207,7 @@ describe("runHeartbeatOnce ack handling", () => {
|
||||
});
|
||||
|
||||
expect(sendWhatsApp).toHaveBeenCalledTimes(1);
|
||||
expect(sendWhatsApp).toHaveBeenCalledWith("+1555", "HEARTBEAT_OK", expect.any(Object));
|
||||
expect(sendWhatsApp).toHaveBeenCalledWith(WHATSAPP_GROUP, "HEARTBEAT_OK", expect.any(Object));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -239,7 +242,7 @@ describe("runHeartbeatOnce ack handling", () => {
|
||||
|
||||
expect(sendTelegram).toHaveBeenCalledTimes(expectedCalls);
|
||||
if (expectedText) {
|
||||
expect(sendTelegram).toHaveBeenCalledWith("12345", expectedText, expect.any(Object));
|
||||
expect(sendTelegram).toHaveBeenCalledWith(TELEGRAM_GROUP, expectedText, expect.any(Object));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -255,7 +258,7 @@ describe("runHeartbeatOnce ack handling", () => {
|
||||
await seedMainSessionStore(storePath, cfg, {
|
||||
lastChannel: "whatsapp",
|
||||
lastProvider: "whatsapp",
|
||||
lastTo: "+1555",
|
||||
lastTo: WHATSAPP_GROUP,
|
||||
});
|
||||
|
||||
const sendWhatsApp = createMessageSendSpy();
|
||||
@@ -303,7 +306,7 @@ describe("runHeartbeatOnce ack handling", () => {
|
||||
updatedAt: originalUpdatedAt,
|
||||
lastChannel: "whatsapp",
|
||||
lastProvider: "whatsapp",
|
||||
lastTo: "+1555",
|
||||
lastTo: WHATSAPP_GROUP,
|
||||
});
|
||||
|
||||
replySpy.mockImplementationOnce(async () => {
|
||||
@@ -372,11 +375,11 @@ describe("runHeartbeatOnce ack handling", () => {
|
||||
await seedMainSessionStore(storePath, cfg, {
|
||||
lastChannel: "telegram",
|
||||
lastProvider: "telegram",
|
||||
lastTo: "123456",
|
||||
lastTo: TELEGRAM_GROUP,
|
||||
});
|
||||
|
||||
replySpy.mockResolvedValue({ text: "Hello from heartbeat" });
|
||||
const sendTelegram = createMessageSendSpy({ chatId: "123456" });
|
||||
const sendTelegram = createMessageSendSpy({ chatId: TELEGRAM_GROUP });
|
||||
|
||||
await runHeartbeatOnce({
|
||||
cfg,
|
||||
@@ -385,7 +388,7 @@ describe("runHeartbeatOnce ack handling", () => {
|
||||
|
||||
expect(sendTelegram).toHaveBeenCalledTimes(1);
|
||||
expect(sendTelegram).toHaveBeenCalledWith(
|
||||
"123456",
|
||||
TELEGRAM_GROUP,
|
||||
"Hello from heartbeat",
|
||||
expect.objectContaining({ accountId: params.expectedAccountId, verbose: false }),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user