Skip to content

Commit

Permalink
pit create changes
Browse files Browse the repository at this point in the history
Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
  • Loading branch information
bharath-techie committed May 19, 2023
1 parent 724b930 commit 8e3ba7a
Show file tree
Hide file tree
Showing 13 changed files with 932 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ export class CreateIndexPatternWizard extends Component<

renderContent() {
const { allIndices, isInitiallyLoadingIndices, step, indexPattern, dataSourceRef } = this.state;

const stepInfo = {
totalStepNumber: this.totalSteps,
currentStepNumber: getCurrentStepNumber(step, this.dataSourceEnabled),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import { CreateButton } from './create_button';
import { scopedHistoryMock } from '../../../../../core/public/mocks';
import { ScopedHistory } from 'opensearch-dashboards/public';

const createButtonIdentifier = `[data-test-subj="createDataSourceButton"]`;

describe('CreateButton', () => {
const history = (scopedHistoryMock.create() as unknown) as ScopedHistory;
const dataTestSubj = 'createDataSourceButton';
let component: ShallowWrapper<any, Readonly<{}>, React.Component<{}, {}, any>>;

beforeEach(() => {
component = shallow(<CreateButton history={history} dataTestSubj={dataTestSubj} />);
});

it('should render normally', () => {
expect(component).toMatchSnapshot();
});

it('should click event normally', () => {
component.find(createButtonIdentifier).first().simulate('click');

expect(history.push).toBeCalledWith('/create');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { History } from 'history';

import { EuiButton } from '@elastic/eui';
import { FormattedMessage } from '@osd/i18n/react';

interface Props {
history: History;
isEmptyState?: boolean;
dataTestSubj: string;
}

export const CreateButton = ({ history, isEmptyState, dataTestSubj }: Props) => {
return (
<EuiButton
data-test-subj={dataTestSubj}
fill={isEmptyState ? false : true}
onClick={() => history.push('/create')}
>
<FormattedMessage
id="pit.createButton"
defaultMessage="Create point in time"
/>
</EuiButton>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export { CreateButton } from './create_button';
Loading

0 comments on commit 8e3ba7a

Please sign in to comment.