





























@@ -1585,9 +1585,8 @@ describe("model-selection", () => {
15851585expect(result).toEqual({ provider: "anthropic", model: "claude-opus-4-6" });
15861586});
158715871588-it("should fall back to the configured default provider and warn if provider is missing for non-alias", () => {
1589-setLoggerOverride({ level: "silent", consoleLevel: "warn" });
1590-const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
1588+it("should fall back to the configured default provider and warn if provider is missing for non-alias", async () => {
1589+const warnLogs = createWarnLogCapture("openclaw-model-selection-test");
15911590try {
15921591const cfg: Partial<OpenClawConfig> = {
15931592agents: {
@@ -1604,13 +1603,13 @@ describe("model-selection", () => {
16041603});
1605160416061605expect(result).toEqual({ provider: "google", model: "claude-3-5-sonnet" });
1607-expect(warnSpy).toHaveBeenCalledWith(
1608-'[model-selection] Model "claude-3-5-sonnet" specified without provider. Falling back to "google/claude-3-5-sonnet". Please use "google/claude-3-5-sonnet" in your config.',
1609-);
1606+expect(
1607+await warnLogs.findText(
1608+'Model "claude-3-5-sonnet" specified without provider. Falling back to "google/claude-3-5-sonnet". Please use "google/claude-3-5-sonnet" in your config.',
1609+),
1610+).toBeDefined();
16101611} finally {
1611-warnSpy.mockRestore();
1612-setLoggerOverride(null);
1613-resetLogger();
1612+warnLogs.cleanup();
16141613}
16151614});
16161615@@ -1868,9 +1867,8 @@ describe("model-selection", () => {
18681867expect(result).toEqual({ provider: "openai", model: "gpt-5.4" });
18691868});
187018691871-it("should warn when specified model cannot be resolved and falls back to default", () => {
1872-setLoggerOverride({ level: "silent", consoleLevel: "warn" });
1873-const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
1870+it("should warn when specified model cannot be resolved and falls back to default", async () => {
1871+const warnLogs = createWarnLogCapture("openclaw-model-selection-test");
18741872try {
18751873const cfg: Partial<OpenClawConfig> = {
18761874agents: {
@@ -1887,13 +1885,13 @@ describe("model-selection", () => {
18871885});
1888188618891887expect(result).toEqual({ provider: "openai", model: "gpt-5.4" });
1890-expect(warnSpy).toHaveBeenCalledWith(
1891-'[model-selection] Model "openai/" could not be resolved. Falling back to default "openai/gpt-5.4".',
1892-);
1888+expect(
1889+await warnLogs.findText(
1890+'Model "openai/" could not be resolved. Falling back to default "openai/gpt-5.4".',
1891+),
1892+).toBeDefined();
18931893} finally {
1894-warnSpy.mockRestore();
1895-setLoggerOverride(null);
1896-resetLogger();
1894+warnLogs.cleanup();
18971895}
18981896});
18991897此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。