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
@@ -2,6 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test"
import { getFallbackModelsForSession } from "./fallback-models"
import { SessionCategoryRegistry } from "../../shared/session-category-registry"
import { unsafeTestValue } from "../../../test-support/unsafe-test-value"
describe("runtime-fallback fallback-models", () => {
afterEach(() => {
@@ -12,7 +13,7 @@ describe("runtime-fallback fallback-models", () => {
//#given
const sessionID = "ses_runtime_fallback_category"
SessionCategoryRegistry.register(sessionID, "quick")
const pluginConfig = testCoerce({
const pluginConfig = unsafeTestValue({
categories: {
quick: {
fallback_models: ["openai/gpt-5.2", "anthropic/claude-opus-4-7"],
@@ -29,7 +30,7 @@ describe("runtime-fallback fallback-models", () => {
test("uses agent-specific fallback_models when agent is resolved", () => {
//#given
const pluginConfig = testCoerce({
const pluginConfig = unsafeTestValue({
agents: {
oracle: {
fallback_models: ["openai/gpt-5.2", "anthropic/claude-opus-4-7"],
@@ -46,7 +47,7 @@ describe("runtime-fallback fallback-models", () => {
test("does not fall back to another agent chain when agent cannot be resolved", () => {
//#given
const pluginConfig = testCoerce({
const pluginConfig = unsafeTestValue({
agents: {
sisyphus: {
fallback_models: ["quotio/gpt-5.2", "quotio/glm-5", "quotio/kimi-k2.5"],
+2 -1
View File
@@ -2,6 +2,7 @@ import { describe, expect, test, beforeEach, afterEach, mock } from "bun:test"
import type { RuntimeFallbackConfig, OhMyOpenCodeConfig } from "../../config"
import * as loggerModule from "../../shared/logger"
import { SessionCategoryRegistry } from "../../shared/session-category-registry"
import { unsafeTestValue } from "../../../test-support/unsafe-test-value"
type RuntimeFallbackModule = typeof import("./hook")
@@ -41,7 +42,7 @@ describe("runtime-fallback", () => {
abort?: (args: unknown) => Promise<unknown>
}
}) {
return testCoerce({
return unsafeTestValue({
client: {
tui: {
showToast: async (opts: { body: { title: string; message: string; variant: string; duration: number } }) => {