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
@@ -18,7 +18,7 @@ describe("createBackgroundTask metadata", () => {
// #given
clearPendingStore()
const manager = {
const manager = testCoerce<BackgroundManager>({
launch: mock(() => Promise.resolve({
id: "task-1",
sessionID: null,
@@ -27,12 +27,12 @@ describe("createBackgroundTask metadata", () => {
status: "pending",
})),
getTask: mock(() => undefined),
} as unknown as BackgroundManager
const client = {
})
const client = testCoerce<PluginInput["client"]>({
session: {
messages: mock(() => Promise.resolve({ data: [] })),
},
} as unknown as PluginInput["client"]
})
let capturedMetadata: { title?: string; metadata?: Record<string, unknown> } | undefined
const tool = createBackgroundTask(manager, client)
@@ -21,16 +21,16 @@ describe("createBackgroundTask", () => {
}))
const getTaskMock = mock()
const mockManager = {
const mockManager = testCoerce<BackgroundManager>({
launch: launchMock,
getTask: getTaskMock,
} as unknown as BackgroundManager
})
const mockClient = {
const mockClient = testCoerce<PluginInput["client"]>({
session: {
messages: mock(() => Promise.resolve({ data: [] })),
},
} as unknown as PluginInput["client"]
})
const tool = createBackgroundTask(mockManager, mockClient)
+14 -14
View File
@@ -66,10 +66,10 @@ describe("background_output full_session", () => {
const manager = createMockManager(task)
const client = createMockClient({})
const tool = createBackgroundOutput(manager, client)
const ctxWithCallId = {
const ctxWithCallId = testCoerce<ToolContext>({
...mockContext,
callID: "call-1",
} as unknown as ToolContext
})
// #when
await tool.execute({ task_id: "task-1" }, ctxWithCallId)
@@ -93,10 +93,10 @@ describe("background_output full_session", () => {
const manager = createMockManager(task)
const client = createMockClient({})
const tool = createBackgroundOutput(manager, client)
const ctxWithCallId = {
const ctxWithCallId = testCoerce<ToolContext>({
...mockContext,
callID: "call-1",
} as unknown as ToolContext
})
// #when
await tool.execute({ task_id: "task-1" }, ctxWithCallId)
@@ -387,7 +387,7 @@ describe("background_cancel", () => {
// #given
const task = createTask({ status: "running" })
const cancelled: string[] = []
const manager = {
const manager = testCoerce<BackgroundManager>({
getTask: (id: string) => (id === task.id ? task : undefined),
getAllDescendantTasks: () => [task],
cancelTask: async (taskId: string) => {
@@ -395,7 +395,7 @@ describe("background_cancel", () => {
task.status = "cancelled"
return true
},
} as unknown as BackgroundManager
})
const client = { session: { abort: async () => ({}) } } as BackgroundCancelClient
const tool = createBackgroundCancel(manager, client)
@@ -412,7 +412,7 @@ describe("background_cancel", () => {
const taskA = createTask({ id: "task-a", status: "running" })
const taskB = createTask({ id: "task-b", status: "pending" })
const cancelled: string[] = []
const manager = {
const manager = testCoerce<BackgroundManager>({
getTask: () => undefined,
getAllDescendantTasks: () => [taskA, taskB],
cancelTask: async (taskId: string) => {
@@ -421,7 +421,7 @@ describe("background_cancel", () => {
task.status = "cancelled"
return true
},
} as unknown as BackgroundManager
})
const client = { session: { abort: async () => ({}) } } as BackgroundCancelClient
const tool = createBackgroundCancel(manager, client)
@@ -437,7 +437,7 @@ describe("background_cancel", () => {
// #given
const taskA = createTask({ id: "task-a", status: "running", sessionId: "ses-a", description: "running task" })
const taskB = createTask({ id: "task-b", status: "pending", sessionId: undefined, description: "pending task" })
const manager = {
const manager = testCoerce<BackgroundManager>({
getTask: () => undefined,
getAllDescendantTasks: () => [taskA, taskB],
cancelTask: async (taskId: string) => {
@@ -445,7 +445,7 @@ describe("background_cancel", () => {
task.status = "cancelled"
return true
},
} as unknown as BackgroundManager
})
const client = { session: { abort: async () => ({}) } } as BackgroundCancelClient
const tool = createBackgroundCancel(manager, client)
@@ -461,7 +461,7 @@ describe("background_cancel", () => {
// #given
const task = createTask({ id: "task-1", status: "running" })
const cancelOptions: Array<{ taskId: string; options: unknown }> = []
const manager = {
const manager = testCoerce<BackgroundManager>({
getTask: (id: string) => (id === task.id ? task : undefined),
getAllDescendantTasks: () => [task],
cancelTask: async (taskId: string, options?: unknown) => {
@@ -469,7 +469,7 @@ describe("background_cancel", () => {
task.status = "cancelled"
return true
},
} as unknown as BackgroundManager
})
const client = { session: { abort: async () => ({}) } } as BackgroundCancelClient
const tool = createBackgroundCancel(manager, client)
@@ -487,7 +487,7 @@ describe("background_cancel", () => {
// #given
const task = createTask({ id: "task-1", status: "running" })
const cancelOptions: Array<{ taskId: string; options: unknown }> = []
const manager = {
const manager = testCoerce<BackgroundManager>({
getTask: (id: string) => (id === task.id ? task : undefined),
getAllDescendantTasks: () => [task],
cancelTask: async (taskId: string, options?: unknown) => {
@@ -495,7 +495,7 @@ describe("background_cancel", () => {
task.status = "cancelled"
return true
},
} as unknown as BackgroundManager
})
const client = { session: { abort: async () => ({}) } } as BackgroundCancelClient
const tool = createBackgroundCancel(manager, client)