Skip to content

Commit aad0559

Browse files
committed
refactor(test): dedupe bundled plugin record fixtures
1 parent 712e45d commit aad0559

3 files changed

Lines changed: 13 additions & 78 deletions

File tree

src/auto-reply/reply/commands-diagnostics.test.ts

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
import { afterEach, describe, expect, it, vi } from "vitest";
33
import type { OpenClawConfig } from "../../config/config.js";
44
import { clearPluginCommands, registerPluginCommand } from "../../plugins/commands.js";
5-
import { createPluginRegistry, type PluginRecord } from "../../plugins/registry.js";
5+
import { createPluginRegistry } from "../../plugins/registry.js";
66
import type { PluginRuntime } from "../../plugins/runtime/types.js";
7+
import { createBundledPluginRecord } from "../../plugins/status.test-helpers.js";
78
import type { PluginCommandContext, PluginCommandHandler } from "../../plugins/types.js";
89
import type { MsgContext } from "../templating.js";
910
import { createDiagnosticsCommandHandler } from "./commands-diagnostics.js";
@@ -104,44 +105,6 @@ function buildDiagnosticsParams(
104105
} as HandleCommandsParams;
105106
}
106107

107-
function createBundledPluginRecord(id: string): PluginRecord {
108-
return {
109-
id,
110-
name: id,
111-
source: `bundled:${id}`,
112-
rootDir: `/bundled/${id}`,
113-
origin: "bundled",
114-
enabled: true,
115-
status: "loaded",
116-
toolNames: [],
117-
hookNames: [],
118-
channelIds: [],
119-
cliBackendIds: [],
120-
providerIds: [],
121-
embeddingProviderIds: [],
122-
speechProviderIds: [],
123-
realtimeTranscriptionProviderIds: [],
124-
realtimeVoiceProviderIds: [],
125-
mediaUnderstandingProviderIds: [],
126-
transcriptSourceProviderIds: [],
127-
imageGenerationProviderIds: [],
128-
videoGenerationProviderIds: [],
129-
musicGenerationProviderIds: [],
130-
webFetchProviderIds: [],
131-
webSearchProviderIds: [],
132-
migrationProviderIds: [],
133-
memoryEmbeddingProviderIds: [],
134-
agentHarnessIds: [],
135-
cliCommands: [],
136-
services: [],
137-
gatewayDiscoveryServiceIds: [],
138-
commands: [],
139-
httpRoutes: 0,
140-
hookCount: 0,
141-
configSchema: false,
142-
} as PluginRecord;
143-
}
144-
145108
function registerHostTrustedReservedCommandForTest(
146109
command: Parameters<typeof registerPluginCommand>[1],
147110
) {

src/plugins/commands.test.ts

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import {
1313
matchPluginCommand,
1414
registerPluginCommand,
1515
} from "./commands.js";
16-
import { createPluginRegistry, type PluginRecord } from "./registry.js";
16+
import { createPluginRegistry } from "./registry.js";
1717
import { setActivePluginRegistry } from "./runtime.js";
1818
import type { PluginRuntime } from "./runtime/types.js";
19+
import { createBundledPluginRecord } from "./status.test-helpers.js";
1920

2021
const completionMocks = vi.hoisted(() => ({
2122
prepareSimpleCompletionModelForAgent: vi.fn(),
@@ -48,44 +49,6 @@ function createVoiceCommand(overrides: Partial<Parameters<typeof registerPluginC
4849
};
4950
}
5051

51-
function createBundledPluginRecord(id: string): PluginRecord {
52-
return {
53-
id,
54-
name: id,
55-
source: `bundled:${id}`,
56-
rootDir: `/bundled/${id}`,
57-
origin: "bundled",
58-
enabled: true,
59-
status: "loaded",
60-
toolNames: [],
61-
hookNames: [],
62-
channelIds: [],
63-
cliBackendIds: [],
64-
providerIds: [],
65-
embeddingProviderIds: [],
66-
speechProviderIds: [],
67-
realtimeTranscriptionProviderIds: [],
68-
realtimeVoiceProviderIds: [],
69-
mediaUnderstandingProviderIds: [],
70-
transcriptSourceProviderIds: [],
71-
imageGenerationProviderIds: [],
72-
videoGenerationProviderIds: [],
73-
musicGenerationProviderIds: [],
74-
webFetchProviderIds: [],
75-
webSearchProviderIds: [],
76-
migrationProviderIds: [],
77-
memoryEmbeddingProviderIds: [],
78-
agentHarnessIds: [],
79-
cliCommands: [],
80-
services: [],
81-
gatewayDiscoveryServiceIds: [],
82-
commands: [],
83-
httpRoutes: 0,
84-
hookCount: 0,
85-
configSchema: false,
86-
} as PluginRecord;
87-
}
88-
8952
function registerHostTrustedReservedCommandForTest(
9053
command: Parameters<typeof registerPluginCommand>[1],
9154
) {

src/plugins/status.test-helpers.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ export function createPluginRecord(
9393
};
9494
}
9595

96+
export function createBundledPluginRecord(id: string): PluginRecord {
97+
return createPluginRecord({
98+
id,
99+
source: `bundled:${id}`,
100+
rootDir: `/bundled/${id}`,
101+
origin: "bundled",
102+
});
103+
}
104+
96105
export function createTypedHook(params: {
97106
pluginId: string;
98107
hookName: PluginHookName;

0 commit comments

Comments
 (0)