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.
[Multiple Datasource Test] Add test for edit data source form (opense…
…arch-project#6742) * add test for edit data source form Signed-off-by: yujin-emma <[email protected]> * Changeset file for PR opensearch-project#6742 created/updated --------- Signed-off-by: yujin-emma <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
281 additions
and
0 deletions.
There are no files selected for viewing
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,2 @@ | ||
fix: | ||
- Add test for edit data source form ([#6742](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6742)) |
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
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
67 changes: 67 additions & 0 deletions
67
...t_data_source/components/update_aws_credential_modal/update_aws_credential_modal.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,67 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { mount, shallow } from 'enzyme'; | ||
import { render } from '@testing-library/react'; | ||
import { UpdateAwsCredentialModal } from './update_aws_credential_modal'; | ||
import { SigV4ServiceName } from '../../../../../../data_source/common/data_sources'; | ||
import { EuiFormRow, EuiModalHeaderTitle } from '@elastic/eui'; | ||
import { FormattedMessage } from 'react-intl'; | ||
|
||
describe('UpdateAwsCredentialModal', () => { | ||
const mockHandleUpdateAwsCredential = jest.fn(); | ||
const mockCloseUpdateAwsCredentialModal = jest.fn(); | ||
|
||
const props = { | ||
region: 'us-east-1', | ||
service: SigV4ServiceName.OpenSearch, | ||
handleUpdateAwsCredential: mockHandleUpdateAwsCredential, | ||
closeUpdateAwsCredentialModal: mockCloseUpdateAwsCredentialModal, | ||
}; | ||
|
||
it('updates new access key state on input change', () => { | ||
const wrapper = shallow(<UpdateAwsCredentialModal {...props} />); | ||
const newAccessKeyInput = wrapper.find('[name="updatedAccessKey"]'); | ||
newAccessKeyInput.simulate('change', { target: { value: 'new_access_key' } }); | ||
expect(wrapper.find('[name="updatedAccessKey"]').prop('value')).toEqual('new_access_key'); | ||
}); | ||
|
||
it('renders modal with correct header title', () => { | ||
const wrapper = shallow(<UpdateAwsCredentialModal {...props} />); | ||
const headerTitle = wrapper.find(EuiModalHeaderTitle).props().children; | ||
expect(headerTitle).toEqual( | ||
<h1> | ||
<FormattedMessage | ||
defaultMessage="Update stored AWS credential" | ||
id="dataSourcesManagement.editDataSource.updateStoredAwsCredential" | ||
values={{}} | ||
/> | ||
</h1> | ||
); | ||
}); | ||
|
||
it('renders modal with correct label for updated secret key', () => { | ||
const wrapper = shallow(<UpdateAwsCredentialModal {...props} />); | ||
expect(wrapper.find(EuiFormRow).at(4).props().label).toEqual('Updated secret key'); | ||
}); | ||
|
||
it('renders modal with correct label for updated access key', () => { | ||
const wrapper = shallow(<UpdateAwsCredentialModal {...props} />); | ||
expect(wrapper.find(EuiFormRow).at(3).props().label).toEqual('Updated access key'); | ||
}); | ||
|
||
it('renders modal with correct region', () => { | ||
const container = render(<UpdateAwsCredentialModal {...props} />); | ||
expect(container.getByTestId('data-source-update-credential-region')).toBeVisible(); | ||
const text = container.getByTestId('data-source-update-credential-region'); | ||
expect(text.textContent).toBe(props.region); | ||
}); | ||
|
||
it('renders modal with service name select', () => { | ||
const container = render(<UpdateAwsCredentialModal {...props} />); | ||
expect(container.getByTestId('data-source-update-credential-service-name')).toBeVisible(); | ||
}); | ||
}); |
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