test(call-omo-agent): align background task fixtures with normalized field names
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -7,13 +7,13 @@ import { executeBackgroundAgent } from "./background-agent-executor"
|
||||
describe("executeBackgroundAgent", () => {
|
||||
const launchMock = mock(async (): Promise<{
|
||||
id: string
|
||||
sessionID: string | null
|
||||
sessionId: string | null
|
||||
description: string
|
||||
agent: string
|
||||
status: string
|
||||
}> => ({
|
||||
id: "test-task-id",
|
||||
sessionID: null,
|
||||
sessionId: null,
|
||||
description: "Test task",
|
||||
agent: "test-agent",
|
||||
status: "pending",
|
||||
@@ -23,7 +23,7 @@ describe("executeBackgroundAgent", () => {
|
||||
const mockManager = {
|
||||
launch: launchMock,
|
||||
getTask: getTaskMock,
|
||||
} as unknown as BackgroundManager
|
||||
} as BackgroundManager
|
||||
|
||||
const testContext = {
|
||||
sessionID: "test-session",
|
||||
@@ -43,20 +43,20 @@ describe("executeBackgroundAgent", () => {
|
||||
session: {
|
||||
messages: mock(() => Promise.resolve({ data: [] })),
|
||||
},
|
||||
} as unknown as PluginInput["client"]
|
||||
} as PluginInput["client"]
|
||||
|
||||
test("detects interrupted task as failure", async () => {
|
||||
//#given
|
||||
launchMock.mockResolvedValueOnce({
|
||||
id: "test-task-id",
|
||||
sessionID: null,
|
||||
sessionId: null,
|
||||
description: "Test task",
|
||||
agent: "test-agent",
|
||||
status: "pending",
|
||||
})
|
||||
getTaskMock.mockReturnValueOnce({
|
||||
id: "test-task-id",
|
||||
sessionID: null,
|
||||
sessionId: null,
|
||||
description: "Test task",
|
||||
agent: "test-agent",
|
||||
status: "interrupt",
|
||||
@@ -76,14 +76,14 @@ describe("executeBackgroundAgent", () => {
|
||||
const abortController = new AbortController()
|
||||
launchMock.mockResolvedValueOnce({
|
||||
id: "test-task-id",
|
||||
sessionID: null,
|
||||
sessionId: null,
|
||||
description: "Test task",
|
||||
agent: "test-agent",
|
||||
status: "pending",
|
||||
})
|
||||
getTaskMock.mockImplementationOnce(() => {
|
||||
abortController.abort()
|
||||
return { id: "test-task-id", sessionID: null, description: "Test task", agent: "test-agent", status: "pending" }
|
||||
return { id: "test-task-id", sessionId: null, description: "Test task", agent: "test-agent", status: "pending" }
|
||||
})
|
||||
|
||||
//#when
|
||||
@@ -108,15 +108,15 @@ describe("executeBackgroundAgent", () => {
|
||||
const firstAbortController = new AbortController()
|
||||
const secondAbortController = new AbortController()
|
||||
const states = new Map([
|
||||
["task-1", { reads: 0, abortOnFirstRead: true, sessionID: "ses-1" }],
|
||||
["task-2", { reads: 0, abortOnFirstRead: false, sessionID: "ses-2" }],
|
||||
["task-1", { reads: 0, abortOnFirstRead: true, sessionId: "ses-1" }],
|
||||
["task-2", { reads: 0, abortOnFirstRead: false, sessionId: "ses-2" }],
|
||||
])
|
||||
let launchCount = 0
|
||||
launchMock.mockImplementation(async () => {
|
||||
launchCount += 1
|
||||
return launchCount === 1
|
||||
? { id: "task-1", sessionID: null, description: "Task 1", agent: "test-agent", status: "pending" }
|
||||
: { id: "task-2", sessionID: null, description: "Task 2", agent: "test-agent", status: "pending" }
|
||||
? { id: "task-1", sessionId: null, description: "Task 1", agent: "test-agent", status: "pending" }
|
||||
: { id: "task-2", sessionId: null, description: "Task 2", agent: "test-agent", status: "pending" }
|
||||
})
|
||||
getTaskMock.mockImplementation((taskID: string) => {
|
||||
const state = states.get(taskID)
|
||||
@@ -126,8 +126,8 @@ describe("executeBackgroundAgent", () => {
|
||||
firstAbortController.abort()
|
||||
}
|
||||
return state.reads >= 2
|
||||
? { id: taskID, sessionID: state.sessionID, description: "Task", agent: "test-agent", status: "pending" }
|
||||
: { id: taskID, sessionID: null, description: "Task", agent: "test-agent", status: "pending" }
|
||||
? { id: taskID, sessionId: state.sessionId, description: "Task", agent: "test-agent", status: "pending" }
|
||||
: { id: taskID, sessionId: null, description: "Task", agent: "test-agent", status: "pending" }
|
||||
})
|
||||
|
||||
//#when
|
||||
|
||||
@@ -7,13 +7,13 @@ import { executeBackground } from "./background-executor"
|
||||
describe("executeBackground", () => {
|
||||
const launchMock = mock(async (_input?: { fallbackChain?: unknown }): Promise<{
|
||||
id: string
|
||||
sessionID: string | null
|
||||
sessionId: string | null
|
||||
description: string
|
||||
agent: string
|
||||
status: string
|
||||
}> => ({
|
||||
id: "test-task-id",
|
||||
sessionID: null,
|
||||
sessionId: null,
|
||||
description: "Test task",
|
||||
agent: "test-agent",
|
||||
status: "pending",
|
||||
@@ -23,7 +23,7 @@ describe("executeBackground", () => {
|
||||
const mockManager = {
|
||||
launch: launchMock,
|
||||
getTask: getTaskMock,
|
||||
} as unknown as BackgroundManager
|
||||
} as BackgroundManager
|
||||
|
||||
const testContext = {
|
||||
sessionID: "test-session",
|
||||
@@ -43,20 +43,20 @@ describe("executeBackground", () => {
|
||||
session: {
|
||||
messages: mock(() => Promise.resolve({ data: [] })),
|
||||
},
|
||||
} as unknown as PluginInput["client"]
|
||||
} as PluginInput["client"]
|
||||
|
||||
test("detects interrupted task as failure", async () => {
|
||||
//#given
|
||||
launchMock.mockResolvedValueOnce({
|
||||
id: "test-task-id",
|
||||
sessionID: null,
|
||||
sessionId: null,
|
||||
description: "Test task",
|
||||
agent: "test-agent",
|
||||
status: "pending",
|
||||
})
|
||||
getTaskMock.mockReturnValueOnce({
|
||||
id: "test-task-id",
|
||||
sessionID: null,
|
||||
sessionId: null,
|
||||
description: "Test task",
|
||||
agent: "test-agent",
|
||||
status: "interrupt",
|
||||
@@ -79,7 +79,7 @@ describe("executeBackground", () => {
|
||||
]
|
||||
launchMock.mockResolvedValueOnce({
|
||||
id: "test-task-id",
|
||||
sessionID: "sub-session",
|
||||
sessionId: "sub-session",
|
||||
description: "Test task",
|
||||
agent: "test-agent",
|
||||
status: "pending",
|
||||
@@ -105,14 +105,14 @@ describe("executeBackground", () => {
|
||||
const abortController = new AbortController()
|
||||
launchMock.mockResolvedValueOnce({
|
||||
id: "test-task-id",
|
||||
sessionID: null,
|
||||
sessionId: null,
|
||||
description: "Test task",
|
||||
agent: "test-agent",
|
||||
status: "pending",
|
||||
})
|
||||
getTaskMock.mockImplementationOnce(() => {
|
||||
abortController.abort()
|
||||
return { id: "test-task-id", sessionID: null, description: "Test task", agent: "test-agent", status: "pending" }
|
||||
return { id: "test-task-id", sessionId: null, description: "Test task", agent: "test-agent", status: "pending" }
|
||||
})
|
||||
|
||||
//#when
|
||||
@@ -137,15 +137,15 @@ describe("executeBackground", () => {
|
||||
const firstAbortController = new AbortController()
|
||||
const secondAbortController = new AbortController()
|
||||
const states = new Map([
|
||||
["task-1", { reads: 0, abortOnFirstRead: true, sessionID: "ses-1" }],
|
||||
["task-2", { reads: 0, abortOnFirstRead: false, sessionID: "ses-2" }],
|
||||
["task-1", { reads: 0, abortOnFirstRead: true, sessionId: "ses-1" }],
|
||||
["task-2", { reads: 0, abortOnFirstRead: false, sessionId: "ses-2" }],
|
||||
])
|
||||
let launchCount = 0
|
||||
launchMock.mockImplementation(async () => {
|
||||
launchCount += 1
|
||||
return launchCount === 1
|
||||
? { id: "task-1", sessionID: null, description: "Task 1", agent: "test-agent", status: "pending" }
|
||||
: { id: "task-2", sessionID: null, description: "Task 2", agent: "test-agent", status: "pending" }
|
||||
? { id: "task-1", sessionId: null, description: "Task 1", agent: "test-agent", status: "pending" }
|
||||
: { id: "task-2", sessionId: null, description: "Task 2", agent: "test-agent", status: "pending" }
|
||||
})
|
||||
getTaskMock.mockImplementation((taskID: string) => {
|
||||
const state = states.get(taskID)
|
||||
@@ -155,8 +155,8 @@ describe("executeBackground", () => {
|
||||
firstAbortController.abort()
|
||||
}
|
||||
return state.reads >= 2
|
||||
? { id: taskID, sessionID: state.sessionID, description: "Task", agent: "test-agent", status: "pending" }
|
||||
: { id: taskID, sessionID: null, description: "Task", agent: "test-agent", status: "pending" }
|
||||
? { id: taskID, sessionId: state.sessionId, description: "Task", agent: "test-agent", status: "pending" }
|
||||
: { id: taskID, sessionId: null, description: "Task", agent: "test-agent", status: "pending" }
|
||||
})
|
||||
|
||||
//#when
|
||||
|
||||
@@ -21,7 +21,7 @@ function createMockCtx(agents: Array<{ name: string; mode?: string }> = []): Plu
|
||||
},
|
||||
},
|
||||
directory: "/test",
|
||||
} as unknown as PluginInput
|
||||
}
|
||||
}
|
||||
|
||||
const DEFAULT_AGENTS = [
|
||||
@@ -103,12 +103,12 @@ describe("createCallOmoAgent edge cases", () => {
|
||||
reserveSubagentSpawn: reserveSubagentSpawnMock,
|
||||
launch: mock(() => Promise.resolve({
|
||||
id: "task-id",
|
||||
sessionID: "ses-1",
|
||||
sessionId: "ses-1",
|
||||
description: "Test",
|
||||
agent: "bug-fixer",
|
||||
status: "pending",
|
||||
})),
|
||||
getTask: mock(() => ({ status: "pending", sessionID: "ses-1" })),
|
||||
getTask: mock(() => ({ status: "pending", sessionId: "ses-1" })),
|
||||
}
|
||||
const toolDef = createCallOmoAgent(mockCtx, mockManager, [])
|
||||
const executeFunc = toolDef.execute as Function
|
||||
@@ -139,12 +139,12 @@ describe("createCallOmoAgent edge cases", () => {
|
||||
reserveSubagentSpawn: reserveSubagentSpawnMock,
|
||||
launch: mock(() => Promise.resolve({
|
||||
id: "task-id",
|
||||
sessionID: "ses-1",
|
||||
sessionId: "ses-1",
|
||||
description: "Test",
|
||||
agent: "explore",
|
||||
status: "pending",
|
||||
})),
|
||||
getTask: mock(() => ({ status: "pending", sessionID: "ses-1" })),
|
||||
getTask: mock(() => ({ status: "pending", sessionId: "ses-1" })),
|
||||
}
|
||||
const toolDef = createCallOmoAgent(mockCtx, mockManager, [])
|
||||
const executeFunc = toolDef.execute as Function
|
||||
|
||||
@@ -18,7 +18,7 @@ function createMockCtx(agents: Array<{ name: string; mode?: string }> = []): Plu
|
||||
},
|
||||
},
|
||||
directory: "/test",
|
||||
} as unknown as PluginInput
|
||||
}
|
||||
}
|
||||
|
||||
function createFailingMockCtx(error: Error = new Error("API unavailable")): PluginInput {
|
||||
@@ -29,7 +29,7 @@ function createFailingMockCtx(error: Error = new Error("API unavailable")): Plug
|
||||
},
|
||||
},
|
||||
directory: "/test",
|
||||
} as unknown as PluginInput
|
||||
}
|
||||
}
|
||||
|
||||
const DEFAULT_AGENTS = [
|
||||
@@ -57,13 +57,13 @@ const mockBackgroundManager = {
|
||||
reserveSubagentSpawn: reserveSubagentSpawnMock,
|
||||
launch: mock(() => Promise.resolve({
|
||||
id: "test-task-id",
|
||||
sessionID: null,
|
||||
sessionId: null,
|
||||
description: "Test task",
|
||||
agent: "test-agent",
|
||||
status: "pending",
|
||||
})),
|
||||
getTask: mock(() => ({ status: "pending", sessionID: "ses-123" })),
|
||||
} as unknown as BackgroundManager
|
||||
getTask: mock(() => ({ status: "pending", sessionId: "ses-123" })),
|
||||
} as BackgroundManager
|
||||
|
||||
const toolCtx = {
|
||||
sessionID: "test",
|
||||
@@ -240,7 +240,7 @@ describe("createCallOmoAgent", () => {
|
||||
//#given
|
||||
const launch = mock((_input: { fallbackChain?: Array<{ providers: string[]; model: string; variant?: string }> }) => Promise.resolve({
|
||||
id: "task-fallback",
|
||||
sessionID: "sub-session",
|
||||
sessionId: "sub-session",
|
||||
description: "Test task",
|
||||
agent: "explore",
|
||||
status: "pending",
|
||||
@@ -290,7 +290,7 @@ describe("createCallOmoAgent", () => {
|
||||
//#given
|
||||
const launch = mock((_input: { model?: { providerID: string; modelID: string }; fallbackChain?: unknown[] }) => Promise.resolve({
|
||||
id: "task-model",
|
||||
sessionID: "sub-session",
|
||||
sessionId: "sub-session",
|
||||
description: "Test task",
|
||||
agent: "explore",
|
||||
status: "pending",
|
||||
@@ -339,7 +339,7 @@ describe("createCallOmoAgent", () => {
|
||||
//#given
|
||||
const launch = mock((_input: { model?: { providerID: string; modelID: string; variant?: string } }) => Promise.resolve({
|
||||
id: "task-variant",
|
||||
sessionID: "sub-session",
|
||||
sessionId: "sub-session",
|
||||
description: "Test task",
|
||||
agent: "explore",
|
||||
status: "pending",
|
||||
@@ -390,7 +390,7 @@ describe("createCallOmoAgent", () => {
|
||||
//#given
|
||||
const launch = mock((_input: { model?: { providerID: string; modelID: string; variant?: string } }) => Promise.resolve({
|
||||
id: "task-inline-variant",
|
||||
sessionID: "sub-session",
|
||||
sessionId: "sub-session",
|
||||
description: "Test task",
|
||||
agent: "explore",
|
||||
status: "pending",
|
||||
@@ -440,7 +440,7 @@ describe("createCallOmoAgent", () => {
|
||||
//#given
|
||||
const launch = mock((_input: { model?: { providerID: string; modelID: string } }) => Promise.resolve({
|
||||
id: "task-category-model",
|
||||
sessionID: "sub-session",
|
||||
sessionId: "sub-session",
|
||||
description: "Test task",
|
||||
agent: "explore",
|
||||
status: "pending",
|
||||
|
||||
Reference in New Issue
Block a user