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
@@ -1,6 +1,7 @@
import { describe, test, expect } from "bun:test"
import { TmuxPollingManager } from "./polling-manager"
import type { TrackedSession } from "./types"
import { unsafeTestValue } from "../../../test-support/unsafe-test-value"
describe("TmuxPollingManager overlap", () => {
test("skips overlapping pollSessions executions", async () => {
@@ -39,15 +40,15 @@ describe("TmuxPollingManager overlap", () => {
}
const manager = new TmuxPollingManager(
testCoerce<import("../../tools/delegate-task/types").OpencodeClient>(client),
unsafeTestValue<import("../../tools/delegate-task/types").OpencodeClient>(client),
sessions,
async () => {},
)
//#when
const firstPoll = (testCoerce<{ pollSessions: () => Promise<void> }>(manager)).pollSessions()
const firstPoll = (unsafeTestValue<{ pollSessions: () => Promise<void> }>(manager)).pollSessions()
await Promise.resolve()
const secondPoll = (testCoerce<{ pollSessions: () => Promise<void> }>(manager)).pollSessions()
const secondPoll = (unsafeTestValue<{ pollSessions: () => Promise<void> }>(manager)).pollSessions()
releaseStatus?.()
await Promise.all([firstPoll, secondPoll])
@@ -85,7 +86,7 @@ describe("TmuxPollingManager overlap", () => {
}
const manager = new TmuxPollingManager(
testCoerce<import("../../tools/delegate-task/types").OpencodeClient>(client),
unsafeTestValue<import("../../tools/delegate-task/types").OpencodeClient>(client),
sessions,
async (sessionId) => {
closedSessionIds.push(sessionId)
@@ -98,7 +99,7 @@ describe("TmuxPollingManager overlap", () => {
})
//#when
const pollSessions = (testCoerce<{ pollSessions: () => Promise<void> }>(manager)).pollSessions
const pollSessions = (unsafeTestValue<{ pollSessions: () => Promise<void> }>(manager)).pollSessions
await pollSessions.call(manager)
await pollSessions.call(manager)
await pollSessions.call(manager)
@@ -132,7 +133,7 @@ describe("TmuxPollingManager overlap", () => {
}
const manager = new TmuxPollingManager(
testCoerce<import("../../tools/delegate-task/types").OpencodeClient>(client),
unsafeTestValue<import("../../tools/delegate-task/types").OpencodeClient>(client),
sessions,
async (sessionId) => {
closedSessionIds.push(sessionId)
@@ -140,7 +141,7 @@ describe("TmuxPollingManager overlap", () => {
)
// when
const pollSessions = (testCoerce<{ pollSessions: () => Promise<void> }>(manager)).pollSessions
const pollSessions = (unsafeTestValue<{ pollSessions: () => Promise<void> }>(manager)).pollSessions
await pollSessions.call(manager)
// then
@@ -171,7 +172,7 @@ describe("TmuxPollingManager overlap", () => {
}
const manager = new TmuxPollingManager(
testCoerce<import("../../tools/delegate-task/types").OpencodeClient>(client),
unsafeTestValue<import("../../tools/delegate-task/types").OpencodeClient>(client),
sessions,
async (sessionId) => {
closedSessionIds.push(sessionId)
@@ -179,7 +180,7 @@ describe("TmuxPollingManager overlap", () => {
)
// when
const pollSessions = (testCoerce<{ pollSessions: () => Promise<void> }>(manager)).pollSessions
const pollSessions = (unsafeTestValue<{ pollSessions: () => Promise<void> }>(manager)).pollSessions
await pollSessions.call(manager)
// then
@@ -222,13 +223,13 @@ describe("TmuxPollingManager overlap", () => {
}
manager = new TmuxPollingManager(
testCoerce<import("../../tools/delegate-task/types").OpencodeClient>(client),
unsafeTestValue<import("../../tools/delegate-task/types").OpencodeClient>(client),
sessions,
async (sessionId) => {
closedSessionIds.push(sessionId)
},
)
const pollSessions = (testCoerce<{ pollSessions: () => Promise<void> }>(manager)).pollSessions
const pollSessions = (unsafeTestValue<{ pollSessions: () => Promise<void> }>(manager)).pollSessions
// when
await pollSessions.call(manager)