Skip to content

Commit

Permalink
refactor based on PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: mpabba3003 <amazonmanideep@gmail.com>
  • Loading branch information
mpabba3003 committed Dec 6, 2022
1 parent f140548 commit 06fefc2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Vis Builder] Add field summary popovers ([#2682](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2682))
- [I18n] Register ru, ru-RU locale ([#2817](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2817))
- Add yarn opensearch arg to setup plugin dependencies ([#2544](https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2544))
- [Multi DataSource] Add Test connection feature on data source create and update ([#2973](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2973))
- [Multi DataSource] Test the connection to an external data source when creating or updating ([#2973](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2973))

### 🐛 Bug Fixes

- [Vis Builder] Fixes auto bounds for timeseries bar chart visualization ([2401](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2401))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('Datasource Management: Create Datasource Wizard', () => {
expect(utils.createSingleDataSource).toHaveBeenCalled();
});

test('should test connection successfully', async () => {
test('should test connection to the endpoint successfully', async () => {
spyOn(utils, 'testConnection').and.returnValue({});

await act(async () => {
Expand All @@ -82,7 +82,7 @@ describe('Datasource Management: Create Datasource Wizard', () => {
expect(utils.testConnection).toHaveBeenCalled();
});

test('should fail to test connection', async () => {
test('should fail to test connection to the endpoint', async () => {
spyOn(utils, 'testConnection').and.throwError('error');
await act(async () => {
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ describe('DataSourceManagement: Utils.ts', () => {
});
});

describe('Test connection - success', () => {
describe('Test connection to the endpoint of the data source - success', () => {
let http: jest.Mocked<HttpStart>;
const mockSuccess = jest.fn().mockResolvedValue({ body: { success: true } });
const mockError = jest.fn().mockRejectedValue(null);
beforeEach(() => {
http = coreMock.createStart().http;
http.post.mockResolvedValue(mockSuccess);
});
test('Success: Test Connection on create', async () => {
test('Success: Test Connection to the endpoint while creating a new data source', async () => {
await testConnection(http, getDataSourceByIdWithoutCredential.attributes);
expect(http.post.mock.calls).toMatchInlineSnapshot(`
Array [
Expand All @@ -163,7 +163,7 @@ describe('DataSourceManagement: Utils.ts', () => {
`);
});

test('Success: Test Connection on update', async () => {
test('Success: Test Connection to the endpoint while existing data source is updated', async () => {
await testConnection(http, getDataSourceByIdWithoutCredential.attributes, 'test1234');
expect(http.post.mock.calls).toMatchInlineSnapshot(`
Array [
Expand All @@ -176,7 +176,7 @@ describe('DataSourceManagement: Utils.ts', () => {
]
`);
});
test('failure: Test connection', async () => {
test('failure: Test Connection to the endpoint while creating/updating a data source', async () => {
try {
http.post.mockRejectedValue(mockError);
await testConnection(http, getDataSourceByIdWithoutCredential.attributes, 'test1234');
Expand Down

0 comments on commit 06fefc2

Please sign in to comment.