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:
@@ -5,6 +5,7 @@ import { executeCompact } from "./executor"
|
||||
import type { AutoCompactState } from "./types"
|
||||
import * as recoveryStrategy from "./recovery-strategy"
|
||||
import * as messagesReader from "../session-recovery/storage/messages-reader"
|
||||
import { unsafeTestValue } from "../../../test-support/unsafe-test-value"
|
||||
|
||||
type TimerCallback = (...args: any[]) => void
|
||||
|
||||
@@ -37,7 +38,7 @@ function createFakeTimeouts(): FakeTimeouts {
|
||||
callback,
|
||||
args,
|
||||
})
|
||||
return testCoerce<ReturnType<typeof setTimeout>>(id)
|
||||
return unsafeTestValue<ReturnType<typeof setTimeout>>(id)
|
||||
}) as typeof setTimeout
|
||||
|
||||
globalThis.clearTimeout = ((id?: number) => {
|
||||
@@ -243,7 +244,7 @@ describe("executeCompact lock management", () => {
|
||||
await executeCompact(sessionID, msg, autoCompactState, mockClient, directory, pluginConfig)
|
||||
|
||||
// then: Toast should be shown
|
||||
const toastCalls = (testCoerce(mockClient.tui.showToast)).mock.calls
|
||||
const toastCalls = (unsafeTestValue(mockClient.tui.showToast)).mock.calls
|
||||
const blockedToast = toastCalls.find(
|
||||
(call: any) => call[0]?.body?.title === "Compact In Progress",
|
||||
)
|
||||
@@ -276,7 +277,7 @@ describe("executeCompact lock management", () => {
|
||||
await executeCompact(sessionID, msg, autoCompactState, mockClient, directory, pluginConfig)
|
||||
|
||||
// then: Should show failure toast
|
||||
const toastCalls = (testCoerce(mockClient.tui.showToast)).mock.calls
|
||||
const toastCalls = (unsafeTestValue(mockClient.tui.showToast)).mock.calls
|
||||
const failureToast = toastCalls.find(
|
||||
(call: any) => call[0]?.body?.title === "Auto Compact Failed",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user