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:
@@ -2,10 +2,11 @@ import { describe, expect, test } from "bun:test"
|
||||
import { resolveGateway, validateGatewayUrl, normalizeReplyListenerConfig } from "../config"
|
||||
import type { OpenClawConfig } from "../types"
|
||||
import { OpenClawConfigSchema } from "../../config/schema/openclaw"
|
||||
import { unsafeTestValue } from "../../../test-support/unsafe-test-value"
|
||||
|
||||
describe("OpenClaw Config", () => {
|
||||
test("resolveGateway resolves HTTP gateway", () => {
|
||||
const config: OpenClawConfig = testCoerce({
|
||||
const config: OpenClawConfig = unsafeTestValue({
|
||||
enabled: true,
|
||||
gateways: {
|
||||
discord: {
|
||||
@@ -30,7 +31,7 @@ describe("OpenClaw Config", () => {
|
||||
})
|
||||
|
||||
test("resolveGateway returns null for disabled config", () => {
|
||||
const config: OpenClawConfig = testCoerce({
|
||||
const config: OpenClawConfig = unsafeTestValue({
|
||||
enabled: false,
|
||||
gateways: {},
|
||||
hooks: {},
|
||||
@@ -39,7 +40,7 @@ describe("OpenClaw Config", () => {
|
||||
})
|
||||
|
||||
test("resolveGateway returns null for unknown hook", () => {
|
||||
const config: OpenClawConfig = testCoerce({
|
||||
const config: OpenClawConfig = unsafeTestValue({
|
||||
enabled: true,
|
||||
gateways: {},
|
||||
hooks: {},
|
||||
@@ -48,7 +49,7 @@ describe("OpenClaw Config", () => {
|
||||
})
|
||||
|
||||
test("resolveGateway returns null for disabled hook", () => {
|
||||
const config: OpenClawConfig = testCoerce({
|
||||
const config: OpenClawConfig = unsafeTestValue({
|
||||
enabled: true,
|
||||
gateways: { g: { type: "http", url: "https://example.com" } },
|
||||
hooks: {
|
||||
|
||||
@@ -8,6 +8,7 @@ import * as injectionModule from "../reply-listener-injection"
|
||||
import * as sessionRegistryModule from "../session-registry"
|
||||
import type { ReplyListenerDaemonState } from "../reply-listener-state"
|
||||
import type { OpenClawConfig } from "../types"
|
||||
import { unsafeTestValue } from "../../../test-support/unsafe-test-value"
|
||||
|
||||
const originalFetch = globalThis.fetch
|
||||
|
||||
@@ -75,7 +76,7 @@ describe("pollDiscordReplies", () => {
|
||||
status: 401,
|
||||
}),
|
||||
))
|
||||
globalThis.fetch = testCoerce<typeof fetch>(fetchMock)
|
||||
globalThis.fetch = unsafeTestValue<typeof fetch>(fetchMock)
|
||||
|
||||
const state = createState()
|
||||
|
||||
@@ -109,7 +110,7 @@ describe("pollDiscordReplies", () => {
|
||||
),
|
||||
)
|
||||
.mockResolvedValueOnce(new Response(null, { status: 204 }))
|
||||
globalThis.fetch = testCoerce<typeof fetch>(fetchMock)
|
||||
globalThis.fetch = unsafeTestValue<typeof fetch>(fetchMock)
|
||||
const lookupSpy = spyOn(sessionRegistryModule, "lookupByMessageId").mockReturnValue({
|
||||
sessionId: "ses-1",
|
||||
tmuxSession: "session-1",
|
||||
|
||||
Reference in New Issue
Block a user