Skip to content

Commit

Permalink
update snapshot test and snapshots
Browse files Browse the repository at this point in the history
Signed-off-by: Yibo Wang <yibow@amazon.com>
  • Loading branch information
yibow98 committed Oct 6, 2022
1 parent 89d2b49 commit b615245
Show file tree
Hide file tree
Showing 8 changed files with 991 additions and 1,818 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,11 @@ describe('Datasource Management: Create Datasource form', () => {
/* Default option: Username & Password*/
test('should validate when submit button is clicked without any user input on any field', () => {
findTestSubject(component, 'createDataSourceButton').simulate('click');
const { title, description, endpoint, authType, username, password } = getFields(component);
const { title, description, endpoint, username, password } = getFields(component);
expect(component).toMatchSnapshot();
expect(title.prop('isInvalid')).toBe(true);
expect(description.prop('isInvalid')).toBe(undefined);
expect(endpoint.prop('isInvalid')).toBe(true);
expect(authType.prop('isInvalid')).toBe(false);
expect(username.prop('isInvalid')).toBe(true);
expect(password.prop('isInvalid')).toBe(true);
});
Expand All @@ -93,13 +92,11 @@ describe('Datasource Management: Create Datasource form', () => {
/* Click on submit without any user input */
findTestSubject(component, 'createDataSourceButton').simulate('click');

const { title, description, endpoint, authType, username, password } = getFields(component);
const { title, description, endpoint, username, password } = getFields(component);

expect(authType.prop('valueOfSelected')).toBe(AuthType.NoAuth);
expect(title.prop('isInvalid')).toBe(true);
expect(description.prop('isInvalid')).toBe(undefined);
expect(endpoint.prop('isInvalid')).toBe(true);
expect(authType.prop('isInvalid')).toBe(false);
expect(username.exists()).toBeFalsy(); // username field does not exist when No Auth option is selected
expect(password.exists()).toBeFalsy(); // password field does not exist when No Auth option is selected
});
Expand All @@ -112,13 +109,12 @@ describe('Datasource Management: Create Datasource form', () => {

findTestSubject(component, 'createDataSourceButton').simulate('click');

const { title, description, endpoint, authType, username, password } = getFields(component);
const { title, description, endpoint, username, password } = getFields(component);

expect(component).toMatchSnapshot();
expect(title.prop('isInvalid')).toBe(true);
expect(description.prop('isInvalid')).toBe(undefined);
expect(endpoint.prop('isInvalid')).toBe(false);
expect(authType.prop('isInvalid')).toBe(false);
expect(username.prop('isInvalid')).toBe(false);
expect(password.prop('isInvalid')).toBe(false);

Expand Down

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,18 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { shallow } from 'enzyme';
import { ExperimentalCallout } from './experimental_callout';
import { DocLinksStart } from 'opensearch-dashboards/public';
import { docLinks } from '../../../mocks';

describe('Index pattern experimental callout component', () => {
const mockedDocLinks = docLinks as DocLinksStart;
test('should render normally', () => {
const component = shallow(<ExperimentalCallout docLinks={mockedDocLinks} />);
expect(component).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ import {
DATA_SOURCE_OPEN_FORUM_TEXT,
} from '../../../components/text_content';

export const ExperimentalCallOut = ({ docLinks }: { docLinks: DocLinksStart }) => {
export const ExperimentalCallout = ({ docLinks }: { docLinks: DocLinksStart }) => {
return (
<>
<EuiCallOut title={EXPERIMENTAL_FEATURE} iconType="iInCircle">
<EuiCallOut
title={EXPERIMENTAL_FEATURE}
iconType="iInCircle"
data-test-subj="data-source-experimental-callout"
>
<p>
{EXPERIMENTAL_FEATURE_CALL_OUT_DESCRIPTION}
<EuiLink href={docLinks.links.noDocumentation.indexPatterns.introduction} target="_blank">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

export * from './experimental_call_out';
export * from './experimental_callout';
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { CreateDataSourceWizardWithRouter } from '../components/create_data_sour
import { DataSourceTableWithRouter } from '../components/data_source_table';
import { DataSourceManagementContext } from '../types';
import { EditDataSourceWithRouter } from '../components/edit_data_source';
import { ExperimentalCallOut } from './compoenent/experimental_call_out';
import { ExperimentalCallout } from './compoenent/experimental_callout';

export interface DataSourceManagementStartDependencies {
data: DataPublicPluginStart;
Expand Down Expand Up @@ -46,7 +46,7 @@ export async function mountManagementSection(
ReactDOM.render(
<OpenSearchDashboardsContextProvider services={deps}>
<I18nProvider>
<ExperimentalCallOut docLinks={docLinks} />
<ExperimentalCallout docLinks={docLinks} />
<Router history={params.history}>
<Switch>
<Route path={['/create']}>
Expand Down

0 comments on commit b615245

Please sign in to comment.