Skip to content

Commit

Permalink
[MD] UX updates on data source page & validation changes (opensearch-…
Browse files Browse the repository at this point in the history
…project#2521)

* new ux changes v2.4.0

Signed-off-by: mpabba3003 <amazonmanideep@gmail.com>

* new UX changes and Validation changed

Signed-off-by: mpabba3003 <amazonmanideep@gmail.com>

* refactoring duplicate title validation on edit data source

Signed-off-by: mpabba3003 <amazonmanideep@gmail.com>

* replacing eui toasts with notifications toasts

Signed-off-by: mpabba3003 <amazonmanideep@gmail.com>

* updating testcases after updating toasts methods

Signed-off-by: mpabba3003 <amazonmanideep@gmail.com>

* adding change log for data source

Signed-off-by: mpabba3003 <amazonmanideep@gmail.com>

* adding password validation on update stored password modal

Signed-off-by: mpabba3003 <amazonmanideep@gmail.com>

* removing un-used text content

Signed-off-by: mpabba3003 <amazonmanideep@gmail.com>

Signed-off-by: mpabba3003 <amazonmanideep@gmail.com>
  • Loading branch information
mpabba3003 authored and yibow98 committed Oct 7, 2022
1 parent 723a3fb commit b983496
Show file tree
Hide file tree
Showing 26 changed files with 2,233 additions and 4,343 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* [Viz Builder] State validation before dispatching and loading ([#2351](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2351))
* [Viz Builder] Create a new wizard directly on a dashboard ([#2384](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2384))
* [Multi DataSource] UX enhacement on index pattern management stack ([#2505]https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2505))
* [Multi DataSource] UX enhancement on Data source management stack ([#2521](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2521))

### 🐛 Bug Fixes

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
Expand Up @@ -7,7 +7,7 @@ import React from 'react';
import { History } from 'history';

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

interface Props {
history: History;
Expand All @@ -19,12 +19,8 @@ export const CreateButton = ({ history }: Props) => {
data-test-subj="createDataSourceButton"
fill={true}
onClick={() => history.push('/create')}
iconType="plusInCircle"
>
<FormattedMessage
id="dataSourcesManagement.dataSourcesTable.createBtn"
defaultMessage="Create data source connection"
/>
{CREATE_DATA_SOURCE_BUTTON_TEXT}
</EuiButton>
);
};

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 @@ -9,6 +9,7 @@ import { mount, ReactWrapper } from 'enzyme';
import { wrapWithIntl } from 'test_utils/enzyme_helpers';
import { OpenSearchDashboardsContextProvider } from '../../../../../../opensearch_dashboards_react/public';
import { CreateDataSourceForm } from './create_data_source_form';
// @ts-ignore
import { findTestSubject } from '@elastic/eui/lib/test';
import { AuthType } from '../../../../types';

Expand All @@ -18,6 +19,7 @@ const endpointIdentifier = '[data-test-subj="createDataSourceFormEndpointField"]
const authTypeIdentifier = '[data-test-subj="createDataSourceFormAuthTypeSelect"]';
const usernameIdentifier = '[data-test-subj="createDataSourceFormUsernameField"]';
const passwordIdentifier = '[data-test-subj="createDataSourceFormPasswordField"]';
const createButtonIdentifier = '[data-test-subj="createDataSourceButton"]';

describe('Datasource Management: Create Datasource form', () => {
const mockedContext = mockManagementPlugin.createDataSourceManagementContext();
Expand Down Expand Up @@ -57,12 +59,17 @@ describe('Datasource Management: Create Datasource form', () => {
};

beforeEach(() => {
component = mount(wrapWithIntl(<CreateDataSourceForm handleSubmit={mockSubmitHandler} />), {
wrappingComponent: OpenSearchDashboardsContextProvider,
wrappingComponentProps: {
services: mockedContext,
},
});
component = mount(
wrapWithIntl(
<CreateDataSourceForm handleSubmit={mockSubmitHandler} existingDatasourceNamesList={[]} />
),
{
wrappingComponent: OpenSearchDashboardsContextProvider,
wrappingComponentProps: {
services: mockedContext,
},
}
);
});

/* Scenario 1: Should render the page normally*/
Expand All @@ -72,16 +79,9 @@ describe('Datasource Management: Create Datasource form', () => {

/* Scenario 2: submit without any input from user - should display validation error messages*/
/* 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);
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);
test('should disable submit button when there is no user input on any field', () => {
const createBtn = component.find(createButtonIdentifier).last();
expect(createBtn.prop('disabled')).toBe(true);
});

/* Change option: No Authentication */
Expand All @@ -93,13 +93,9 @@ 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 { authType, 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(authType.prop('idSelected')).toBe(AuthType.NoAuth);
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 @@ -110,21 +106,20 @@ describe('Datasource Management: Create Datasource form', () => {
changeTextFieldValue(usernameIdentifier, 'test123');
changeTextFieldValue(passwordIdentifier, 'test123');

findTestSubject(component, 'createDataSourceButton').simulate('click');
component.find(titleIdentifier).last().simulate('blur');

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

/* Update title & remove validation*/
findTestSubject(component, 'createDataSourceButton').simulate('click');
changeTextFieldValue(titleIdentifier, 'test');
component.find(titleIdentifier).last().simulate('blur');
findTestSubject(component, 'createDataSourceButton').simulate('click');
expect(mockSubmitHandler).toHaveBeenCalled(); // should call submit as all fields are valid
});
Expand Down
Loading

0 comments on commit b983496

Please sign in to comment.