1199e2b839
- fix(background): include "interrupt" status in all terminal status checks (3 files) - fix(background): display "INTERRUPTED" instead of "CANCELLED" for interrupted tasks - fix(cli): add error recovery grace period in poll-for-completion - fix(lsp): use JSONC parser for config loading to support comments All changes verified with tests and typecheck.
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { describe, test, expect, mock } from "bun:test"
|
|
import type { BackgroundManager } from "../../features/background-agent"
|
|
import { executeBackgroundAgent } from "./background-agent-executor"
|
|
|
|
describe("executeBackgroundAgent", () => {
|
|
const mockManager = {
|
|
launch: mock(() => Promise.resolve({
|
|
id: "test-task-id",
|
|
sessionID: null,
|
|
description: "Test task",
|
|
agent: "test-agent",
|
|
status: "pending",
|
|
})),
|
|
getTask: mock(),
|
|
} as unknown as BackgroundManager
|
|
|
|
const testContext = {
|
|
sessionID: "test-session",
|
|
messageID: "test-message",
|
|
agent: "test-agent",
|
|
abort: new AbortController().signal,
|
|
}
|
|
|
|
const testArgs = {
|
|
description: "Test background task",
|
|
prompt: "Test prompt",
|
|
subagent_type: "test-agent",
|
|
}
|
|
|
|
test("detects interrupted task as failure", async () => {
|
|
//#given
|
|
mockManager.launch.mockResolvedValueOnce({
|
|
id: "test-task-id",
|
|
sessionID: null,
|
|
description: "Test task",
|
|
agent: "test-agent",
|
|
status: "pending",
|
|
})
|
|
mockManager.getTask.mockReturnValueOnce({
|
|
id: "test-task-id",
|
|
sessionID: null,
|
|
description: "Test task",
|
|
agent: "test-agent",
|
|
status: "interrupt",
|
|
})
|
|
|
|
//#when
|
|
const result = await executeBackgroundAgent(testArgs, testContext, mockManager)
|
|
|
|
//#then
|
|
expect(result).toContain("Task failed to start")
|
|
expect(result).toContain("interrupt")
|
|
expect(result).toContain("test-task-id")
|
|
})
|
|
}) |