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
+4 -3
View File
@@ -5,6 +5,7 @@ import { join } from "node:path"
import { install } from "./install"
import * as configManager from "./config-manager"
import type { InstallArgs } from "./types"
import { unsafeTestValue } from "../../test-support/unsafe-test-value"
// Mock console methods to capture output
const mockConsoleLog = mock(() => {})
@@ -57,7 +58,7 @@ describe("install CLI - binary check behavior", () => {
getOpenCodeVersionSpy = spyOn(configManager, "getOpenCodeVersion").mockResolvedValue(null)
// given mock npm fetch
globalThis.fetch = testCoerce<typeof fetch>(mock(() =>
globalThis.fetch = unsafeTestValue<typeof fetch>(mock(() =>
Promise.resolve({
ok: true,
json: () => Promise.resolve({ latest: "3.0.0" }),
@@ -92,7 +93,7 @@ describe("install CLI - binary check behavior", () => {
getOpenCodeVersionSpy = spyOn(configManager, "getOpenCodeVersion").mockResolvedValue(null)
// given mock npm fetch
globalThis.fetch = testCoerce<typeof fetch>(mock(() =>
globalThis.fetch = unsafeTestValue<typeof fetch>(mock(() =>
Promise.resolve({
ok: true,
json: () => Promise.resolve({ latest: "3.0.0" }),
@@ -131,7 +132,7 @@ describe("install CLI - binary check behavior", () => {
getOpenCodeVersionSpy = spyOn(configManager, "getOpenCodeVersion").mockResolvedValue("1.4.0")
// given mock npm fetch
globalThis.fetch = testCoerce<typeof fetch>(mock(() =>
globalThis.fetch = unsafeTestValue<typeof fetch>(mock(() =>
Promise.resolve({
ok: true,
json: () => Promise.resolve({ latest: "3.0.0" }),