test: fix CI failures in heartbeat and typing tests

This commit is contained in:
Peter Steinberger
2026-02-25 02:28:42 +00:00
parent d42ef2ac62
commit 45b5c35b21
3 changed files with 24 additions and 24 deletions

View File

@@ -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 }),
);