diff --git a/packages/@n8n/utils/src/search/sublimeSearch.test.ts b/packages/@n8n/utils/src/search/sublimeSearch.test.ts index 6fee13d1aa0..f725e26e7ee 100644 --- a/packages/@n8n/utils/src/search/sublimeSearch.test.ts +++ b/packages/@n8n/utils/src/search/sublimeSearch.test.ts @@ -2,8 +2,13 @@ import topLevel from './snapshots/toplevel.snapshot.json'; import { sublimeSearch } from './sublimeSearch'; describe('sublimeSearch', () => { - describe('search finds at least one match', () => { - const testCases: Array<[string, string[]]> = [['agent', ['Magento 2', 'AI Agent']]]; + describe('search finds specific matches first', () => { + // Note that this only tests the order of the specified matches + // Further results may appear after the listed ones + const testCases: Array<[string, string[]]> = [ + ['set', ['Edit Fields (Set)']], + ['agent', ['AI Agent', 'Magento 2']], + ]; test.each(testCases)( 'should return at least "$expectedOrder" for filter "$filter"', diff --git a/packages/@n8n/utils/src/search/sublimeSearch.ts b/packages/@n8n/utils/src/search/sublimeSearch.ts index 539541a7838..5746424bec5 100644 --- a/packages/@n8n/utils/src/search/sublimeSearch.ts +++ b/packages/@n8n/utils/src/search/sublimeSearch.ts @@ -4,7 +4,7 @@ */ const SEQUENTIAL_BONUS = 60; // bonus for adjacent matches -const SEPARATOR_BONUS = 30; // bonus if match occurs after a separator +const SEPARATOR_BONUS = 38; // bonus if match occurs after a separator const CAMEL_BONUS = 30; // bonus if match is uppercase and prev is lower const FIRST_LETTER_BONUS = 15; // bonus if the first letter is matched