fix: repair test typing for check gate

This commit is contained in:
Peter Steinberger
2026-04-07 20:56:30 +01:00
parent a4bb2698dd
commit 3e85f9c4ff
8 changed files with 20 additions and 20 deletions

View File

@@ -26,7 +26,7 @@ function createOpenGuildConfig(
channels: Record<string, { allow: boolean; includeThreadStarter?: boolean }>,
extra: Partial<Config> = {},
): Config {
return {
const cfg: Config = {
...createMentionRequiredGuildConfig(),
...extra,
channels: {
@@ -41,7 +41,8 @@ function createOpenGuildConfig(
},
},
},
} as Config;
};
return cfg;
}
describe("discord tool result dispatch", () => {

View File

@@ -70,12 +70,12 @@ describe("discord tool result dispatch", () => {
});
it("replies with pairing code and sender id when dmPolicy is pairing", async () => {
const cfg = {
const cfg: Config = {
...BASE_CFG,
channels: {
discord: { dm: { enabled: true, policy: "pairing", allowFrom: [] } },
},
} as Config;
};
const handler = await createDmHandler({ cfg });
const client = createDmClient();

View File

@@ -307,7 +307,7 @@ export function createMentionRequiredGuildConfig(overrides?: Partial<Config>): C
},
},
...overrides,
} as Config;
};
}
export function captureNextDispatchCtx<

View File

@@ -274,10 +274,9 @@ describe("Discord native slash commands with commands.allowFrom", () => {
},
});
const dispatchCall = vi.mocked(dispatcherModule.dispatchReplyWithDispatcher).mock
.calls[0]?.[0] as
const dispatchCall:
| Parameters<typeof dispatcherModule.dispatchReplyWithDispatcher>[0]
| undefined;
| undefined = vi.mocked(dispatcherModule.dispatchReplyWithDispatcher).mock.calls[0]?.[0];
await dispatchCall?.dispatcherOptions.deliver({ text: longReply }, { kind: "final" });
expect(interaction.followUp).toHaveBeenCalledWith(

View File

@@ -48,19 +48,18 @@ function createNativeCommand(
throw new Error(`missing native command: ${name}`);
}
const baseCfg: ReturnType<typeof loadConfig> = opts?.cfg ?? {};
const discordConfig = (opts?.discordConfig ?? baseCfg.channels?.discord ?? {}) as NonNullable<
OpenClawConfig["channels"]
>["discord"];
const discordConfig: NonNullable<OpenClawConfig["channels"]>["discord"] =
opts?.discordConfig ?? baseCfg.channels?.discord ?? {};
const cfg =
opts?.discordConfig === undefined
? baseCfg
: ({
: {
...baseCfg,
channels: {
...baseCfg.channels,
discord: discordConfig,
},
} as ReturnType<typeof loadConfig>);
};
return createDiscordNativeCommand({
command,
cfg,

View File

@@ -25,7 +25,7 @@ vi.mock("./short-term-promotion.js", () => ({
}));
function asOpenClawConfig(config: Partial<OpenClawConfig>): OpenClawConfig {
return config as OpenClawConfig;
return config;
}
function createSearchTool(config: OpenClawConfig) {

View File

@@ -3,7 +3,7 @@ import type { OpenClawConfig } from "../api.js";
import { createMemoryGetTool, createMemorySearchTool } from "./tools.js";
export function asOpenClawConfig(config: Partial<OpenClawConfig>): OpenClawConfig {
return config as OpenClawConfig;
return config;
}
export function createDefaultMemoryToolConfig(): OpenClawConfig {

View File

@@ -3,6 +3,8 @@ import os from "node:os";
import path from "node:path";
import { Command } from "commander";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { createTestPluginApi } from "../../test/helpers/plugins/plugin-api.ts";
import type { OpenClawPluginApi } from "./api.js";
let runtimeStub: {
config: { toNumber?: string };
@@ -57,7 +59,7 @@ function captureStdout() {
function setup(config: Record<string, unknown>): Registered {
const methods = new Map<string, unknown>();
const tools: unknown[] = [];
void plugin.register({
const api = createTestPluginApi({
id: "voice-call",
name: "Voice Call",
description: "test",
@@ -65,16 +67,15 @@ function setup(config: Record<string, unknown>): Registered {
source: "test",
config: {},
pluginConfig: config,
runtime: { tts: { textToSpeechTelephony: vi.fn() } } as unknown as Parameters<
typeof plugin.register
>[0]["runtime"],
runtime: { tts: { textToSpeechTelephony: vi.fn() } } as unknown as OpenClawPluginApi["runtime"],
logger: noopLogger,
registerGatewayMethod: (method: string, handler: unknown) => methods.set(method, handler),
registerTool: (tool: unknown) => tools.push(tool),
registerCli: () => {},
registerService: () => {},
resolvePath: (p: string) => p,
} as unknown as Parameters<typeof plugin.register>[0]);
});
void plugin.register(api);
return { methods, tools };
}