-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GS] add tag and dashboard suggestion results (#85144)
* initial draft * polish * fix mocks * add tests * tests on suggestions * add comment * add FTR tests * factorize getSearchableTypes * move to bottom
- Loading branch information
1 parent
d63f769
commit 73fbf2a
Showing
37 changed files
with
1,226 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
x-pack/plugins/global_search/public/services/fetch_server_searchable_types.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { httpServiceMock } from '../../../../../src/core/public/mocks'; | ||
import { fetchServerSearchableTypes } from './fetch_server_searchable_types'; | ||
|
||
describe('fetchServerSearchableTypes', () => { | ||
let http: ReturnType<typeof httpServiceMock.createStartContract>; | ||
|
||
beforeEach(() => { | ||
http = httpServiceMock.createStartContract(); | ||
}); | ||
|
||
it('perform a GET request to the endpoint with valid options', () => { | ||
http.get.mockResolvedValue({ results: [] }); | ||
|
||
fetchServerSearchableTypes(http); | ||
|
||
expect(http.get).toHaveBeenCalledTimes(1); | ||
expect(http.get).toHaveBeenCalledWith('/internal/global_search/searchable_types'); | ||
}); | ||
|
||
it('returns the results from the server', async () => { | ||
const types = ['typeA', 'typeB']; | ||
|
||
http.get.mockResolvedValue({ types }); | ||
|
||
const results = await fetchServerSearchableTypes(http); | ||
|
||
expect(http.get).toHaveBeenCalledTimes(1); | ||
expect(results).toEqual(types); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
x-pack/plugins/global_search/public/services/fetch_server_searchable_types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { HttpStart } from 'src/core/public'; | ||
|
||
interface ServerSearchableTypesResponse { | ||
types: string[]; | ||
} | ||
|
||
export const fetchServerSearchableTypes = async (http: HttpStart) => { | ||
const { types } = await http.get<ServerSearchableTypesResponse>( | ||
'/internal/global_search/searchable_types' | ||
); | ||
return types; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.