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>
This commit is contained in:
YeonGyu-Kim
2026-05-12 15:38:31 +09:00
parent ce5da13fc5
commit d5fbada13d
103 changed files with 700 additions and 554 deletions
@@ -5,6 +5,7 @@ import { createEventHandler } from "./event"
import { _resetForTesting, setMainSession } from "../features/claude-code-session-state"
import { createModelFallbackHook, clearPendingModelFallback } from "../hooks/model-fallback/hook"
import * as connectedProvidersCache from "../shared/connected-providers-cache"
import { unsafeTestValue } from "../../test-support/unsafe-test-value"
let readConnectedProvidersCacheSpy: { mockRestore: () => void } | undefined
let readProviderModelsCacheSpy: { mockRestore: () => void } | undefined
@@ -50,16 +51,16 @@ describe("createEventHandler - model-fallback auto-continuation pins agent/model
}
const handler = createEventHandler({
ctx: testCoerce({
ctx: unsafeTestValue({
directory: "/tmp",
client: { session: sessionClient },
}),
pluginConfig: testCoerce((args?.pluginConfig ?? {})),
pluginConfig: unsafeTestValue((args?.pluginConfig ?? {})),
firstMessageVariantGate: {
markSessionCreated: () => {},
clear: () => {},
},
managers: testCoerce({
managers: unsafeTestValue({
tmuxSessionManager: {
onSessionCreated: async () => {},
onSessionDeleted: async () => {},
@@ -68,7 +69,7 @@ describe("createEventHandler - model-fallback auto-continuation pins agent/model
disconnectSession: async () => {},
},
}),
hooks: args?.hooks ?? (testCoerce({})),
hooks: args?.hooks ?? (unsafeTestValue({})),
})
return { handler, promptAsyncBodies, promptBodies }