mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 01:10:21 +00:00
fix(ci): reduce slow channel test skew
This commit is contained in:
@@ -9,6 +9,7 @@ import { readChannelAllowFromStore } from "openclaw/plugin-sdk/conversation-runt
|
||||
import { upsertChannelPairingRequest } from "openclaw/plugin-sdk/conversation-runtime";
|
||||
import { dispatchReplyWithBufferedBlockDispatcher } from "openclaw/plugin-sdk/reply-runtime";
|
||||
import { loadWebMedia } from "openclaw/plugin-sdk/web-media";
|
||||
import { syncTelegramMenuCommands } from "./bot-native-command-menu.js";
|
||||
import { deliverReplies, emitInternalMessageSentHook } from "./bot/delivery.js";
|
||||
import { createTelegramDraftStream } from "./draft-stream.js";
|
||||
import { resolveTelegramExecApproval } from "./exec-approval-resolver.js";
|
||||
@@ -26,6 +27,7 @@ export type TelegramBotDeps = {
|
||||
loadWebMedia?: typeof loadWebMedia;
|
||||
buildModelsProviderData: typeof buildModelsProviderData;
|
||||
listSkillCommandsForAgents: typeof listSkillCommandsForAgents;
|
||||
syncTelegramMenuCommands?: typeof syncTelegramMenuCommands;
|
||||
wasSentByBot: typeof wasSentByBot;
|
||||
resolveExecApproval?: typeof resolveTelegramExecApproval;
|
||||
createTelegramDraftStream?: typeof createTelegramDraftStream;
|
||||
@@ -65,6 +67,9 @@ export const defaultTelegramBotDeps: TelegramBotDeps = {
|
||||
get listSkillCommandsForAgents() {
|
||||
return listSkillCommandsForAgents;
|
||||
},
|
||||
get syncTelegramMenuCommands() {
|
||||
return syncTelegramMenuCommands;
|
||||
},
|
||||
get wasSentByBot() {
|
||||
return wasSentByBot;
|
||||
},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { vi } from "vitest";
|
||||
import type { BuildTelegramMessageContextParams, TelegramMediaRef } from "./bot-message-context.js";
|
||||
|
||||
export const baseTelegramMessageContextConfig = {
|
||||
@@ -22,8 +23,7 @@ export async function buildTelegramMessageContextForTest(
|
||||
): Promise<
|
||||
Awaited<ReturnType<typeof import("./bot-message-context.js").buildTelegramMessageContext>>
|
||||
> {
|
||||
const { vi } = await import("vitest");
|
||||
const { buildTelegramMessageContext } = await import("./bot-message-context.js");
|
||||
const buildTelegramMessageContext = await loadBuildTelegramMessageContext();
|
||||
return await buildTelegramMessageContext({
|
||||
primaryCtx: {
|
||||
message: {
|
||||
@@ -64,3 +64,15 @@ export async function buildTelegramMessageContextForTest(
|
||||
sendChatActionHandler: { sendChatAction: vi.fn() } as never,
|
||||
});
|
||||
}
|
||||
|
||||
let buildTelegramMessageContextLoader:
|
||||
| typeof import("./bot-message-context.js").buildTelegramMessageContext
|
||||
| undefined;
|
||||
|
||||
async function loadBuildTelegramMessageContext() {
|
||||
if (!buildTelegramMessageContextLoader) {
|
||||
({ buildTelegramMessageContext: buildTelegramMessageContextLoader } =
|
||||
await import("./bot-message-context.js"));
|
||||
}
|
||||
return buildTelegramMessageContextLoader;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
|
||||
import type { TelegramAccountConfig } from "openclaw/plugin-sdk/config-runtime";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
let createNativeCommandsHarness: typeof import("./bot-native-commands.test-helpers.js").createNativeCommandsHarness;
|
||||
let deliverReplies: typeof import("./bot-native-commands.test-helpers.js").deliverReplies;
|
||||
@@ -27,7 +27,7 @@ let executePluginCommandMock: {
|
||||
};
|
||||
|
||||
describe("registerTelegramNativeCommands (plugin auth)", () => {
|
||||
beforeEach(async () => {
|
||||
beforeAll(async () => {
|
||||
vi.resetModules();
|
||||
({
|
||||
createNativeCommandsHarness,
|
||||
@@ -40,6 +40,9 @@ describe("registerTelegramNativeCommands (plugin auth)", () => {
|
||||
getPluginCommandSpecs as unknown as typeof getPluginCommandSpecsMock;
|
||||
matchPluginCommandMock = matchPluginCommand as unknown as typeof matchPluginCommandMock;
|
||||
executePluginCommandMock = executePluginCommand as unknown as typeof executePluginCommandMock;
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@@ -206,6 +206,7 @@ function registerAndResolveCommandHandlerBase(params: {
|
||||
modelNames: new Map<string, string>(),
|
||||
})),
|
||||
listSkillCommandsForAgents: vi.fn(() => []),
|
||||
syncTelegramMenuCommands: vi.fn(),
|
||||
wasSentByBot: vi.fn(() => false),
|
||||
};
|
||||
registerTelegramNativeCommands({
|
||||
|
||||
@@ -129,6 +129,7 @@ export function createNativeCommandsHarness(params?: {
|
||||
modelNames: new Map<string, string>(),
|
||||
})),
|
||||
listSkillCommandsForAgents: vi.fn(() => []),
|
||||
syncTelegramMenuCommands: vi.fn(),
|
||||
wasSentByBot: vi.fn(() => false),
|
||||
};
|
||||
const bot = {
|
||||
|
||||
@@ -56,7 +56,7 @@ import type { TelegramMessageContextOptions } from "./bot-message-context.types.
|
||||
import {
|
||||
buildCappedTelegramMenuCommands,
|
||||
buildPluginTelegramMenuCommands,
|
||||
syncTelegramMenuCommands,
|
||||
syncTelegramMenuCommands as syncTelegramMenuCommandsRuntime,
|
||||
} from "./bot-native-command-menu.js";
|
||||
import { TelegramUpdateKeyContext } from "./bot-updates.js";
|
||||
import { TelegramBotOptions } from "./bot.js";
|
||||
@@ -501,6 +501,8 @@ export const registerTelegramNativeCommands = ({
|
||||
`Use channels.telegram.commands.native: false to disable, or reduce plugin/skill/custom commands.`,
|
||||
);
|
||||
}
|
||||
const syncTelegramMenuCommands =
|
||||
telegramDeps.syncTelegramMenuCommands ?? syncTelegramMenuCommandsRuntime;
|
||||
// Telegram only limits the setMyCommands payload (menu entries).
|
||||
// Keep hidden commands callable by registering handlers for the full catalog.
|
||||
syncTelegramMenuCommands({
|
||||
|
||||
Reference in New Issue
Block a user