mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-22 07:38:12 +00:00
refactor(test): dedupe bundled plugin record fixtures
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { clearPluginCommands, registerPluginCommand } from "../../plugins/commands.js";
|
||||
import { createPluginRegistry, type PluginRecord } from "../../plugins/registry.js";
|
||||
import { createPluginRegistry } from "../../plugins/registry.js";
|
||||
import type { PluginRuntime } from "../../plugins/runtime/types.js";
|
||||
import { createBundledPluginRecord } from "../../plugins/status.test-helpers.js";
|
||||
import type { PluginCommandContext, PluginCommandHandler } from "../../plugins/types.js";
|
||||
import type { MsgContext } from "../templating.js";
|
||||
import { createDiagnosticsCommandHandler } from "./commands-diagnostics.js";
|
||||
@@ -104,44 +105,6 @@ function buildDiagnosticsParams(
|
||||
} as HandleCommandsParams;
|
||||
}
|
||||
|
||||
function createBundledPluginRecord(id: string): PluginRecord {
|
||||
return {
|
||||
id,
|
||||
name: id,
|
||||
source: `bundled:${id}`,
|
||||
rootDir: `/bundled/${id}`,
|
||||
origin: "bundled",
|
||||
enabled: true,
|
||||
status: "loaded",
|
||||
toolNames: [],
|
||||
hookNames: [],
|
||||
channelIds: [],
|
||||
cliBackendIds: [],
|
||||
providerIds: [],
|
||||
embeddingProviderIds: [],
|
||||
speechProviderIds: [],
|
||||
realtimeTranscriptionProviderIds: [],
|
||||
realtimeVoiceProviderIds: [],
|
||||
mediaUnderstandingProviderIds: [],
|
||||
transcriptSourceProviderIds: [],
|
||||
imageGenerationProviderIds: [],
|
||||
videoGenerationProviderIds: [],
|
||||
musicGenerationProviderIds: [],
|
||||
webFetchProviderIds: [],
|
||||
webSearchProviderIds: [],
|
||||
migrationProviderIds: [],
|
||||
memoryEmbeddingProviderIds: [],
|
||||
agentHarnessIds: [],
|
||||
cliCommands: [],
|
||||
services: [],
|
||||
gatewayDiscoveryServiceIds: [],
|
||||
commands: [],
|
||||
httpRoutes: 0,
|
||||
hookCount: 0,
|
||||
configSchema: false,
|
||||
} as PluginRecord;
|
||||
}
|
||||
|
||||
function registerHostTrustedReservedCommandForTest(
|
||||
command: Parameters<typeof registerPluginCommand>[1],
|
||||
) {
|
||||
|
||||
@@ -13,9 +13,10 @@ import {
|
||||
matchPluginCommand,
|
||||
registerPluginCommand,
|
||||
} from "./commands.js";
|
||||
import { createPluginRegistry, type PluginRecord } from "./registry.js";
|
||||
import { createPluginRegistry } from "./registry.js";
|
||||
import { setActivePluginRegistry } from "./runtime.js";
|
||||
import type { PluginRuntime } from "./runtime/types.js";
|
||||
import { createBundledPluginRecord } from "./status.test-helpers.js";
|
||||
|
||||
const completionMocks = vi.hoisted(() => ({
|
||||
prepareSimpleCompletionModelForAgent: vi.fn(),
|
||||
@@ -48,44 +49,6 @@ function createVoiceCommand(overrides: Partial<Parameters<typeof registerPluginC
|
||||
};
|
||||
}
|
||||
|
||||
function createBundledPluginRecord(id: string): PluginRecord {
|
||||
return {
|
||||
id,
|
||||
name: id,
|
||||
source: `bundled:${id}`,
|
||||
rootDir: `/bundled/${id}`,
|
||||
origin: "bundled",
|
||||
enabled: true,
|
||||
status: "loaded",
|
||||
toolNames: [],
|
||||
hookNames: [],
|
||||
channelIds: [],
|
||||
cliBackendIds: [],
|
||||
providerIds: [],
|
||||
embeddingProviderIds: [],
|
||||
speechProviderIds: [],
|
||||
realtimeTranscriptionProviderIds: [],
|
||||
realtimeVoiceProviderIds: [],
|
||||
mediaUnderstandingProviderIds: [],
|
||||
transcriptSourceProviderIds: [],
|
||||
imageGenerationProviderIds: [],
|
||||
videoGenerationProviderIds: [],
|
||||
musicGenerationProviderIds: [],
|
||||
webFetchProviderIds: [],
|
||||
webSearchProviderIds: [],
|
||||
migrationProviderIds: [],
|
||||
memoryEmbeddingProviderIds: [],
|
||||
agentHarnessIds: [],
|
||||
cliCommands: [],
|
||||
services: [],
|
||||
gatewayDiscoveryServiceIds: [],
|
||||
commands: [],
|
||||
httpRoutes: 0,
|
||||
hookCount: 0,
|
||||
configSchema: false,
|
||||
} as PluginRecord;
|
||||
}
|
||||
|
||||
function registerHostTrustedReservedCommandForTest(
|
||||
command: Parameters<typeof registerPluginCommand>[1],
|
||||
) {
|
||||
|
||||
@@ -93,6 +93,15 @@ export function createPluginRecord(
|
||||
};
|
||||
}
|
||||
|
||||
export function createBundledPluginRecord(id: string): PluginRecord {
|
||||
return createPluginRecord({
|
||||
id,
|
||||
source: `bundled:${id}`,
|
||||
rootDir: `/bundled/${id}`,
|
||||
origin: "bundled",
|
||||
});
|
||||
}
|
||||
|
||||
export function createTypedHook(params: {
|
||||
pluginId: string;
|
||||
hookName: PluginHookName;
|
||||
|
||||
Reference in New Issue
Block a user