@@ -129,30 +129,54 @@ describe('createUnifiedQuickPanelOpenOptions', () => {
129129 expect ( options . sortFn ! ( reversedItems , '' ) ) . toEqual ( reversedItems )
130130 } )
131131
132- it ( 'filters by filterText substring and pinyin, without loose fuzzy subsequence' , ( ) => {
133- const options = createUnifiedQuickPanelOpenOptions ( [ ] , {
134- quickPanel,
135- additionalItems : [
136- { id : 'skill:pdf' , label : 'pdf' , description : 'Read and analyze PDFs' , filterText : 'pdf' , icon : 'skill' }
132+ it ( 'filters by explicit text, search aliases, pinyin, and pinyin initials without loose fuzzy subsequence' , ( ) => {
133+ const options = createUnifiedQuickPanelOpenOptions (
134+ [
135+ {
136+ id : 'web-search' ,
137+ kind : 'command' ,
138+ label : '网络搜索' ,
139+ icon : 'search' ,
140+ sources : [ 'root-panel' ] ,
141+ searchAliases : [ 'Web Search' , 'Online Search' ]
142+ }
137143 ] ,
138- resourceItems : [ { id : 'quick-phrases' , label : '提示词管理' , icon : 'phrase' } ]
139- } )
144+ {
145+ quickPanel,
146+ additionalItems : [
147+ {
148+ id : 'skill:pdf' ,
149+ label : 'pdf' ,
150+ description : 'Read and analyze PDFs' ,
151+ filterText : 'pdf' ,
152+ icon : 'skill'
153+ }
154+ ] ,
155+ resourceItems : [ { id : 'quick-phrases' , label : '提示词管理' , icon : 'phrase' } ]
156+ }
157+ )
140158
141159 const filterFn = options . filterFn !
142160 const fuzzyRegex = / s .* l / i
143161 const pinyinCache = new WeakMap < QuickPanelListItem , string > ( )
144162 const skill = options . list . find ( ( item ) => item . label === 'pdf' ) !
145163 const quickPhrases = options . list . find ( ( item ) => item . label === '提示词管理' ) !
164+ const webSearch = options . list . find ( ( item ) => item . label === '网络搜索' ) !
146165
147- // Skill matches its name.. .
166+ // Skills keep their explicit root-panel search field and do not match descriptions .
148167 expect ( filterFn ( skill , 'pdf' , fuzzyRegex , pinyinCache ) ) . toBe ( true )
149- // ...but not its description (name-only).
150168 expect ( filterFn ( skill , 'analyze' , fuzzyRegex , pinyinCache ) ) . toBe ( false )
151169
152- // Chinese row matches by substring and pinyin substring...
170+ // Chinese row matches by substring, pinyin substring, and pinyin initial substring...
153171 expect ( filterFn ( quickPhrases , '提示词' , fuzzyRegex , pinyinCache ) ) . toBe ( true )
154172 expect ( filterFn ( quickPhrases , 'tishi' , fuzzyRegex , pinyinCache ) ) . toBe ( true )
155- // ...but not by a loose fuzzy subsequence of its pinyin (tiShiCiGuanLi).
173+ expect ( filterFn ( quickPhrases , 'tscgl' , fuzzyRegex , pinyinCache ) ) . toBe ( true )
174+
175+ // Launcher rows with filterText still match hidden English aliases and visible Chinese labels by initials.
176+ expect ( filterFn ( webSearch , 'web' , fuzzyRegex , pinyinCache ) ) . toBe ( true )
177+ expect ( filterFn ( webSearch , 'online' , fuzzyRegex , pinyinCache ) ) . toBe ( true )
178+ expect ( filterFn ( webSearch , 'wlss' , fuzzyRegex , pinyinCache ) ) . toBe ( true )
179+ // ...but not by a loose fuzzy subsequence of its pinyin or initials.
156180 expect ( filterFn ( quickPhrases , 'sl' , fuzzyRegex , pinyinCache ) ) . toBe ( false )
157181 } )
158182
0 commit comments