


























@@ -4,6 +4,7 @@ import path from "node:path";
44import { ChannelType, type AutocompleteInteraction } from "@buape/carbon";
55import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
66import { clearSessionStoreCacheForTest } from "openclaw/plugin-sdk/session-store-runtime";
7+import { createEmptyPluginRegistry, setActivePluginRegistry } from "openclaw/plugin-sdk/testing";
78import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
89import { createNoopThreadBindingManager } from "./thread-bindings.js";
910@@ -125,14 +126,44 @@ let findCommandByNativeName: typeof import("openclaw/plugin-sdk/command-auth").f
125126let resolveCommandArgChoices: typeof import("openclaw/plugin-sdk/command-auth").resolveCommandArgChoices;
126127let resolveDiscordNativeChoiceContext: typeof import("./native-command-ui.js").resolveDiscordNativeChoiceContext;
127128129+function installProviderThinkingRegistryForTest(): void {
130+const registry = createEmptyPluginRegistry();
131+registry.providers.push({
132+pluginId: "discord-test",
133+source: "test",
134+provider: {
135+id: "discord-test-thinking",
136+label: "Discord Test Thinking",
137+aliases: ["anthropic", "openai-codex"],
138+auth: [],
139+isBinaryThinking: (context) =>
140+providerThinkingMocks.resolveProviderBinaryThinking({
141+provider: context.provider,
142+ context,
143+}),
144+supportsXHighThinking: (context) =>
145+providerThinkingMocks.resolveProviderXHighThinking({
146+provider: context.provider,
147+ context,
148+}),
149+resolveThinkingProfile: (context) =>
150+providerThinkingMocks.resolveProviderThinkingProfile({
151+provider: context.provider,
152+ context,
153+}),
154+resolveDefaultThinkingLevel: (context) =>
155+providerThinkingMocks.resolveProviderDefaultThinkingLevel({
156+provider: context.provider,
157+ context,
158+}),
159+},
160+});
161+setActivePluginRegistry(registry);
162+}
163+128164async function loadDiscordThinkAutocompleteModulesForTest() {
129165vi.resetModules();
130-vi.doMock("../../../../src/plugins/provider-thinking.js", () => ({
131-resolveProviderBinaryThinking: providerThinkingMocks.resolveProviderBinaryThinking,
132-resolveProviderDefaultThinkingLevel: providerThinkingMocks.resolveProviderDefaultThinkingLevel,
133-resolveProviderThinkingProfile: providerThinkingMocks.resolveProviderThinkingProfile,
134-resolveProviderXHighThinking: providerThinkingMocks.resolveProviderXHighThinking,
135-}));
166+installProviderThinkingRegistryForTest();
136167const commandAuth = await import("openclaw/plugin-sdk/command-auth");
137168const nativeCommandUi = await import("./native-command-ui.js");
138169return {
@@ -183,6 +214,7 @@ describe("discord native /think autocomplete", () => {
183214 ? true
184215 : undefined,
185216);
217+installProviderThinkingRegistryForTest();
186218fs.mkdirSync(path.dirname(STORE_PATH), { recursive: true });
187219fs.writeFileSync(
188220STORE_PATH,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。