From 2e2e33cfc0266c0b6972b2cabe9412b908ce33fb Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Fri, 22 May 2026 00:06:08 +0900 Subject: [PATCH] test: fix stale imports after prompt-async-gate and model-core refactors - prompt-async-gate.test.ts: refactor ced36bffc removed promptAsyncAfterSessionIdle in favor of the unified dispatchInternalPrompt({ mode: 'async', ... }). One call site at line 1441 was left behind. Replace it with the current API and pass the explicit dispatchTimeoutMs so the status-timeout semantics are preserved. Also switch the surrounding tests to the third-argument timeout form so Bun's typings stay happy. - runtime-model-readers.test.ts: implementation moved to packages/model-core during the layering refactor; the orphaned test still pointed at './runtime-model-readers'. Switch to the package export via getModelCapabilities and keep the modality-reader coverage by deriving keys through the package API. --- src/hooks/shared/prompt-async-gate.test.ts | 10 ++++---- .../runtime-model-readers.test.ts | 24 ++++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/hooks/shared/prompt-async-gate.test.ts b/src/hooks/shared/prompt-async-gate.test.ts index 10c4f3840..f3b61d881 100644 --- a/src/hooks/shared/prompt-async-gate.test.ts +++ b/src/hooks/shared/prompt-async-gate.test.ts @@ -7,7 +7,7 @@ import { releasePromptAsyncReservation, } from "./prompt-async-gate" -function waitForPromise(promise: Promise, label: string): Promise { +async function waitForPromise(promise: Promise, label: string): Promise { let timeoutID: ReturnType | undefined const timeout = new Promise((_, reject) => { timeoutID = setTimeout(() => reject(new Error(`timed out waiting for ${label}`)), 1_000) @@ -1424,7 +1424,7 @@ describe("dispatchInternalPrompt shared gate behavior", () => { }) }) - test("#given session.status hangs forever #when promptAsync gate checks activity #then it dispatches after status timeout", { timeout: 10_000 }, async () => { + test("#given session.status hangs forever #when promptAsync gate checks activity #then it dispatches after status timeout", async () => { // given let promptCalls = 0 const neverSettles = new Promise(() => {}) @@ -1438,17 +1438,19 @@ describe("dispatchInternalPrompt shared gate behavior", () => { } // when - const result = await promptAsyncAfterSessionIdle({ + const result = await dispatchInternalPrompt({ + mode: "async", client, sessionID: "ses_status_timeout", input: { path: { id: "ses_status_timeout" }, body: { parts: [] } }, source: "test:status-timeout", settleMs: 0, postDispatchHoldMs: 0, + dispatchTimeoutMs: 50, }) // then expect(result.status).toBe("dispatched") expect(promptCalls).toBe(1) - }) + }, 10_000) }) diff --git a/src/shared/model-capabilities/runtime-model-readers.test.ts b/src/shared/model-capabilities/runtime-model-readers.test.ts index 2433d9a45..c92860f1d 100644 --- a/src/shared/model-capabilities/runtime-model-readers.test.ts +++ b/src/shared/model-capabilities/runtime-model-readers.test.ts @@ -1,5 +1,13 @@ import { describe, expect, it } from "bun:test" -import { readRuntimeModelModalities } from "./runtime-model-readers" +import { getModelCapabilities } from "@oh-my-opencode/model-core" + +function readRuntimeModelModalities(runtimeModel: Record) { + return getModelCapabilities({ + providerID: "test-provider", + modelID: "test-model", + runtimeModel, + }).modalities +} describe("readRuntimeModelModalities", () => { describe("object-shaped modalities (OpenCode schema)", () => { @@ -12,7 +20,7 @@ describe("readRuntimeModelModalities", () => { }, } - const result = readRuntimeModelModalities(runtimeModel as Record) + const result = readRuntimeModelModalities(runtimeModel) expect(result).toBeDefined() expect(result?.input).toEqual(["text", "image", "pdf"]) @@ -28,7 +36,7 @@ describe("readRuntimeModelModalities", () => { }, } - const result = readRuntimeModelModalities(runtimeModel as Record) + const result = readRuntimeModelModalities(runtimeModel) expect(result?.input).toEqual(["text", "image", "pdf"]) expect(result?.output).toEqual(["text"]) @@ -45,7 +53,7 @@ describe("readRuntimeModelModalities", () => { }, } - const result = readRuntimeModelModalities(runtimeModel as Record) + const result = readRuntimeModelModalities(runtimeModel) expect(result).toBeDefined() expect(result?.input).toEqual(["text", "audio"]) @@ -64,7 +72,7 @@ describe("readRuntimeModelModalities", () => { }, } - const result = readRuntimeModelModalities(runtimeModel as Record) + const result = readRuntimeModelModalities(runtimeModel) // Boolean maps are only recognized inside input/output keys, not at the modalities root expect(result).toBeUndefined() @@ -75,7 +83,7 @@ describe("readRuntimeModelModalities", () => { it("#given modalities is undefined #when reading runtime model #then returns undefined", () => { const runtimeModel = { id: "test-model" } - const result = readRuntimeModelModalities(runtimeModel as Record) + const result = readRuntimeModelModalities(runtimeModel) expect(result).toBeUndefined() }) @@ -90,7 +98,7 @@ describe("readRuntimeModelModalities", () => { } expect(() => { - readRuntimeModelModalities(runtimeModel as Record) + readRuntimeModelModalities(runtimeModel) }).not.toThrow() }) @@ -104,7 +112,7 @@ describe("readRuntimeModelModalities", () => { } expect(() => { - readRuntimeModelModalities(runtimeModel as Record) + readRuntimeModelModalities(runtimeModel) }).not.toThrow() }) })