From aad0559de0e2ecbc185e1d30465e017cb991ddae Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Thu, 18 Jun 2026 21:10:31 +0800 Subject: [PATCH] refactor(test): dedupe bundled plugin record fixtures --- .../reply/commands-diagnostics.test.ts | 41 +------------------ src/plugins/commands.test.ts | 41 +------------------ src/plugins/status.test-helpers.ts | 9 ++++ 3 files changed, 13 insertions(+), 78 deletions(-) diff --git a/src/auto-reply/reply/commands-diagnostics.test.ts b/src/auto-reply/reply/commands-diagnostics.test.ts index f3ffa72187a..7a5b5e5aecd 100644 --- a/src/auto-reply/reply/commands-diagnostics.test.ts +++ b/src/auto-reply/reply/commands-diagnostics.test.ts @@ -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[1], ) { diff --git a/src/plugins/commands.test.ts b/src/plugins/commands.test.ts index 88902f37efc..f324375da68 100644 --- a/src/plugins/commands.test.ts +++ b/src/plugins/commands.test.ts @@ -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[1], ) { diff --git a/src/plugins/status.test-helpers.ts b/src/plugins/status.test-helpers.ts index 794907821d3..8d6c6e07a11 100644 --- a/src/plugins/status.test-helpers.ts +++ b/src/plugins/status.test-helpers.ts @@ -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;