mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 19:35:28 -06:00
fix(release): repair beta validation fixtures
This commit is contained in:
@@ -340,6 +340,36 @@ export const sendAnimationSpy: AnyAsyncMock = grammySpies.sendAnimationSpy;
|
||||
export const sendPhotoSpy: AnyAsyncMock = grammySpies.sendPhotoSpy;
|
||||
export const getFileSpy: AnyAsyncMock = grammySpies.getFileSpy;
|
||||
|
||||
type RichMessageParams = {
|
||||
chat_id?: string | number;
|
||||
message_id?: number;
|
||||
rich_message?: {
|
||||
markdown?: string;
|
||||
html?: string;
|
||||
};
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
||||
function getRichMessageText(params: RichMessageParams): string {
|
||||
return params.rich_message?.markdown ?? params.rich_message?.html ?? "";
|
||||
}
|
||||
|
||||
function toLegacyMessageParams(params: RichMessageParams): Record<string, unknown> {
|
||||
const { chat_id: _chatId, message_id: _messageId, rich_message: _richMessage, ...rest } = params;
|
||||
const replyParameters = rest.reply_parameters;
|
||||
if (
|
||||
replyParameters &&
|
||||
typeof replyParameters === "object" &&
|
||||
!("quote" in replyParameters) &&
|
||||
typeof (replyParameters as { message_id?: unknown }).message_id === "number"
|
||||
) {
|
||||
rest.reply_to_message_id = (replyParameters as { message_id: number }).message_id;
|
||||
rest.allow_sending_without_reply = true;
|
||||
delete rest.reply_parameters;
|
||||
}
|
||||
return rest;
|
||||
}
|
||||
|
||||
const runnerHoisted = vi.hoisted(() => ({
|
||||
sequentializeMiddleware: vi.fn(async (_ctx: unknown, next?: () => Promise<void>) => {
|
||||
if (typeof next === "function") {
|
||||
@@ -369,6 +399,21 @@ export const telegramBotRuntimeForTest: TelegramBotRuntimeForTest = {
|
||||
sendAnimation: grammySpies.sendAnimationSpy,
|
||||
sendPhoto: grammySpies.sendPhotoSpy,
|
||||
getFile: grammySpies.getFileSpy,
|
||||
raw: {
|
||||
sendRichMessage: async (params: RichMessageParams) =>
|
||||
grammySpies.sendMessageSpy(
|
||||
params.chat_id,
|
||||
getRichMessageText(params),
|
||||
toLegacyMessageParams(params),
|
||||
),
|
||||
editMessageText: async (params: RichMessageParams) =>
|
||||
grammySpies.editMessageTextSpy(
|
||||
params.chat_id,
|
||||
params.message_id,
|
||||
getRichMessageText(params),
|
||||
toLegacyMessageParams(params),
|
||||
),
|
||||
},
|
||||
};
|
||||
use = grammySpies.middlewareUseSpy;
|
||||
on = grammySpies.onSpy;
|
||||
|
||||
@@ -70,6 +70,7 @@ const {
|
||||
TelegramSpooledReplayProcessingError,
|
||||
withTelegramSpooledReplayUpdate,
|
||||
} = await import("./bot-processing-outcome.js");
|
||||
const { TELEGRAM_RICH_TEXT_LIMIT } = await import("./rich-message.js");
|
||||
const { resolveTelegramConversationRoute } = await import("./conversation-route.js");
|
||||
const { clearAccountThrottlersForTest } = await import("./account-throttler.js");
|
||||
const {
|
||||
@@ -4192,7 +4193,7 @@ describe("createTelegramBot", () => {
|
||||
}
|
||||
});
|
||||
it("sends replies without native reply threading", async () => {
|
||||
replySpy.mockResolvedValue({ text: "a".repeat(4500) });
|
||||
replySpy.mockResolvedValue({ text: "a".repeat(TELEGRAM_RICH_TEXT_LIMIT + 1024) });
|
||||
|
||||
createTelegramBot({ token: "tok" });
|
||||
const handler = getOnHandler("message") as (ctx: Record<string, unknown>) => Promise<void>;
|
||||
@@ -4284,7 +4285,7 @@ describe("createTelegramBot", () => {
|
||||
sendMessageSpy.mockClear();
|
||||
replySpy.mockClear();
|
||||
replySpy.mockResolvedValue({
|
||||
text: "a".repeat(4500),
|
||||
text: "a".repeat(TELEGRAM_RICH_TEXT_LIMIT + 1024),
|
||||
replyToId: String(messageId),
|
||||
});
|
||||
loadConfig.mockReturnValue({
|
||||
|
||||
@@ -2,12 +2,34 @@
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const { botApi, botCtorSpy } = vi.hoisted(() => ({
|
||||
botApi: {
|
||||
config: { use: vi.fn() },
|
||||
sendMessage: vi.fn(),
|
||||
setMessageReaction: vi.fn(),
|
||||
deleteMessage: vi.fn(),
|
||||
},
|
||||
botApi: (() => {
|
||||
const sendMessage = vi.fn();
|
||||
type RichMessageParams = {
|
||||
chat_id?: string | number;
|
||||
rich_message?: {
|
||||
markdown?: string;
|
||||
html?: string;
|
||||
};
|
||||
[key: string]: unknown;
|
||||
};
|
||||
return {
|
||||
config: { use: vi.fn() },
|
||||
sendMessage,
|
||||
setMessageReaction: vi.fn(),
|
||||
deleteMessage: vi.fn(),
|
||||
raw: {
|
||||
sendRichMessage: vi.fn(async (params: RichMessageParams) =>
|
||||
sendMessage(
|
||||
params.chat_id,
|
||||
params.rich_message?.markdown ?? params.rich_message?.html ?? "",
|
||||
Object.fromEntries(
|
||||
Object.entries(params).filter(([key]) => key !== "chat_id" && key !== "rich_message"),
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
};
|
||||
})(),
|
||||
botCtorSpy: vi.fn(),
|
||||
}));
|
||||
|
||||
|
||||
@@ -59,10 +59,9 @@ async function writeLiveGatewayConfig(params: {
|
||||
list: [{ id: "dev", default: true }],
|
||||
defaults: {
|
||||
workspace: params.workspace,
|
||||
agentRuntime: { id: "codex" },
|
||||
skipBootstrap: true,
|
||||
model: { primary: params.modelKey },
|
||||
models: { [params.modelKey]: {} },
|
||||
models: { [params.modelKey]: { agentRuntime: { id: "codex" } } },
|
||||
sandbox: { mode: "off" },
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user