惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 【当耐特】
The Cloudflare Blog
博客园 - 聂微东
博客园 - 司徒正美
量子位
博客园 - 三生石上(FineUI控件)
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
Y
Y Combinator Blog
S
SegmentFault 最新的问题
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
A
About on SuperTechFans

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test: cover model list source planning · openclaw/opencla...
shakkernerd · 2026-04-27 · via Recent Commits to openclaw:main

@@ -0,0 +1,115 @@

1+

import { beforeEach, describe, expect, it, vi } from "vitest";

2+3+

const mocks = vi.hoisted(() => ({

4+

loadStaticManifestCatalogRowsForList: vi.fn(),

5+

loadProviderIndexCatalogRowsForList: vi.fn(),

6+

hasProviderStaticCatalogForFilter: vi.fn(),

7+

}));

8+9+

vi.mock("./list.manifest-catalog.js", () => ({

10+

loadStaticManifestCatalogRowsForList: mocks.loadStaticManifestCatalogRowsForList,

11+

}));

12+13+

vi.mock("./list.provider-index-catalog.js", () => ({

14+

loadProviderIndexCatalogRowsForList: mocks.loadProviderIndexCatalogRowsForList,

15+

}));

16+17+

vi.mock("./list.provider-catalog.js", () => ({

18+

hasProviderStaticCatalogForFilter: mocks.hasProviderStaticCatalogForFilter,

19+

}));

20+21+

const catalogRow = {

22+

provider: "moonshot",

23+

id: "kimi-k2.6",

24+

ref: "moonshot/kimi-k2.6",

25+

mergeKey: "moonshot::kimi-k2.6",

26+

name: "Kimi K2.6",

27+

source: "manifest",

28+

input: ["text"],

29+

reasoning: false,

30+

status: "available",

31+

} as const;

32+33+

describe("planAllModelListSources", () => {

34+

beforeEach(() => {

35+

vi.clearAllMocks();

36+

mocks.loadStaticManifestCatalogRowsForList.mockReturnValue([]);

37+

mocks.loadProviderIndexCatalogRowsForList.mockReturnValue([]);

38+

mocks.hasProviderStaticCatalogForFilter.mockResolvedValue(false);

39+

});

40+41+

it("uses installed manifest rows before provider index or runtime catalog sources", async () => {

42+

const { planAllModelListSources } = await import("./list.source-plan.js");

43+

mocks.loadStaticManifestCatalogRowsForList.mockReturnValueOnce([catalogRow]);

44+45+

const plan = await planAllModelListSources({

46+

all: true,

47+

providerFilter: "moonshot",

48+

cfg: {},

49+

});

50+51+

expect(plan).toMatchObject({

52+

kind: "manifest",

53+

requiresInitialRegistry: false,

54+

skipRuntimeModelSuppression: true,

55+

});

56+

expect(plan.manifestCatalogRows).toEqual([catalogRow]);

57+

expect(mocks.loadProviderIndexCatalogRowsForList).not.toHaveBeenCalled();

58+

expect(mocks.hasProviderStaticCatalogForFilter).not.toHaveBeenCalled();

59+

});

60+61+

it("uses provider index rows only when installed manifest rows are unavailable", async () => {

62+

const { planAllModelListSources } = await import("./list.source-plan.js");

63+

const providerIndexRow = { ...catalogRow, source: "provider-index" };

64+

mocks.loadProviderIndexCatalogRowsForList.mockReturnValueOnce([providerIndexRow]);

65+66+

const plan = await planAllModelListSources({

67+

all: true,

68+

providerFilter: "moonshot",

69+

cfg: {},

70+

});

71+72+

expect(plan).toMatchObject({

73+

kind: "provider-index",

74+

requiresInitialRegistry: false,

75+

skipRuntimeModelSuppression: true,

76+

});

77+

expect(plan.providerIndexCatalogRows).toEqual([providerIndexRow]);

78+

expect(mocks.hasProviderStaticCatalogForFilter).not.toHaveBeenCalled();

79+

});

80+81+

it("keeps scoped runtime catalog fallback separate from broad registry loading", async () => {

82+

const { planAllModelListSources } = await import("./list.source-plan.js");

83+84+

await expect(

85+

planAllModelListSources({

86+

all: true,

87+

providerFilter: "openrouter",

88+

cfg: {},

89+

}),

90+

).resolves.toMatchObject({

91+

kind: "provider-runtime-scoped",

92+

requiresInitialRegistry: false,

93+

skipRuntimeModelSuppression: false,

94+

fallbackToRegistryWhenEmpty: false,

95+

});

96+

});

97+98+

it("falls back to registry only for provider static fast paths that return no rows", async () => {

99+

const { planAllModelListSources } = await import("./list.source-plan.js");

100+

mocks.hasProviderStaticCatalogForFilter.mockResolvedValueOnce(true);

101+102+

await expect(

103+

planAllModelListSources({

104+

all: true,

105+

providerFilter: "codex",

106+

cfg: {},

107+

}),

108+

).resolves.toMatchObject({

109+

kind: "provider-runtime-static",

110+

requiresInitialRegistry: false,

111+

skipRuntimeModelSuppression: true,

112+

fallbackToRegistryWhenEmpty: true,

113+

});

114+

});

115+

});