test: fix latest tsgo inference regressions in test suites

This commit is contained in:
Brian Mendonca
2026-02-21 15:30:12 -07:00
committed by Peter Steinberger
parent d12817994f
commit a186036814
5 changed files with 21 additions and 13 deletions

View File

@@ -1,4 +1,5 @@
import { describe, expect, it } from "vitest"; import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "./config.js";
import { migrateLegacyConfig, validateConfigObject } from "./config.js"; import { migrateLegacyConfig, validateConfigObject } from "./config.js";
import type { OpenClawConfig } from "./config.js"; import type { OpenClawConfig } from "./config.js";

View File

@@ -23,6 +23,7 @@ import {
resolveExecApprovalsPath, resolveExecApprovalsPath,
resolveExecApprovalsSocketPath, resolveExecApprovalsSocketPath,
resolveSafeBins, resolveSafeBins,
type ExecApprovalsAgent,
type ExecAllowlistEntry, type ExecAllowlistEntry,
type ExecApprovalsAgent, type ExecApprovalsAgent,
type ExecApprovalsFile, type ExecApprovalsFile,

View File

@@ -4,6 +4,7 @@ import path from "node:path";
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { HEARTBEAT_PROMPT } from "../auto-reply/heartbeat.js"; import { HEARTBEAT_PROMPT } from "../auto-reply/heartbeat.js";
import * as replyModule from "../auto-reply/reply.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 { whatsappOutbound } from "../channels/plugins/outbound/whatsapp.js";
import type { OpenClawConfig } from "../config/config.js"; import type { OpenClawConfig } from "../config/config.js";
import { import {
@@ -20,6 +21,7 @@ import {
type HeartbeatDeps, type HeartbeatDeps,
resolveHeartbeatIntervalMs, resolveHeartbeatIntervalMs,
resolveHeartbeatPrompt, resolveHeartbeatPrompt,
type HeartbeatDeps,
runHeartbeatOnce, runHeartbeatOnce,
} from "./heartbeat-runner.js"; } from "./heartbeat-runner.js";
import { import {

View File

@@ -480,7 +480,14 @@ describe("buildOutboundResultEnvelope", () => {
}, },
]; ];
for (const testCase of cases) { for (const testCase of cases) {
expect(buildOutboundResultEnvelope(testCase.input), testCase.name).toEqual(testCase.expected); const input: Parameters<typeof buildOutboundResultEnvelope>[0] =
"payloads" in testCase.input
? {
...testCase.input,
payloads: testCase.input.payloads?.map((payload) => ({ ...payload })),
}
: testCase.input;
expect(buildOutboundResultEnvelope(input), testCase.name).toEqual(testCase.expected);
} }
}); });
}); });

View File

@@ -147,7 +147,8 @@ describe("buildInlineKeyboard", () => {
}, },
]; ];
for (const testCase of cases) { 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", token: "tok",
api, api,
mediaUrl: testCase.mediaUrl, mediaUrl: testCase.mediaUrl,
...(testCase.asVoice ? { asVoice: true } : {}), ...("asVoice" in testCase && testCase.asVoice ? { asVoice: true } : {}),
...(testCase.messageThreadId !== undefined ...("messageThreadId" in testCase ? { messageThreadId: testCase.messageThreadId } : {}),
? { messageThreadId: testCase.messageThreadId } ...("replyToMessageId" in testCase ? { replyToMessageId: testCase.replyToMessageId } : {}),
: {}),
...(testCase.replyToMessageId !== undefined
? { replyToMessageId: testCase.replyToMessageId }
: {}),
}); });
const called = testCase.expectedMethod === "sendVoice" ? sendVoice : sendAudio; const called = testCase.expectedMethod === "sendVoice" ? sendVoice : sendAudio;
@@ -1291,7 +1288,7 @@ describe("editMessageTelegram", () => {
await editMessageTelegram("123", 1, input.text, { await editMessageTelegram("123", 1, input.text, {
token: "tok", token: "tok",
cfg: {}, cfg: {},
buttons: input.buttons, buttons: input.buttons ? input.buttons.map((row) => [...row]) : input.buttons,
}); });
expect(botCtorSpy, testCase.name).toHaveBeenCalledTimes(1); expect(botCtorSpy, testCase.name).toHaveBeenCalledTimes(1);
@@ -1303,16 +1300,16 @@ describe("editMessageTelegram", () => {
unknown unknown
>; >;
expect(firstParams, testCase.name).toEqual(expect.objectContaining({ parse_mode: "HTML" })); 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"); expect(firstParams, testCase.name).not.toHaveProperty("reply_markup");
} }
if (testCase.firstExpectReplyMarkup) { if ("firstExpectReplyMarkup" in testCase) {
expect(firstParams, testCase.name).toEqual( expect(firstParams, testCase.name).toEqual(
expect.objectContaining({ reply_markup: testCase.firstExpectReplyMarkup }), expect.objectContaining({ reply_markup: testCase.firstExpectReplyMarkup }),
); );
} }
if (testCase.secondExpectReplyMarkup) { if ("secondExpectReplyMarkup" in testCase) {
const secondParams = (botApi.editMessageText.mock.calls[1] ?? [])[3] as Record< const secondParams = (botApi.editMessageText.mock.calls[1] ?? [])[3] as Record<
string, string,
unknown unknown