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:
@@ -7,7 +7,7 @@ import {
|
|||||||
releasePromptAsyncReservation,
|
releasePromptAsyncReservation,
|
||||||
} from "./prompt-async-gate"
|
} 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
|
let timeoutID: ReturnType<typeof setTimeout> | undefined
|
||||||
const timeout = new Promise<never>((_, reject) => {
|
const timeout = new Promise<never>((_, reject) => {
|
||||||
timeoutID = setTimeout(() => reject(new Error(`timed out waiting for ${label}`)), 1_000)
|
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
|
// given
|
||||||
let promptCalls = 0
|
let promptCalls = 0
|
||||||
const neverSettles = new Promise<never>(() => {})
|
const neverSettles = new Promise<never>(() => {})
|
||||||
@@ -1438,17 +1438,19 @@ describe("dispatchInternalPrompt shared gate behavior", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// when
|
// when
|
||||||
const result = await promptAsyncAfterSessionIdle({
|
const result = await dispatchInternalPrompt({
|
||||||
|
mode: "async",
|
||||||
client,
|
client,
|
||||||
sessionID: "ses_status_timeout",
|
sessionID: "ses_status_timeout",
|
||||||
input: { path: { id: "ses_status_timeout" }, body: { parts: [] } },
|
input: { path: { id: "ses_status_timeout" }, body: { parts: [] } },
|
||||||
source: "test:status-timeout",
|
source: "test:status-timeout",
|
||||||
settleMs: 0,
|
settleMs: 0,
|
||||||
postDispatchHoldMs: 0,
|
postDispatchHoldMs: 0,
|
||||||
|
dispatchTimeoutMs: 50,
|
||||||
})
|
})
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(result.status).toBe("dispatched")
|
expect(result.status).toBe("dispatched")
|
||||||
expect(promptCalls).toBe(1)
|
expect(promptCalls).toBe(1)
|
||||||
})
|
}, 10_000)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
import { describe, expect, it } from "bun:test"
|
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("readRuntimeModelModalities", () => {
|
||||||
describe("object-shaped modalities (OpenCode schema)", () => {
|
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).toBeDefined()
|
||||||
expect(result?.input).toEqual(["text", "image", "pdf"])
|
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?.input).toEqual(["text", "image", "pdf"])
|
||||||
expect(result?.output).toEqual(["text"])
|
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).toBeDefined()
|
||||||
expect(result?.input).toEqual(["text", "audio"])
|
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
|
// Boolean maps are only recognized inside input/output keys, not at the modalities root
|
||||||
expect(result).toBeUndefined()
|
expect(result).toBeUndefined()
|
||||||
@@ -75,7 +83,7 @@ describe("readRuntimeModelModalities", () => {
|
|||||||
it("#given modalities is undefined #when reading runtime model #then returns undefined", () => {
|
it("#given modalities is undefined #when reading runtime model #then returns undefined", () => {
|
||||||
const runtimeModel = { id: "test-model" }
|
const runtimeModel = { id: "test-model" }
|
||||||
|
|
||||||
const result = readRuntimeModelModalities(runtimeModel as Record<string, unknown>)
|
const result = readRuntimeModelModalities(runtimeModel)
|
||||||
|
|
||||||
expect(result).toBeUndefined()
|
expect(result).toBeUndefined()
|
||||||
})
|
})
|
||||||
@@ -90,7 +98,7 @@ describe("readRuntimeModelModalities", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
readRuntimeModelModalities(runtimeModel as Record<string, unknown>)
|
readRuntimeModelModalities(runtimeModel)
|
||||||
}).not.toThrow()
|
}).not.toThrow()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -104,7 +112,7 @@ describe("readRuntimeModelModalities", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
readRuntimeModelModalities(runtimeModel as Record<string, unknown>)
|
readRuntimeModelModalities(runtimeModel)
|
||||||
}).not.toThrow()
|
}).not.toThrow()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user