mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 21:44:32 +00:00
test(telegram): dedupe native-command test setup
This commit is contained in:
@@ -6,6 +6,7 @@ import { TELEGRAM_COMMAND_NAME_PATTERN } from "../config/telegram-custom-command
|
||||
import type { TelegramAccountConfig } from "../config/types.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { registerTelegramNativeCommands } from "./bot-native-commands.js";
|
||||
import { createNativeCommandTestParams } from "./bot-native-commands.test-helpers.js";
|
||||
|
||||
const { listSkillCommandsForAgents } = vi.hoisted(() => ({
|
||||
listSkillCommandsForAgents: vi.fn(() => []),
|
||||
@@ -63,34 +64,20 @@ describe("registerTelegramNativeCommands", () => {
|
||||
deliveryMocks.deliverReplies.mockResolvedValue({ delivered: true });
|
||||
});
|
||||
|
||||
const buildParams = (cfg: OpenClawConfig, accountId = "default") => ({
|
||||
bot: {
|
||||
api: {
|
||||
setMyCommands: vi.fn().mockResolvedValue(undefined),
|
||||
sendMessage: vi.fn().mockResolvedValue(undefined),
|
||||
},
|
||||
command: vi.fn(),
|
||||
} as unknown as Parameters<typeof registerTelegramNativeCommands>[0]["bot"],
|
||||
cfg,
|
||||
runtime: {} as unknown as RuntimeEnv,
|
||||
accountId,
|
||||
telegramCfg: {} as TelegramAccountConfig,
|
||||
allowFrom: [],
|
||||
groupAllowFrom: [],
|
||||
replyToMode: "off" as const,
|
||||
textLimit: 4096,
|
||||
useAccessGroups: false,
|
||||
nativeEnabled: true,
|
||||
nativeSkillsEnabled: true,
|
||||
nativeDisabledExplicit: false,
|
||||
resolveGroupPolicy: () => ({ allowlistEnabled: false, allowed: true }),
|
||||
resolveTelegramGroupConfig: () => ({
|
||||
groupConfig: undefined,
|
||||
topicConfig: undefined,
|
||||
}),
|
||||
shouldSkipUpdate: () => false,
|
||||
opts: { token: "token" },
|
||||
});
|
||||
const buildParams = (cfg: OpenClawConfig, accountId = "default") =>
|
||||
createNativeCommandTestParams({
|
||||
bot: {
|
||||
api: {
|
||||
setMyCommands: vi.fn().mockResolvedValue(undefined),
|
||||
sendMessage: vi.fn().mockResolvedValue(undefined),
|
||||
},
|
||||
command: vi.fn(),
|
||||
} as unknown as Parameters<typeof registerTelegramNativeCommands>[0]["bot"],
|
||||
cfg,
|
||||
runtime: {} as RuntimeEnv,
|
||||
accountId,
|
||||
telegramCfg: {} as TelegramAccountConfig,
|
||||
});
|
||||
|
||||
it("scopes skill commands when account binding exists", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
|
||||
Reference in New Issue
Block a user