forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Maps] fix Kibana Maps UI upload geojson failure should be received a…
…s such (elastic#149969) Fixes elastic#138122 PR updates geo spatial file upload to show error callout if all features fail indexing. PR updates geo spatial file upload to show warning callout if some features fail indexing. <img width="150" alt="Screen Shot 2023-01-31 at 11 34 49 AM" src="https://user-images.githubusercontent.com/373691/215851548-11cf9fa8-7c59-4d21-9257-664ab00f418d.png"> <img width="150" alt="Screen Shot 2023-01-31 at 11 34 32 AM" src="https://user-images.githubusercontent.com/373691/215851557-09dfbef3-ae0e-4ddd-b617-9c70a66fa712.png"> To test save the following geojson samples as a file with the name `<filename>.geojson`. Then upload the files in kibana. Verify errors are displayed as expected all invalid features ``` { "type" : "FeatureCollection", "features" : [{ "type" : "Feature", "geometry" : { "type" : "Point", "coordinates" : [ 100000, 42.417500 ] } }] } ``` some invalid features ``` { "type" : "FeatureCollection", "features" : [{ "type" : "Feature", "geometry" : { "type" : "Point", "coordinates" : [ 0, 0 ] } }, { "type" : "Feature", "geometry" : { "type" : "Point", "coordinates" : [ 100000, 0 ] } }] } ``` --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
0ab7722
commit 0e9d9c8
Showing
8 changed files
with
710 additions
and
20 deletions.
There are no files selected for viewing
519 changes: 519 additions & 0 deletions
519
...ck/plugins/file_upload/public/components/__snapshots__/import_complete_view.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
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
115 changes: 115 additions & 0 deletions
115
x-pack/plugins/file_upload/public/components/import_complete_view.test.tsx
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,115 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import { ImportCompleteView } from './import_complete_view'; | ||
|
||
jest.mock('../kibana_services', () => ({ | ||
get: jest.fn(), | ||
getDocLinks: () => { | ||
return { | ||
links: { | ||
maps: { | ||
importGeospatialPrivileges: 'linkToPrvilegesDocs', | ||
}, | ||
}, | ||
}; | ||
}, | ||
getHttp: () => { | ||
return { | ||
basePath: { | ||
prepend: (path: string) => `abc${path}`, | ||
}, | ||
}; | ||
}, | ||
getUiSettings: () => { | ||
return { | ||
get: jest.fn(), | ||
}; | ||
}, | ||
})); | ||
|
||
test('Should render success', () => { | ||
const component = shallow( | ||
<ImportCompleteView | ||
failedPermissionCheck={false} | ||
importResults={{ | ||
success: true, | ||
docCount: 10, | ||
}} | ||
dataViewResp={{}} | ||
indexName="myIndex" | ||
/> | ||
); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
test('Should render warning when some features failed import', () => { | ||
const component = shallow( | ||
<ImportCompleteView | ||
failedPermissionCheck={false} | ||
importResults={{ | ||
success: true, | ||
docCount: 10, | ||
failures: [ | ||
{ | ||
item: 1, | ||
reason: 'simulated feature import failure', | ||
doc: {}, | ||
}, | ||
], | ||
}} | ||
dataViewResp={{}} | ||
indexName="myIndex" | ||
/> | ||
); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
test('Should render error when upload fails from http request timeout', () => { | ||
const component = shallow( | ||
<ImportCompleteView | ||
failedPermissionCheck={false} | ||
importResults={{ | ||
success: false, | ||
docCount: 10, | ||
error: { | ||
body: { | ||
message: 'simulated http request timeout', | ||
}, | ||
}, | ||
}} | ||
indexName="myIndex" | ||
/> | ||
); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
test('Should render error when upload fails from elasticsearch request failure', () => { | ||
const component = shallow( | ||
<ImportCompleteView | ||
failedPermissionCheck={false} | ||
importResults={{ | ||
success: false, | ||
docCount: 10, | ||
error: { | ||
error: { | ||
reason: 'simulated elasticsearch request failure', | ||
}, | ||
}, | ||
}} | ||
indexName="myIndex" | ||
/> | ||
); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
|
||
export function getPartialImportMessage(failedFeaturesCount: number, totalFeaturesCount?: number) { | ||
const outOfTotalMsg = | ||
typeof totalFeaturesCount === 'number' | ||
? i18n.translate('xpack.fileUpload.geoUploadWizard.outOfTotalMsg', { | ||
defaultMessage: 'of {totalFeaturesCount}', | ||
values: { | ||
totalFeaturesCount, | ||
}, | ||
}) | ||
: ''; | ||
return i18n.translate('xpack.fileUpload.geoUploadWizard.partialImportMsg', { | ||
defaultMessage: 'Unable to index {failedFeaturesCount} {outOfTotalMsg} features.', | ||
values: { | ||
failedFeaturesCount, | ||
outOfTotalMsg, | ||
}, | ||
}); | ||
} |
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