diff --git a/src/gateway/server/__tests__/test-utils.ts b/src/gateway/server/__tests__/test-utils.ts index bfc6a687170..6adf47d9fb9 100644 --- a/src/gateway/server/__tests__/test-utils.ts +++ b/src/gateway/server/__tests__/test-utils.ts @@ -1,22 +1,7 @@ -import type { PluginRegistry } from "../../../plugins/registry.js"; +import { createEmptyPluginRegistry, type PluginRegistry } from "../../../plugins/registry.js"; export const createTestRegistry = (overrides: Partial = {}): PluginRegistry => { - const base: PluginRegistry = { - plugins: [], - tools: [], - hooks: [], - typedHooks: [], - channels: [], - providers: [], - gatewayHandlers: {}, - httpHandlers: [], - httpRoutes: [], - cliRegistrars: [], - services: [], - commands: [], - diagnostics: [], - }; - const merged = { ...base, ...overrides }; + const merged = { ...createEmptyPluginRegistry(), ...overrides }; return { ...merged, gatewayHandlers: merged.gatewayHandlers ?? {}, diff --git a/src/plugins/registry.ts b/src/plugins/registry.ts index ef763910036..29f2f87aa85 100644 --- a/src/plugins/registry.ts +++ b/src/plugins/registry.ts @@ -143,8 +143,8 @@ export type PluginRegistryParams = { runtime: PluginRuntime; }; -export function createPluginRegistry(registryParams: PluginRegistryParams) { - const registry: PluginRegistry = { +export function createEmptyPluginRegistry(): PluginRegistry { + return { plugins: [], tools: [], hooks: [], @@ -159,6 +159,10 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) { commands: [], diagnostics: [], }; +} + +export function createPluginRegistry(registryParams: PluginRegistryParams) { + const registry = createEmptyPluginRegistry(); const coreGatewayMethods = new Set(Object.keys(registryParams.coreGatewayHandlers ?? {})); const pushDiagnostic = (diag: PluginDiagnostic) => {