Files
claude-code-haha/desktop/src/components/chat/composerSuggestionSearch.test.ts
T
程序员阿江(Relakkes) 2d4f48765f feat(desktop): streamline composer capability discovery
Unify skill, plugin and file search across the plus and mention menus.
Prioritize common slash commands and hide withdrawn managed skill packs.
Refresh capability candidates when reopening the composer menu.
2026-09-20 01:25:45 +08:00

21 lines
1001 B
TypeScript

import { expect, it } from 'vitest'
import { rankComposerSuggestions } from '@/components/chat/composerSuggestionSearch'
it('ranks exact names, prefixes, name matches, then description matches in stable order', () => {
const items = [
{ label: 'Other', description: 'Design interfaces' },
{ label: 'My design' },
{ label: 'Design tools' },
{ label: 'Design' },
{ label: 'Design systems' },
]
expect(rankComposerSuggestions(items, 'design').map(item => item.label)).toEqual(['Design', 'Design tools', 'Design systems', 'My design', 'Other'])
})
it('matches aliases and normalized paths and limits cross-source results', () => {
const file = { label: 'index.ts', searchTerms: ['src/index.ts'] }
expect(rankComposerSuggestions([file], 'src\\index')).toEqual([file])
expect(rankComposerSuggestions(Array.from({ length: 12 }, (_, i) => ({ label: `item ${i}` })), 'item')).toHaveLength(8)
expect(rankComposerSuggestions([{ label: 'no match' }], 'absent')).toEqual([])
})