-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
31 changed files
with
1,637 additions
and
243 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
8 changes: 8 additions & 0 deletions
8
...lic/application/components/mappings_editor/__jest__/client_integration/datatypes/index.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,8 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { defaultShapeParameters } from './shape_datatype.test'; | ||
export { defaultTextParameters } from './text_datatype.test'; |
81 changes: 81 additions & 0 deletions
81
.../components/mappings_editor/__jest__/client_integration/datatypes/shape_datatype.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,81 @@ | ||
/* | ||
* 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 { act } from 'react-dom/test-utils'; | ||
|
||
import { componentHelpers, MappingsEditorTestBed } from '../helpers'; | ||
|
||
const { setup, getMappingsEditorDataFactory } = componentHelpers.mappingsEditor; | ||
const onChangeHandler = jest.fn(); | ||
const getMappingsEditorData = getMappingsEditorDataFactory(onChangeHandler); | ||
|
||
// Parameters automatically added to the shape datatype when saved (with the default values) | ||
export const defaultShapeParameters = { | ||
type: 'shape', | ||
coerce: false, | ||
ignore_malformed: false, | ||
ignore_z_value: true, | ||
}; | ||
|
||
describe('Mappings editor: shape datatype', () => { | ||
let testBed: MappingsEditorTestBed; | ||
|
||
/** | ||
* Variable to store the mappings data forwarded to the consumer component | ||
*/ | ||
let data: any; | ||
|
||
test('initial view and default parameters values', async () => { | ||
const defaultMappings = { | ||
_meta: {}, | ||
_source: {}, | ||
properties: { | ||
myField: { | ||
type: 'shape', | ||
}, | ||
}, | ||
}; | ||
|
||
const updatedMappings = { ...defaultMappings }; | ||
|
||
await act(async () => { | ||
testBed = await setup({ value: defaultMappings, onChange: onChangeHandler }); | ||
}); | ||
|
||
const { | ||
exists, | ||
waitFor, | ||
waitForFn, | ||
actions: { startEditField, updateFieldAndCloseFlyout }, | ||
} = testBed; | ||
|
||
// Open the flyout to edit the field | ||
await act(async () => { | ||
startEditField('myField'); | ||
}); | ||
|
||
await waitFor('mappingsEditorFieldEdit'); | ||
|
||
// Save the field and close the flyout | ||
await act(async () => { | ||
await updateFieldAndCloseFlyout(); | ||
}); | ||
|
||
await waitForFn( | ||
async () => exists('mappingsEditorFieldEdit') === false, | ||
'Error waiting for the details flyout to close' | ||
); | ||
|
||
// It should have the default parameters values added | ||
updatedMappings.properties.myField = { | ||
type: 'shape', | ||
...defaultShapeParameters, | ||
}; | ||
|
||
({ data } = await getMappingsEditorData()); | ||
expect(data).toEqual(updatedMappings); | ||
}); | ||
}); |
Oops, something went wrong.