Skip to content

Commit

Permalink
Add step data source UI test (opensearch-project#2264)
Browse files Browse the repository at this point in the history
Signed-off-by: Kristen Tian <tyarong@amazon.com>

Signed-off-by: Kristen Tian <tyarong@amazon.com>
  • Loading branch information
kristenTian committed Sep 15, 2022
1 parent 847e4c6 commit ea0ee82
Show file tree
Hide file tree
Showing 6 changed files with 384 additions and 7 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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);
});
});
Loading

0 comments on commit ea0ee82

Please sign in to comment.