From a186036814a9041116292cf086d85eeff8cd6982 Mon Sep 17 00:00:00 2001 From: Brian Mendonca Date: Sat, 21 Feb 2026 15:30:12 -0700 Subject: [PATCH] test: fix latest tsgo inference regressions in test suites --- ...tion.rejects-routing-allowfrom.e2e.test.ts | 1 + src/infra/exec-approvals.test.ts | 1 + ...tbeat-runner.returns-default-unset.test.ts | 2 ++ src/infra/outbound/outbound.test.ts | 9 +++++++- src/telegram/send.test.ts | 21 ++++++++----------- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/config/config.legacy-config-detection.rejects-routing-allowfrom.e2e.test.ts b/src/config/config.legacy-config-detection.rejects-routing-allowfrom.e2e.test.ts index 5ebaf353df7..278d3fc9922 100644 --- a/src/config/config.legacy-config-detection.rejects-routing-allowfrom.e2e.test.ts +++ b/src/config/config.legacy-config-detection.rejects-routing-allowfrom.e2e.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from "vitest"; +import type { OpenClawConfig } from "./config.js"; import { migrateLegacyConfig, validateConfigObject } from "./config.js"; import type { OpenClawConfig } from "./config.js"; diff --git a/src/infra/exec-approvals.test.ts b/src/infra/exec-approvals.test.ts index e449b4ac517..7ab0b235092 100644 --- a/src/infra/exec-approvals.test.ts +++ b/src/infra/exec-approvals.test.ts @@ -23,6 +23,7 @@ import { resolveExecApprovalsPath, resolveExecApprovalsSocketPath, resolveSafeBins, + type ExecApprovalsAgent, type ExecAllowlistEntry, type ExecApprovalsAgent, type ExecApprovalsFile, diff --git a/src/infra/heartbeat-runner.returns-default-unset.test.ts b/src/infra/heartbeat-runner.returns-default-unset.test.ts index 9dd7a025b8d..cc4a29d1b5e 100644 --- a/src/infra/heartbeat-runner.returns-default-unset.test.ts +++ b/src/infra/heartbeat-runner.returns-default-unset.test.ts @@ -4,6 +4,7 @@ import path from "node:path"; import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { HEARTBEAT_PROMPT } from "../auto-reply/heartbeat.js"; import * as replyModule from "../auto-reply/reply.js"; +import type { ReplyPayload } from "../auto-reply/types.js"; import { whatsappOutbound } from "../channels/plugins/outbound/whatsapp.js"; import type { OpenClawConfig } from "../config/config.js"; import { @@ -20,6 +21,7 @@ import { type HeartbeatDeps, resolveHeartbeatIntervalMs, resolveHeartbeatPrompt, + type HeartbeatDeps, runHeartbeatOnce, } from "./heartbeat-runner.js"; import { diff --git a/src/infra/outbound/outbound.test.ts b/src/infra/outbound/outbound.test.ts index 52ec66340e6..e273bc51441 100644 --- a/src/infra/outbound/outbound.test.ts +++ b/src/infra/outbound/outbound.test.ts @@ -480,7 +480,14 @@ describe("buildOutboundResultEnvelope", () => { }, ]; for (const testCase of cases) { - expect(buildOutboundResultEnvelope(testCase.input), testCase.name).toEqual(testCase.expected); + const input: Parameters[0] = + "payloads" in testCase.input + ? { + ...testCase.input, + payloads: testCase.input.payloads?.map((payload) => ({ ...payload })), + } + : testCase.input; + expect(buildOutboundResultEnvelope(input), testCase.name).toEqual(testCase.expected); } }); }); diff --git a/src/telegram/send.test.ts b/src/telegram/send.test.ts index e1172d09ce2..4ac26bb7493 100644 --- a/src/telegram/send.test.ts +++ b/src/telegram/send.test.ts @@ -147,7 +147,8 @@ describe("buildInlineKeyboard", () => { }, ]; for (const testCase of cases) { - expect(buildInlineKeyboard(testCase.input), testCase.name).toEqual(testCase.expected); + const input = testCase.input.map((row) => row.map((button) => ({ ...button }))); + expect(buildInlineKeyboard(input), testCase.name).toEqual(testCase.expected); } }); }); @@ -788,13 +789,9 @@ describe("sendMessageTelegram", () => { token: "tok", api, mediaUrl: testCase.mediaUrl, - ...(testCase.asVoice ? { asVoice: true } : {}), - ...(testCase.messageThreadId !== undefined - ? { messageThreadId: testCase.messageThreadId } - : {}), - ...(testCase.replyToMessageId !== undefined - ? { replyToMessageId: testCase.replyToMessageId } - : {}), + ...("asVoice" in testCase && testCase.asVoice ? { asVoice: true } : {}), + ...("messageThreadId" in testCase ? { messageThreadId: testCase.messageThreadId } : {}), + ...("replyToMessageId" in testCase ? { replyToMessageId: testCase.replyToMessageId } : {}), }); const called = testCase.expectedMethod === "sendVoice" ? sendVoice : sendAudio; @@ -1291,7 +1288,7 @@ describe("editMessageTelegram", () => { await editMessageTelegram("123", 1, input.text, { token: "tok", cfg: {}, - buttons: input.buttons, + buttons: input.buttons ? input.buttons.map((row) => [...row]) : input.buttons, }); expect(botCtorSpy, testCase.name).toHaveBeenCalledTimes(1); @@ -1303,16 +1300,16 @@ describe("editMessageTelegram", () => { unknown >; expect(firstParams, testCase.name).toEqual(expect.objectContaining({ parse_mode: "HTML" })); - if (testCase.firstExpectNoReplyMarkup) { + if ("firstExpectNoReplyMarkup" in testCase && testCase.firstExpectNoReplyMarkup) { expect(firstParams, testCase.name).not.toHaveProperty("reply_markup"); } - if (testCase.firstExpectReplyMarkup) { + if ("firstExpectReplyMarkup" in testCase) { expect(firstParams, testCase.name).toEqual( expect.objectContaining({ reply_markup: testCase.firstExpectReplyMarkup }), ); } - if (testCase.secondExpectReplyMarkup) { + if ("secondExpectReplyMarkup" in testCase) { const secondParams = (botApi.editMessageText.mock.calls[1] ?? [])[3] as Record< string, unknown