-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Mappings editor] Add component integration tests #63853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
1318726
Test props.onUpdate() to make sure it forwards data to consumer
sebelga bf6be1e
Test props.defaultValue to make sure the editor is pre-populated corr…
sebelga 50a6f92
Fix test and add missing "key" element on UseField components
sebelga 60c87ee
Move expectDataUpdatedFactory to helpers and add editField helper
sebelga 841b8d0
[testbed] Add "waitForFn" helper to wait for a predicate function
sebelga 8385484
Add test of edit field (flyout) initial view
sebelga dce1813
[mappings editor] Strip undefined value from object returned
sebelga 5feedcc
Test that default parameters values are added to the field when updated
sebelga 905bae7
Remove unused
sebelga 91a3b7b
Fix strip undefined logic to support Array and Date instances
sebelga ab0ecd7
Add expandAllFields helper
sebelga 04930f7
Refactor helper to get data forwarded to consumer component
sebelga 21513e9
Move the beforeEach logic inside the test
sebelga b26f5c8
Add coverage for analyzer default value and changes
sebelga 93388a3
Fix act() error
sebelga a01f522
Fix TS issue
sebelga 9a8d9b5
Test custom analyzer of external plugins
sebelga 01605db
Test custom analyzer declared on index settings
sebelga 2fe79d0
Fix default value for second dropdown select of analyzers
sebelga 0f97d1f
Fix failing test
sebelga 2b63142
Add mapped field test to make sure the DOM tree represents the mappin…
sebelga 4e42d31
Refactor "defaultValue" to "value" to respect convention
sebelga d978d2a
Refactor "onUpdate" to "onChange" to respect convention
sebelga b45953b
Add test to make sure the MappingsEditor can be controlled
sebelga 41735fb
Add TS doc on how to mock <EuiSuperSelect />
sebelga d797ae2
Restructure tests
sebelga 21b5b8f
Test that the edit field form updates when switching datatype
sebelga ade4aa9
Merge branch 'master' into test/mappings-editor
elasticmachine 3d78aa8
Merge branch 'master' into test/mappings-editor
elasticmachine 80da167
Merge branch 'master' into test/mappings-editor
elasticmachine 760efa2
Move "waitFor" outside act() calls
sebelga 49876f3
[mappings editor] Fix regression when switching from "custom" to "bui…
sebelga 118124e
Add web worker stub to remove console warning on missing Worker
sebelga 49d0752
Fix textDatatype failing test
sebelga 5aeda2d
Merge branch 'master' into test/mappings-editor
elasticmachine ac17d91
Address CR changes
sebelga 2deaa38
Merge branch 'test/mappings-editor' of github.com:sebelga/kibana into…
sebelga d5c5179
Merge branch 'master' into test/mappings-editor
elasticmachine c669122
Inscrease timeout in test to 30s
sebelga 4fc1055
Merge branch 'master' into test/mappings-editor
elasticmachine fe92ac4
Merge branch 'master' into test/mappings-editor
elasticmachine 70bf068
Merge branch 'master' into test/mappings-editor
elasticmachine c56cb07
Merge branch 'master' into test/mappings-editor
elasticmachine ab76582
Address CR changes
sebelga 793bbdc
Merge branch 'master' into test/mappings-editor
elasticmachine df5be1c
Merge branch 'master' into test/mappings-editor
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.