skillhub/cli/test/unit/agents/resolver-interactive.test.ts
SenLinLeo b44c65443d fix(cli): treat highlighted install target as selected
Signed-off-by: SenLinLeo <1664761477@qq.com>
2026-06-16 16:30:30 +08:00

36 lines
1.1 KiB
TypeScript

import { describe, expect, mock, test } from 'bun:test'
import type { AgentCandidate } from '../../../src/agents/types'
interface PromptOptions {
onRender?: (this: { cursor?: number }) => void
format?: (selectedTargets: AgentCandidate[]) => AgentCandidate[]
}
mock.module('prompts', () => ({
default: (options: PromptOptions) => {
options.onRender?.call({ cursor: 1 })
return { selected: options.format?.([]) ?? [] }
}
}))
const { resolveInstallTargets } = await import('../../../src/agents/resolver')
describe('resolveInstallTargets interactive prompt', () => {
test('uses the highlighted target when Enter submits an empty multiselect', async () => {
const detected: AgentCandidate[] = [
{ agent: 'codex', rootDir: '/repo/.codex/skills', scope: 'project', source: 'detected' },
{ agent: 'claude-code', rootDir: '/repo/.claude/skills', scope: 'project', source: 'detected' }
]
const highlighted = detected[1]!
const targets = await resolveInstallTargets({
cwd: '/repo',
agents: [],
json: false,
interactive: true,
detected
})
expect(targets).toEqual([highlighted])
})
})