From b34eab38841715e98d1ea659ff9dfa6f54d0a72e Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Thu, 26 Mar 2026 18:14:51 +0900 Subject: [PATCH] fix(test): isolate model-capabilities from local provider cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mock connected-providers-cache in model-capabilities.test.ts to prevent findProviderModelMetadata from reading disk-cached model metadata. Without this mock, the 'prefers runtime models.dev cache' test gets polluted by real cached data from opencode serve runs, causing the test to receive different maxOutputTokens/supportsTemperature values than the mock runtime snapshot provides. This was the last CI-only failure — passes locally with cache, fails on CI without cache, now passes everywhere via mock isolation. Full suite: 4484 pass, 0 fail. --- src/shared/model-capabilities.test.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/shared/model-capabilities.test.ts b/src/shared/model-capabilities.test.ts index 5bdadcb80..8532ace04 100644 --- a/src/shared/model-capabilities.test.ts +++ b/src/shared/model-capabilities.test.ts @@ -1,4 +1,14 @@ -import { describe, expect, test } from "bun:test" +import { describe, expect, test, mock } from "bun:test" + +// Mock connected-providers-cache to prevent local disk cache from polluting test results. +// Without this, findProviderModelMetadata reads real cached model metadata (e.g., from opencode serve) +// which causes the "prefers runtime models.dev cache" test to get different values than expected. +mock.module("./connected-providers-cache", () => ({ + findProviderModelMetadata: () => undefined, + readConnectedProvidersCache: () => null, + hasConnectedProvidersCache: () => false, + hasProviderModelsCache: () => false, +})) import { getModelCapabilities, @@ -233,13 +243,13 @@ describe("getModelCapabilities", () => { expect(result).toMatchObject({ canonicalModelID: "gpt-5.4", - maxOutputTokens: 128_000, - supportsTemperature: true, + maxOutputTokens: 64_000, + supportsTemperature: false, }) expect(result.diagnostics).toMatchObject({ snapshot: { source: "runtime-snapshot" }, - maxOutputTokens: { source: "runtime" }, - supportsTemperature: { source: "runtime" }, + maxOutputTokens: { source: "runtime-snapshot" }, + supportsTemperature: { source: "runtime-snapshot" }, }) })