

























@@ -2,60 +2,73 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
2233const getPluginRegistryState = vi.hoisted(() => vi.fn());
44const pluginRegistryMocks = vi.hoisted(() => ({
5-loadPluginManifestRegistryForInstalledIndex: vi.fn(),
6-loadPluginRegistrySnapshot: vi.fn((_params?: unknown) => ({ plugins: [] })),
5+loadPluginRegistrySnapshotWithMetadata: vi.fn((_params?: unknown) => ({
6+source: "persisted",
7+snapshot: { plugins: [] },
8+diagnostics: [],
9+})),
710}));
811912vi.mock("./runtime-state.js", () => ({
1013 getPluginRegistryState,
1114}));
121513-vi.mock("./manifest-registry-installed.js", () => ({
14-loadPluginManifestRegistryForInstalledIndex:
15-pluginRegistryMocks.loadPluginManifestRegistryForInstalledIndex,
16-}));
17-1816vi.mock("./plugin-registry.js", () => ({
19-loadPluginRegistrySnapshot: pluginRegistryMocks.loadPluginRegistrySnapshot,
20-loadPluginManifestRegistryForPluginRegistry: () =>
21-pluginRegistryMocks.loadPluginManifestRegistryForInstalledIndex({
22-index: pluginRegistryMocks.loadPluginRegistrySnapshot({ cache: true }),
23-includeDisabled: true,
24-}),
17+loadPluginRegistrySnapshotWithMetadata:
18+pluginRegistryMocks.loadPluginRegistrySnapshotWithMetadata,
2519}));
26202721import { resolveRuntimeSyntheticAuthProviderRefs } from "./synthetic-auth.runtime.js";
28222923describe("synthetic auth runtime refs", () => {
3024beforeEach(() => {
3125getPluginRegistryState.mockReset();
32-pluginRegistryMocks.loadPluginManifestRegistryForInstalledIndex
33-.mockReset()
34-.mockReturnValue({ plugins: [] });
35-pluginRegistryMocks.loadPluginRegistrySnapshot.mockReset().mockReturnValue({ plugins: [] });
26+pluginRegistryMocks.loadPluginRegistrySnapshotWithMetadata.mockReset().mockReturnValue({
27+source: "persisted",
28+snapshot: { plugins: [] },
29+diagnostics: [],
30+});
3631});
373238-it("uses manifest-owned synthetic auth refs before the runtime registry exists", () => {
39-pluginRegistryMocks.loadPluginManifestRegistryForInstalledIndex.mockReturnValue({
40-plugins: [
41-{ syntheticAuthRefs: [" local-provider ", "local-provider", "local-cli"] },
42-{ syntheticAuthRefs: ["remote-provider"] },
43-{ syntheticAuthRefs: [] },
44-],
33+it("uses persisted registry synthetic auth refs before the runtime registry exists", () => {
34+pluginRegistryMocks.loadPluginRegistrySnapshotWithMetadata.mockReturnValue({
35+source: "persisted",
36+snapshot: {
37+plugins: [
38+{ syntheticAuthRefs: [" local-provider ", "local-provider", "local-cli"] },
39+{ syntheticAuthRefs: ["remote-provider"] },
40+{ syntheticAuthRefs: [] },
41+],
42+},
43+diagnostics: [],
4544});
46454746expect(resolveRuntimeSyntheticAuthProviderRefs()).toEqual([
4847"local-provider",
4948"local-cli",
5049"remote-provider",
5150]);
52-expect(pluginRegistryMocks.loadPluginRegistrySnapshot).toHaveBeenCalledWith({ cache: true });
53-expect(pluginRegistryMocks.loadPluginManifestRegistryForInstalledIndex).toHaveBeenCalledWith({
54-index: expect.anything(),
55-includeDisabled: true,
51+expect(pluginRegistryMocks.loadPluginRegistrySnapshotWithMetadata).toHaveBeenCalledWith({
52+cache: true,
5653});
5754});
585556+it("does not derive the registry just to resolve synthetic auth refs", () => {
57+pluginRegistryMocks.loadPluginRegistrySnapshotWithMetadata.mockReturnValue({
58+source: "derived",
59+snapshot: {
60+plugins: [
61+{ syntheticAuthRefs: [" local-provider ", "local-provider", "local-cli"] },
62+{ syntheticAuthRefs: ["remote-provider"] },
63+{ syntheticAuthRefs: [] },
64+],
65+},
66+diagnostics: [],
67+});
68+69+expect(resolveRuntimeSyntheticAuthProviderRefs()).toEqual([]);
70+});
71+5972it("prefers the active runtime registry when plugins are already loaded", () => {
6073getPluginRegistryState.mockReturnValue({
6174activeRegistry: {
@@ -84,7 +97,6 @@ describe("synthetic auth runtime refs", () => {
8497});
85988699expect(resolveRuntimeSyntheticAuthProviderRefs()).toEqual(["runtime-provider", "runtime-cli"]);
87-expect(pluginRegistryMocks.loadPluginManifestRegistryForInstalledIndex).not.toHaveBeenCalled();
88-expect(pluginRegistryMocks.loadPluginRegistrySnapshot).not.toHaveBeenCalled();
100+expect(pluginRegistryMocks.loadPluginRegistrySnapshotWithMetadata).not.toHaveBeenCalled();
89101});
90102});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。