forked from opensearch-project/OpenSearch-Dashboards
-
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.
Add step data source UI test (opensearch-project#2264)
Signed-off-by: Kristen Tian <tyarong@amazon.com> Signed-off-by: Kristen Tian <tyarong@amazon.com>
- Loading branch information
1 parent
002774c
commit d8f592a
Showing
6 changed files
with
384 additions
and
7 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...x_pattern_wizard/components/step_data_source/__snapshots__/step_data_source.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
238 changes: 238 additions & 0 deletions
238
...n_wizard/components/step_data_source/components/header/__snapshots__/header.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
98 changes: 98 additions & 0 deletions
98
...create_index_pattern_wizard/components/step_data_source/components/header/header.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,98 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { Header } from '../header'; | ||
import { shallow } from 'enzyme'; | ||
|
||
describe('Header', () => { | ||
it('should render normally', () => { | ||
const component = shallow( | ||
<Header | ||
onDataSourceSelected={() => {}} | ||
dataSourceRef={{ type: 'type', id: 'id' }!} | ||
goToNextStep={() => {}} | ||
isNextStepDisabled={true} | ||
stepInfo={{ totalStepNumber: 0, currentStepNumber: 0 }} | ||
/> | ||
); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render data source finder when choose to use data source', () => { | ||
const component = shallow( | ||
<Header | ||
onDataSourceSelected={() => {}} | ||
dataSourceRef={{ type: 'type', id: 'id' }!} | ||
goToNextStep={() => {}} | ||
isNextStepDisabled={true} | ||
stepInfo={{ totalStepNumber: 0, currentStepNumber: 0 }} | ||
/> | ||
); | ||
|
||
component | ||
.find('[data-test-subj="createIndexPatternStepDataSourceUseDataSourceRadio"]') | ||
.simulate('change', { | ||
target: { | ||
checked: true, | ||
}, | ||
}); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
it('should disable next step before select data source', () => { | ||
const component = shallow( | ||
<Header | ||
onDataSourceSelected={() => {}} | ||
dataSourceRef={{ type: 'type', id: 'id' }!} | ||
goToNextStep={() => {}} | ||
isNextStepDisabled={true} | ||
stepInfo={{ totalStepNumber: 0, currentStepNumber: 0 }} | ||
/> | ||
); | ||
|
||
component | ||
.find('[data-test-subj="createIndexPatternStepDataSourceUseDataSourceRadio"]') | ||
.simulate('change', { | ||
target: { | ||
checked: true, | ||
}, | ||
}); | ||
|
||
expect( | ||
component | ||
.find('[data-test-subj="createIndexPatternStepDataSourceNextStepButton"]') | ||
.prop('isDisabled') | ||
).toEqual(true); | ||
}); | ||
|
||
it('should enable next step when pick default option', () => { | ||
const component = shallow( | ||
<Header | ||
onDataSourceSelected={() => {}} | ||
dataSourceRef={{ type: 'type', id: 'id' }!} | ||
goToNextStep={() => {}} | ||
isNextStepDisabled={true} | ||
stepInfo={{ totalStepNumber: 0, currentStepNumber: 0 }} | ||
/> | ||
); | ||
|
||
component | ||
.find('[data-test-subj="createIndexPatternStepDataSourceUseDefaultRadio"]') | ||
.simulate('change', { | ||
target: { | ||
checked: true, | ||
}, | ||
}); | ||
|
||
expect( | ||
component | ||
.find('[data-test-subj="createIndexPatternStepDataSourceNextStepButton"]') | ||
.prop('isDisabled') | ||
).toEqual(false); | ||
}); | ||
}); |
Oops, something went wrong.