




















@@ -0,0 +1,73 @@
1+import { describe, expect, it, vi } from "vitest";
2+3+const mocks = vi.hoisted(() => ({
4+loadPluginRegistrySnapshot: vi.fn(),
5+resolvePluginContributionOwners: vi.fn(),
6+getPluginRecord: vi.fn(),
7+isPluginEnabled: vi.fn(),
8+loadPluginManifestRegistryForInstalledIndex: vi.fn(),
9+}));
10+11+vi.mock("../../plugins/plugin-registry.js", () => ({
12+loadPluginRegistrySnapshot: mocks.loadPluginRegistrySnapshot,
13+resolvePluginContributionOwners: mocks.resolvePluginContributionOwners,
14+getPluginRecord: mocks.getPluginRecord,
15+isPluginEnabled: mocks.isPluginEnabled,
16+}));
17+18+vi.mock("../../plugins/manifest-registry-installed.js", () => ({
19+loadPluginManifestRegistryForInstalledIndex: mocks.loadPluginManifestRegistryForInstalledIndex,
20+}));
21+22+const moonshotPlugin = {
23+id: "moonshot",
24+providers: ["moonshot"],
25+modelCatalog: {
26+providers: {
27+moonshot: {
28+models: [{ id: "kimi-k2.6", name: "Kimi K2.6" }],
29+},
30+},
31+discovery: {
32+moonshot: "static",
33+},
34+},
35+};
36+37+const openrouterPlugin = {
38+id: "openrouter",
39+providers: ["openrouter"],
40+modelCatalog: {
41+providers: {
42+openrouter: {
43+models: [{ id: "auto", name: "Auto" }],
44+},
45+},
46+discovery: {
47+openrouter: "refreshable",
48+},
49+},
50+};
51+52+describe("loadStaticManifestCatalogRowsForList", () => {
53+it("loads all static manifest catalog rows without a provider filter", async () => {
54+const { loadStaticManifestCatalogRowsForList } = await import("./list.manifest-catalog.js");
55+const index = { plugins: [], diagnostics: [] };
56+mocks.loadPluginRegistrySnapshot.mockReturnValueOnce(index);
57+mocks.loadPluginManifestRegistryForInstalledIndex.mockReturnValueOnce({
58+plugins: [openrouterPlugin, moonshotPlugin],
59+diagnostics: [],
60+});
61+62+expect(
63+loadStaticManifestCatalogRowsForList({
64+cfg: {},
65+}).map((row) => row.ref),
66+).toEqual(["moonshot/kimi-k2.6"]);
67+expect(mocks.loadPluginManifestRegistryForInstalledIndex).toHaveBeenCalledWith({
68+ index,
69+config: {},
70+env: undefined,
71+});
72+});
73+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。