test(hooks): remove unsafe test assertions

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 14:22:05 +09:00
parent 11b3638493
commit 23211159c9
37 changed files with 242 additions and 232 deletions
+20 -20
View File
@@ -86,12 +86,12 @@ describe("model fallback hook", () => {
})
test("applies pending fallback on chat.message by overriding model", async () => {
const hook = modelFallback as unknown as {
const hook = testCoerce<{
"chat.message"?: (
input: { sessionID: string },
output: { message: Record<string, unknown>; parts: Array<{ type: string; text?: string }> },
) => Promise<void>
}
}>(modelFallback)
const set = setPendingModelFallback(
modelFallback,
@@ -122,12 +122,12 @@ describe("model fallback hook", () => {
})
test("preserves fallback progression across repeated session.error retries", async () => {
const hook = modelFallback as unknown as {
const hook = testCoerce<{
"chat.message"?: (
input: { sessionID: string },
output: { message: Record<string, unknown>; parts: Array<{ type: string; text?: string }> },
) => Promise<void>
}
}>(modelFallback)
const sessionID = "ses_model_fallback_main"
expect(
@@ -212,12 +212,12 @@ describe("model fallback hook", () => {
const sessionID = "ses_model_fallback_noop_skip"
clearPendingModelFallback(modelFallback, sessionID)
const hook = modelFallback as unknown as {
const hook = testCoerce<{
"chat.message"?: (
input: { sessionID: string },
output: { message: Record<string, unknown>; parts: Array<{ type: string; text?: string }> },
) => Promise<void>
}
}>(modelFallback)
setSessionFallbackChain(modelFallback, sessionID, [
{ providers: ["anthropic"], model: "claude-opus-4-7" },
@@ -254,12 +254,12 @@ describe("model fallback hook", () => {
const sessionID = "ses_model_fallback_noop_variant_skip"
clearPendingModelFallback(modelFallback, sessionID)
const hook = modelFallback as unknown as {
const hook = testCoerce<{
"chat.message"?: (
input: { sessionID: string },
output: { message: Record<string, unknown>; parts: Array<{ type: string; text?: string }> },
) => Promise<void>
}
}>(modelFallback)
setSessionFallbackChain(modelFallback, sessionID, [
{ providers: ["quotio"], model: "claude-opus-4-7", variant: "max" },
@@ -299,12 +299,12 @@ describe("model fallback hook", () => {
clearPendingModelFallback(modelFallback, sessionID)
readConnectedProvidersCacheMock.mockReturnValue(["provider-x"])
const hook = modelFallback as unknown as {
const hook = testCoerce<{
"chat.message"?: (
input: { sessionID: string },
output: { message: Record<string, unknown>; parts: Array<{ type: string; text?: string }> },
) => Promise<void>
}
}>(modelFallback)
setSessionFallbackChain(modelFallback, sessionID, [
{ providers: ["provider-y"], model: "fallback-model" },
@@ -355,16 +355,16 @@ describe("model fallback hook", () => {
test("shows toast when fallback is applied", async () => {
const toastCalls: Array<{ title: string; message: string }> = []
const hook = createModelFallbackHook({
toast: async ({ title, message }) => {
toastCalls.push({ title, message })
},
}) as unknown as {
const hook = testCoerce<{
"chat.message"?: (
input: { sessionID: string },
output: { message: Record<string, unknown>; parts: Array<{ type: string; text?: string }> },
) => Promise<void>
}
}>(createModelFallbackHook({
toast: async ({ title, message }) => {
toastCalls.push({ title, message })
},
}))
const set = setPendingModelFallback(
hook,
@@ -393,12 +393,12 @@ describe("model fallback hook", () => {
const sessionID = "ses_model_fallback_ghcp"
clearPendingModelFallback(modelFallback, sessionID)
const hook = modelFallback as unknown as {
const hook = testCoerce<{
"chat.message"?: (
input: { sessionID: string },
output: { message: Record<string, unknown>; parts: Array<{ type: string; text?: string }> },
) => Promise<void>
}
}>(modelFallback)
setSessionFallbackChain(modelFallback, sessionID, [
{ providers: ["github-copilot"], model: "claude-sonnet-4-6" },
@@ -434,12 +434,12 @@ describe("model fallback hook", () => {
const sessionID = "ses_model_fallback_google"
clearPendingModelFallback(modelFallback, sessionID)
const hook = modelFallback as unknown as {
const hook = testCoerce<{
"chat.message"?: (
input: { sessionID: string },
output: { message: Record<string, unknown>; parts: Array<{ type: string; text?: string }> },
) => Promise<void>
}
}>(modelFallback)
setSessionFallbackChain(modelFallback, sessionID, [
{ providers: ["google"], model: "gemini-3.1-pro-preview" },