fix(ci): reduce slow channel test skew

This commit is contained in:
Vincent Koc
2026-03-31 19:48:17 +09:00
parent da7f016db6
commit cf3ae2612b
14 changed files with 230 additions and 31 deletions

View File

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

View File

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

View File

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

View File

@@ -206,6 +206,7 @@ function registerAndResolveCommandHandlerBase(params: {
modelNames: new Map<string, string>(),
})),
listSkillCommandsForAgents: vi.fn(() => []),
syncTelegramMenuCommands: vi.fn(),
wasSentByBot: vi.fn(() => false),
};
registerTelegramNativeCommands({

View File

@@ -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 = {

View File

@@ -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({