diff --git a/x-pack/plugins/fleet/public/search_provider.test.ts b/x-pack/plugins/fleet/public/search_provider.test.ts index c42ac2e5a1551..f2bdec6362ccd 100644 --- a/x-pack/plugins/fleet/public/search_provider.test.ts +++ b/x-pack/plugins/fleet/public/search_provider.test.ts @@ -164,18 +164,18 @@ describe('Package search provider', () => { const packageSearchProvider = createPackageSearchProvider(setupMock); expectObservable( packageSearchProvider.find( - { term: 'test' }, + { term: 'test1' }, { aborted$: NEVER, maxResults: 1, preference: '' } ) ).toBe('--(a|)', { a: [ { - id: 'test-test', + id: 'test1-test1', score: 80, - title: 'test', + title: 'test1', type: 'package', url: { - path: 'undefined#/detail/test-test/overview', + path: 'undefined#/detail/test1-test1/overview', prependBasePath: false, }, }, diff --git a/x-pack/plugins/fleet/public/search_provider.ts b/x-pack/plugins/fleet/public/search_provider.ts index 56e08ecad29fb..4fcc9754aa625 100644 --- a/x-pack/plugins/fleet/public/search_provider.ts +++ b/x-pack/plugins/fleet/public/search_provider.ts @@ -94,19 +94,19 @@ export const createPackageSearchProvider = (core: CoreSetup): GlobalSearchResult coreStart: CoreStart, packagesResponse: GetPackagesResponse['response'] ): GlobalSearchProviderResult[] => { - const packages = packagesResponse.slice(0, maxResults); - - return packages.flatMap( - includeAllPackages - ? (pkg) => toSearchResult(pkg, coreStart.application) - : (pkg) => { - if (!term || !pkg.title.toLowerCase().includes(term)) { - return []; + return packagesResponse + .flatMap( + includeAllPackages + ? (pkg) => toSearchResult(pkg, coreStart.application) + : (pkg) => { + if (!term || !pkg.title.toLowerCase().includes(term)) { + return []; + } + + return toSearchResult(pkg, coreStart.application); } - - return toSearchResult(pkg, coreStart.application); - } - ); + ) + .slice(0, maxResults); }; return combineLatest([coreStart$, getPackages$()]).pipe(