


























@@ -1,26 +1,37 @@
11import { beforeEach, describe, expect, it, vi } from "vitest";
2233const getPluginRegistryState = vi.hoisted(() => vi.fn());
4-const loadPluginManifestRegistry = vi.hoisted(() => vi.fn());
4+const pluginRegistryMocks = vi.hoisted(() => ({
5+loadPluginManifestRegistryForInstalledIndex: vi.fn(),
6+loadPluginRegistrySnapshot: vi.fn(() => ({ plugins: [] })),
7+}));
5869vi.mock("./runtime-state.js", () => ({
710 getPluginRegistryState,
811}));
91210-vi.mock("./manifest-registry.js", () => ({
11- loadPluginManifestRegistry,
13+vi.mock("./manifest-registry-installed.js", () => ({
14+loadPluginManifestRegistryForInstalledIndex:
15+pluginRegistryMocks.loadPluginManifestRegistryForInstalledIndex,
16+}));
17+18+vi.mock("./plugin-registry.js", () => ({
19+loadPluginRegistrySnapshot: pluginRegistryMocks.loadPluginRegistrySnapshot,
1220}));
13211422import { resolveRuntimeSyntheticAuthProviderRefs } from "./synthetic-auth.runtime.js";
15231624describe("synthetic auth runtime refs", () => {
1725beforeEach(() => {
1826getPluginRegistryState.mockReset();
19-loadPluginManifestRegistry.mockReset().mockReturnValue({ plugins: [] });
27+pluginRegistryMocks.loadPluginManifestRegistryForInstalledIndex
28+.mockReset()
29+.mockReturnValue({ plugins: [] });
30+pluginRegistryMocks.loadPluginRegistrySnapshot.mockReset().mockReturnValue({ plugins: [] });
2031});
21322233it("uses manifest-owned synthetic auth refs before the runtime registry exists", () => {
23-loadPluginManifestRegistry.mockReturnValue({
34+pluginRegistryMocks.loadPluginManifestRegistryForInstalledIndex.mockReturnValue({
2435plugins: [
2536{ syntheticAuthRefs: [" local-provider ", "local-provider", "local-cli"] },
2637{ syntheticAuthRefs: ["remote-provider"] },
@@ -33,7 +44,11 @@ describe("synthetic auth runtime refs", () => {
3344"local-cli",
3445"remote-provider",
3546]);
36-expect(loadPluginManifestRegistry).toHaveBeenCalledWith({ cache: true });
47+expect(pluginRegistryMocks.loadPluginRegistrySnapshot).toHaveBeenCalledWith({ cache: true });
48+expect(pluginRegistryMocks.loadPluginManifestRegistryForInstalledIndex).toHaveBeenCalledWith({
49+index: expect.anything(),
50+includeDisabled: true,
51+});
3752});
38533954it("prefers the active runtime registry when plugins are already loaded", () => {
@@ -64,6 +79,7 @@ describe("synthetic auth runtime refs", () => {
6479});
65806681expect(resolveRuntimeSyntheticAuthProviderRefs()).toEqual(["runtime-provider", "runtime-cli"]);
67-expect(loadPluginManifestRegistry).not.toHaveBeenCalled();
82+expect(pluginRegistryMocks.loadPluginManifestRegistryForInstalledIndex).not.toHaveBeenCalled();
83+expect(pluginRegistryMocks.loadPluginRegistrySnapshot).not.toHaveBeenCalled();
6884});
6985});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。