2026-02-10 17:19:06 +09:00
|
|
|
declare const require: (name: string) => any
|
|
|
|
|
const { describe, test, expect, beforeEach, afterEach, spyOn, mock } = require("bun:test")
|
2026-02-10 13:25:49 +09:00
|
|
|
import { resolveCategoryExecution } from "./category-resolver"
|
|
|
|
|
import type { ExecutorContext } from "./executor-types"
|
2026-02-10 17:19:06 +09:00
|
|
|
import * as connectedProvidersCache from "../../shared/connected-providers-cache"
|
2026-02-10 13:25:49 +09:00
|
|
|
|
|
|
|
|
describe("resolveCategoryExecution", () => {
|
2026-02-10 17:19:06 +09:00
|
|
|
let connectedProvidersSpy: ReturnType<typeof spyOn> | undefined
|
|
|
|
|
let providerModelsSpy: ReturnType<typeof spyOn> | undefined
|
|
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
mock.restore()
|
|
|
|
|
connectedProvidersSpy = spyOn(connectedProvidersCache, "readConnectedProvidersCache").mockReturnValue(null)
|
|
|
|
|
providerModelsSpy = spyOn(connectedProvidersCache, "readProviderModelsCache").mockReturnValue(null)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
connectedProvidersSpy?.mockRestore()
|
|
|
|
|
providerModelsSpy?.mockRestore()
|
|
|
|
|
})
|
|
|
|
|
|
2026-02-10 13:25:49 +09:00
|
|
|
const createMockExecutorContext = (): ExecutorContext => ({
|
|
|
|
|
client: {} as any,
|
|
|
|
|
manager: {} as any,
|
|
|
|
|
directory: "/tmp/test",
|
|
|
|
|
userCategories: {},
|
|
|
|
|
sisyphusJuniorModel: undefined,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test("returns clear error when category exists but required model is not available", async () => {
|
|
|
|
|
//#given
|
|
|
|
|
const args = {
|
|
|
|
|
category: "deep",
|
|
|
|
|
prompt: "test prompt",
|
|
|
|
|
description: "Test task",
|
|
|
|
|
run_in_background: false,
|
|
|
|
|
load_skills: [],
|
|
|
|
|
blockedBy: undefined,
|
|
|
|
|
enableSkillTools: false,
|
|
|
|
|
}
|
|
|
|
|
const executorCtx = createMockExecutorContext()
|
|
|
|
|
const inheritedModel = undefined
|
2026-02-18 15:51:24 +09:00
|
|
|
const systemDefaultModel = "anthropic/claude-sonnet-4-6"
|
2026-02-10 13:25:49 +09:00
|
|
|
|
|
|
|
|
//#when
|
|
|
|
|
const result = await resolveCategoryExecution(args, executorCtx, inheritedModel, systemDefaultModel)
|
|
|
|
|
|
|
|
|
|
//#then
|
|
|
|
|
expect(result.error).toBeDefined()
|
|
|
|
|
expect(result.error).toContain("deep")
|
|
|
|
|
expect(result.error).toMatch(/model.*not.*available|requires.*model/i)
|
|
|
|
|
expect(result.error).not.toContain("Unknown category")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test("returns 'unknown category' error for truly unknown categories", async () => {
|
|
|
|
|
//#given
|
|
|
|
|
const args = {
|
|
|
|
|
category: "definitely-not-a-real-category-xyz123",
|
|
|
|
|
prompt: "test prompt",
|
|
|
|
|
description: "Test task",
|
|
|
|
|
run_in_background: false,
|
|
|
|
|
load_skills: [],
|
|
|
|
|
blockedBy: undefined,
|
|
|
|
|
enableSkillTools: false,
|
|
|
|
|
}
|
|
|
|
|
const executorCtx = createMockExecutorContext()
|
|
|
|
|
const inheritedModel = undefined
|
2026-02-18 15:51:24 +09:00
|
|
|
const systemDefaultModel = "anthropic/claude-sonnet-4-6"
|
2026-02-10 13:25:49 +09:00
|
|
|
|
|
|
|
|
//#when
|
|
|
|
|
const result = await resolveCategoryExecution(args, executorCtx, inheritedModel, systemDefaultModel)
|
|
|
|
|
|
|
|
|
|
//#then
|
|
|
|
|
expect(result.error).toBeDefined()
|
|
|
|
|
expect(result.error).toContain("Unknown category")
|
|
|
|
|
expect(result.error).toContain("definitely-not-a-real-category-xyz123")
|
|
|
|
|
})
|
|
|
|
|
})
|