test(tools): 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:23:05 +09:00
parent 8b093a1115
commit fb135d047c
24 changed files with 199 additions and 156 deletions
@@ -32,8 +32,8 @@ describe("resolveMultimodalLookerAgentMetadata", () => {
afterEach(() => {
clearVisionCapableModelsCache()
;(modelAvailability.fetchAvailableModels as unknown as { mockRestore?: () => void }).mockRestore?.()
;(connectedProvidersCache.readConnectedProvidersCache as unknown as { mockRestore?: () => void }).mockRestore?.()
;(testCoerce<{ mockRestore?: () => void }>(modelAvailability.fetchAvailableModels)).mockRestore?.()
;(testCoerce<{ mockRestore?: () => void }>(connectedProvidersCache.readConnectedProvidersCache)).mockRestore?.()
})
test("returns configured multimodal-looker model when it already matches a vision-capable override", async () => {
+6 -6
View File
@@ -30,7 +30,7 @@ describe("pollSessionUntilIdle", () => {
{ data: { ses_test: { type: "idle" } } },
])
await pollSessionUntilIdle(client as any, "ses_test", { pollIntervalMs: 10, timeoutMs: 5000 })
await pollSessionUntilIdle(testCoerce(client), "ses_test", { pollIntervalMs: 10, timeoutMs: 5000 })
expect(client.session.status).toHaveBeenCalledTimes(3)
})
@@ -43,7 +43,7 @@ describe("pollSessionUntilIdle", () => {
{ data: {} },
])
await pollSessionUntilIdle(client as any, "ses_test", { pollIntervalMs: 10, timeoutMs: 5000 })
await pollSessionUntilIdle(testCoerce(client), "ses_test", { pollIntervalMs: 10, timeoutMs: 5000 })
expect(client.session.status).toHaveBeenCalledTimes(1)
})
@@ -57,7 +57,7 @@ describe("pollSessionUntilIdle", () => {
])
await expect(
pollSessionUntilIdle(client as any, "ses_test", { pollIntervalMs: 10, timeoutMs: 50 })
pollSessionUntilIdle(testCoerce(client), "ses_test", { pollIntervalMs: 10, timeoutMs: 50 })
).rejects.toThrow("timed out")
})
@@ -69,7 +69,7 @@ describe("pollSessionUntilIdle", () => {
{ error: new Error("API error") },
])
await pollSessionUntilIdle(client as any, "ses_test", { pollIntervalMs: 10, timeoutMs: 5000 })
await pollSessionUntilIdle(testCoerce(client), "ses_test", { pollIntervalMs: 10, timeoutMs: 5000 })
expect(client.session.status).toHaveBeenCalledTimes(1)
})
@@ -85,7 +85,7 @@ describe("pollSessionUntilIdle", () => {
{ data: {} },
])
await pollSessionUntilIdle(client as any, "ses_test", { pollIntervalMs: 10, timeoutMs: 5000 })
await pollSessionUntilIdle(testCoerce(client), "ses_test", { pollIntervalMs: 10, timeoutMs: 5000 })
expect(client.session.status).toHaveBeenCalledTimes(4)
})
@@ -98,7 +98,7 @@ describe("pollSessionUntilIdle", () => {
{ data: {} },
])
await pollSessionUntilIdle(client as any, "ses_test")
await pollSessionUntilIdle(testCoerce(client), "ses_test")
expect(client.session.status).toHaveBeenCalledTimes(1)
})
+35 -35
View File
@@ -14,7 +14,7 @@ describe("look-at tool", () => {
// then should normalize to file_path
test("normalizes path to file_path for LLM compatibility", () => {
const args = { path: "/some/file.png", goal: "analyze" }
const normalized = normalizeArgs(args as any)
const normalized = normalizeArgs(testCoerce(args))
expect(normalized.file_path).toBe("/some/file.png")
expect(normalized.goal).toBe("analyze")
})
@@ -33,7 +33,7 @@ describe("look-at tool", () => {
// then prefer file_path
test("prefers file_path over path when both provided", () => {
const args = { file_path: "/preferred.png", path: "/fallback.png", goal: "test" }
const normalized = normalizeArgs(args as any)
const normalized = normalizeArgs(testCoerce(args))
expect(normalized.file_path).toBe("/preferred.png")
})
@@ -42,7 +42,7 @@ describe("look-at tool", () => {
// then preserve image_data in normalized args
test("preserves image_data when provided", () => {
const args = { image_data: "data:image/png;base64,iVBORw0KGgo=", goal: "analyze" }
const normalized = normalizeArgs(args as any)
const normalized = normalizeArgs(testCoerce(args))
expect(normalized.image_data).toBe("data:image/png;base64,iVBORw0KGgo=")
expect(normalized.file_path).toBeUndefined()
})
@@ -69,7 +69,7 @@ describe("look-at tool", () => {
// when validated
// then clear error message
test("returns error when neither file_path nor image_data provided", () => {
const args = { goal: "analyze" } as any
const args = testCoerce({ goal: "analyze" })
const error = validateArgs(args)
expect(error).toContain("file_path")
expect(error).toContain("image_data")
@@ -88,7 +88,7 @@ describe("look-at tool", () => {
// when validated
// then clear error message
test("returns error when goal is missing", () => {
const args = { file_path: "/some/path.png" } as any
const args = testCoerce({ file_path: "/some/path.png" })
const error = validateArgs(args)
expect(error).toContain("goal")
expect(error).toContain("required")
@@ -156,10 +156,10 @@ describe("look-at tool", () => {
},
}
const tool = createLookAt({
const tool = createLookAt(testCoerce({
client: mockClient,
directory: "/project",
} as any)
}))
const toolContext: ToolContext = {
sessionID: "parent-session",
@@ -193,10 +193,10 @@ describe("look-at tool", () => {
},
}
const tool = createLookAt({
const tool = createLookAt(testCoerce({
client: mockClient,
directory: "/project",
} as any)
}))
const toolContext: ToolContext = {
sessionID: "parent-session",
@@ -230,10 +230,10 @@ describe("look-at tool", () => {
},
}
const tool = createLookAt({
const tool = createLookAt(testCoerce({
client: mockClient,
directory: "/project",
} as any)
}))
const toolContext: ToolContext = {
sessionID: "parent-session",
@@ -291,10 +291,10 @@ describe("look-at tool", () => {
},
}
const tool = createLookAt({
const tool = createLookAt(testCoerce({
client: mockClient,
directory: "/project",
} as any)
}))
const toolContext: ToolContext = {
sessionID: "parent-session",
@@ -346,10 +346,10 @@ describe("look-at tool", () => {
},
}
const tool = createLookAt({
const tool = createLookAt(testCoerce({
client: mockClient,
directory: "/project",
} as any)
}))
const toolContext: ToolContext = {
sessionID: "parent-session",
@@ -395,10 +395,10 @@ describe("look-at tool", () => {
},
}
const tool = createLookAt({
const tool = createLookAt(testCoerce({
client: mockClient,
directory: "/project",
} as any)
}))
const toolContext: ToolContext = {
sessionID: "parent-session",
@@ -437,10 +437,10 @@ describe("look-at tool", () => {
},
}
const tool = createLookAt({
const tool = createLookAt(testCoerce({
client: mockClient,
directory: "/project",
} as any)
}))
const toolContext: ToolContext = {
sessionID: "parent-session",
@@ -486,10 +486,10 @@ describe("look-at tool", () => {
},
}
const tool = createLookAt({
const tool = createLookAt(testCoerce({
client: mockClient,
directory: "/project",
} as any)
}))
const result = await tool.execute(
{ file_path: "/test/file.png", goal: "analyze" },
@@ -515,10 +515,10 @@ describe("look-at tool", () => {
},
}
const tool = createLookAt({
const tool = createLookAt(testCoerce({
client: mockClient,
directory: "/project",
} as any)
}))
const result = await tool.execute(
{ file_path: "/test/file.png", goal: "analyze" },
@@ -539,10 +539,10 @@ describe("look-at tool", () => {
},
}
const tool = createLookAt({
const tool = createLookAt(testCoerce({
client: mockClient,
directory: "/project",
} as any)
}))
const result = await tool.execute(
{ file_path: "/test/file.png", goal: "analyze" },
@@ -579,10 +579,10 @@ describe("look-at tool", () => {
},
}
const tool = createLookAt({
const tool = createLookAt(testCoerce({
client: mockClient,
directory: "/project",
} as any)
}))
const toolContext: ToolContext = {
sessionID: "parent-session",
@@ -632,10 +632,10 @@ describe("look-at tool", () => {
},
}
const tool = createLookAt({
const tool = createLookAt(testCoerce({
client: mockClient,
directory: "/project",
} as any)
}))
const toolContext: ToolContext = {
sessionID: "parent-session",
@@ -701,10 +701,10 @@ describe("look-at tool", () => {
test("instructs agent to analyze attached file when Read is disabled (file_path mode)", async () => {
const { mockClient, captured } = captureLastPromptBody()
const tool = createLookAt({
const tool = createLookAt(testCoerce({
client: mockClient,
directory: "/project",
} as any)
}))
await tool.execute(
{ file_path: "/test/file.png", goal: "describe contents" },
@@ -726,10 +726,10 @@ describe("look-at tool", () => {
test("instructs agent to analyze attached image when image_data is provided", async () => {
const { mockClient, captured } = captureLastPromptBody()
const tool = createLookAt({
const tool = createLookAt(testCoerce({
client: mockClient,
directory: "/project",
} as any)
}))
await tool.execute(
{ image_data: "data:image/png;base64,iVBORw0KGgo=", goal: "describe image" },
@@ -751,10 +751,10 @@ describe("look-at tool", () => {
test("explicitly warns the agent not to attempt Read when Read is disabled", async () => {
const { mockClient, captured } = captureLastPromptBody()
const tool = createLookAt({
const tool = createLookAt(testCoerce({
client: mockClient,
directory: "/project",
} as any)
}))
await tool.execute(
{ file_path: "/test/file.pdf", goal: "extract text" },