

























@@ -154,6 +154,44 @@ function expectInitialRuntimeRegistryLookup() {
154154expect(mocks.resolveRuntimePluginRegistry).toHaveBeenNthCalledWith(1);
155155}
156156157+function requireManifestRegistryLoadParams(index = 0): Record<string, unknown> {
158+const call = mocks.loadPluginManifestRegistry.mock.calls[index] as
159+| [Record<string, unknown>]
160+| undefined;
161+if (!call) {
162+throw new Error(`loadPluginManifestRegistry call ${index} missing`);
163+}
164+return call[0];
165+}
166+167+function expectManifestRegistryLoad(index: number, config: OpenClawConfig | Record<string, never>) {
168+const params = requireManifestRegistryLoadParams(index);
169+expect(params.config).toEqual(config);
170+expect(params.env).toBe(process.env);
171+}
172+173+function requireRuntimeRegistryLookup(params: {
174+activate?: boolean;
175+onlyPluginIds?: string[];
176+}): Record<string, unknown> {
177+const lookup = mocks.resolveRuntimePluginRegistry.mock.calls
178+.map(([options]) => options)
179+.find(
180+(options): options is Record<string, unknown> =>
181+Boolean(options) &&
182+typeof options === "object" &&
183+(params.activate === undefined ||
184+(options as { activate?: unknown }).activate === params.activate) &&
185+(params.onlyPluginIds === undefined ||
186+JSON.stringify((options as { onlyPluginIds?: unknown }).onlyPluginIds) ===
187+JSON.stringify(params.onlyPluginIds)),
188+);
189+if (!lookup) {
190+throw new Error("runtime registry lookup missing");
191+}
192+return lookup;
193+}
194+157195function collectActiveRegistryLookups() {
158196return mocks.resolveRuntimePluginRegistry.mock.calls
159197.map(([options]) => options)
@@ -177,12 +215,7 @@ function expectBundledCompatLoadPath(params: {
177215};
178216};
179217}) {
180-expect(mocks.loadPluginManifestRegistry).toHaveBeenCalledWith(
181-expect.objectContaining({
182-config: params.cfg,
183-env: process.env,
184-}),
185-);
218+expectManifestRegistryLoad(0, params.cfg);
186219expect(mocks.withBundledPluginEnablementCompat).toHaveBeenCalledWith({
187220config: params.allowlistCompat,
188221pluginIds: ["openai"],
@@ -580,12 +613,12 @@ describe("resolvePluginCapabilityProviders", () => {
580613expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
581614onlyPluginIds: ["fish-audio"],
582615});
583-expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith(
584-expect.objectContaining({
585- activate: false,
586- onlyPluginIds: ["fish-audio"],
587- }),
588-);
616+const inactiveLookup = requireRuntimeRegistryLookup({
617+activate: false,
618+onlyPluginIds: ["fish-audio"],
619+});
620+expect(inactiveLookup.activate).toBe(false);
621+expect(inactiveLookup.onlyPluginIds).toEqual(["fish-audio"]);
589622expect(mocks.loadBundledCapabilityRuntimeRegistry).not.toHaveBeenCalled();
590623});
591624@@ -758,9 +791,14 @@ describe("resolvePluginCapabilityProviders", () => {
758791759792expectResolvedCapabilityProviderIds(providers, ["acme"]);
760793expectInitialRuntimeRegistryLookup();
761-expect(mocks.resolveRuntimePluginRegistry).not.toHaveBeenCalledWith({
762-config: expect.anything(),
763-});
794+expect(
795+mocks.resolveRuntimePluginRegistry.mock.calls.some(
796+([options]) =>
797+Boolean(options) &&
798+typeof options === "object" &&
799+Object.hasOwn(options as Record<string, unknown>, "config"),
800+),
801+).toBe(false);
764802});
765803766804it("merges active and allowlisted bundled capability providers when cfg is passed", () => {
@@ -1260,12 +1298,7 @@ describe("resolvePluginCapabilityProviders", () => {
12601298const providers = resolvePluginCapabilityProviders({ key: "mediaUnderstandingProviders" });
1261129912621300expectResolvedCapabilityProviderIds(providers, ["google"]);
1263-expect(mocks.loadPluginManifestRegistry).toHaveBeenCalledWith(
1264-expect.objectContaining({
1265-config: {},
1266-env: process.env,
1267-}),
1268-);
1301+expectManifestRegistryLoad(0, {});
12691302expectActiveRegistryLookup(["google"]);
12701303});
12711304@@ -1378,12 +1411,7 @@ describe("resolvePluginCapabilityProviders", () => {
13781411});
1379141213801413expectResolvedCapabilityProviderIds(providers, ["microsoft"]);
1381-expect(mocks.loadPluginManifestRegistry).toHaveBeenCalledWith(
1382-expect.objectContaining({
1383-config: cfg,
1384-env: process.env,
1385-}),
1386-);
1414+expectManifestRegistryLoad(0, cfg);
13871415expect(mocks.withBundledPluginAllowlistCompat).toHaveBeenCalledWith({
13881416config: cfg,
13891417pluginIds: ["microsoft"],
@@ -1407,12 +1435,7 @@ describe("resolvePluginCapabilityProviders", () => {
14071435});
1408143614091437expectNoResolvedCapabilityProviders(providers as Array<{ id: string }>);
1410-expect(mocks.loadPluginManifestRegistry).toHaveBeenCalledWith(
1411-expect.objectContaining({
1412-config: {},
1413-env: process.env,
1414-}),
1415-);
1438+expectManifestRegistryLoad(0, {});
14161439expectInitialRuntimeRegistryLookup();
14171440expectActiveRegistryLookup([]);
14181441});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。