Files
oh-my-opencode/src/hooks/atlas/recent-model-resolver.test.ts
T
YeonGyu-Kim d5fbada13d test: make unsafe test coercion explicit
Move test coercion out of a hidden global and require each test to import the helper so review tools and runtime scripts can see the unsafe boundary.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-12 15:51:31 +09:00

46 lines
1.4 KiB
TypeScript

import { describe, expect, mock, test } from "bun:test"
import type { PluginInput } from "@opencode-ai/plugin"
import { resolveRecentPromptContextForSession } from "./recent-model-resolver"
import { unsafeTestValue } from "../../../test-support/unsafe-test-value"
describe("resolveRecentPromptContextForSession", () => {
test("uses message time.created rather than SDK array order for recent prompt context", async () => {
// given
const ctx = unsafeTestValue<PluginInput>({
client: {
session: {
messages: mock(async () => ({
data: [
{
id: "msg_newer_in_array",
info: {
providerID: "anthropic",
modelID: "claude-sonnet-4-6",
tools: { read: true },
time: { created: 10 },
},
},
{
id: "msg_older_in_array",
info: {
providerID: "openai",
modelID: "gpt-5.4",
tools: { edit: true },
time: { created: 100 },
},
},
],
})),
},
},
})
// when
const result = await resolveRecentPromptContextForSession(ctx, "ses_123")
// then
expect(result.model).toEqual({ providerID: "openai", modelID: "gpt-5.4" })
expect(result.tools).toEqual({ edit: true })
})
})