-
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.
[Enterprise Search] Match simulate pipeline features with stack manag…
…ement (#145275) ## Summary Adds features to test pipeline with an existing document from the index. Also updated the text to give consistent messages across the other parts of the kibana https://user-images.githubusercontent.com/1410658/201979420-005b6f3e-c44c-4e44-b40e-88c3c717bb99.mov ## Release note Adds the ability to test Ingest pipelines with a document from the same index. ### Checklist Delete any items that are not applicable to this PR. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- Loading branch information
Showing
10 changed files
with
369 additions
and
56 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
26 changes: 26 additions & 0 deletions
26
..._search/public/applications/enterprise_search_content/api/documents/get_document_logic.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,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { GetResponse } from '@elastic/elasticsearch/lib/api/types'; | ||
|
||
import { createApiLogic } from '../../../shared/api_logic/create_api_logic'; | ||
import { HttpLogic } from '../../../shared/http'; | ||
|
||
export interface GetDocumentsArgs { | ||
documentId: string; | ||
indexName: string; | ||
} | ||
|
||
export type GetDocumentsResponse = GetResponse<unknown>; | ||
|
||
export const getDocument = async ({ indexName, documentId }: GetDocumentsArgs) => { | ||
const route = `/internal/enterprise_search/indices/${indexName}/document/${documentId}`; | ||
|
||
return await HttpLogic.values.http.get<GetDocumentsResponse>(route); | ||
}; | ||
|
||
export const GetDocumentsApiLogic = createApiLogic(['get_documents_logic'], getDocument); |
42 changes: 42 additions & 0 deletions
42
...h/public/applications/enterprise_search_content/api/documents/get_documents_logic.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,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { mockHttpValues } from '../../../__mocks__/kea_logic'; | ||
|
||
import { nextTick } from '@kbn/test-jest-helpers'; | ||
|
||
import { getDocument } from './get_document_logic'; | ||
|
||
describe('getDocumentApiLogic', () => { | ||
const { http } = mockHttpValues; | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
describe('getDocument', () => { | ||
it('calls correct api', async () => { | ||
const promise = Promise.resolve({ | ||
_id: 'test-id', | ||
_index: 'indexName', | ||
_source: {}, | ||
found: true, | ||
}); | ||
http.get.mockReturnValue(promise); | ||
const result = getDocument({ documentId: '123123', indexName: 'indexName' }); | ||
await nextTick(); | ||
expect(http.get).toHaveBeenCalledWith( | ||
'/internal/enterprise_search/indices/indexName/document/123123' | ||
); | ||
await expect(result).resolves.toEqual({ | ||
_id: 'test-id', | ||
_index: 'indexName', | ||
_source: {}, | ||
found: true, | ||
}); | ||
}); | ||
}); | ||
}); |
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.