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.
This commit is contained in:
YeonGyu-Kim
2026-05-22 00:06:08 +09:00
parent 9c9e9885fe
commit 2e2e33cfc0
2 changed files with 22 additions and 12 deletions
+6 -4
View File
@@ -7,7 +7,7 @@ import {
releasePromptAsyncReservation,
} from "./prompt-async-gate"
function waitForPromise<T>(promise: Promise<T>, label: string): Promise<T> {
async function waitForPromise<T>(promise: Promise<T>, label: string): Promise<T> {
let timeoutID: ReturnType<typeof setTimeout> | undefined
const timeout = new Promise<never>((_, 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<never>(() => {})
@@ -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)
})
@@ -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<string, unknown>) {
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<string, unknown>)
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<string, unknown>)
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<string, unknown>)
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<string, unknown>)
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<string, unknown>)
const result = readRuntimeModelModalities(runtimeModel)
expect(result).toBeUndefined()
})
@@ -90,7 +98,7 @@ describe("readRuntimeModelModalities", () => {
}
expect(() => {
readRuntimeModelModalities(runtimeModel as Record<string, unknown>)
readRuntimeModelModalities(runtimeModel)
}).not.toThrow()
})
@@ -104,7 +112,7 @@ describe("readRuntimeModelModalities", () => {
}
expect(() => {
readRuntimeModelModalities(runtimeModel as Record<string, unknown>)
readRuntimeModelModalities(runtimeModel)
}).not.toThrow()
})
})