Skip to content

Commit

Permalink
[MDS] Fix the hide local cluster config (opensearch-project#7497) (op…
Browse files Browse the repository at this point in the history
…ensearch-project#7506)

* Fix the local cluster config



* Fix the local cluster config and add test



* Changeset file for PR opensearch-project#7497 created/updated

---------



(cherry picked from commit e24e535)

Signed-off-by: Ryan Liang <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 26, 2024
1 parent 86f4901 commit eb99c5c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/7497.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- [MDS] Fix the hide local cluster config ([#7497](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7497))
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import React from 'react';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { ManageDirectQueryDataConnectionsTable } from './manage_direct_query_data_connections_table';
import { getHideLocalCluster } from '../../utils';

// Mock dependencies
jest.mock('react-router-dom', () => ({
Expand All @@ -24,9 +25,20 @@ jest.mock('../integrations/installed_integrations_table', () => ({
InstallIntegrationFlyout: jest.fn(() => <div>MockInstallIntegrationFlyout</div>),
}));

jest.mock('../../utils', () => ({
...jest.requireActual('../../utils'),
getHideLocalCluster: jest.fn(() => ({ enabled: true })),
}));

describe('ManageDirectQueryDataConnectionsTable', () => {
const mockHttp = { get: jest.fn(), delete: jest.fn() };
const mockNotifications = { toasts: { addSuccess: jest.fn(), addDanger: jest.fn() } };
const mockNotifications = {
toasts: {
addSuccess: jest.fn(),
addDanger: jest.fn(),
addWarning: jest.fn(),
},
};
const mockSavedObjects = { client: {} };
const mockUiSettings = {};
const mockApplication = { navigateToApp: jest.fn() };
Expand Down Expand Up @@ -134,4 +146,22 @@ describe('ManageDirectQueryDataConnectionsTable', () => {
await waitFor(() => expect(screen.getByText('connection1')).toBeInTheDocument());
expect(screen.queryByText('Loading direct query data connections...')).not.toBeInTheDocument();
});

test('renders DataSourceSelector with hideLocalCluster enabled', async () => {
const newProps = {
...defaultProps,
featureFlagStatus: true,
};

render(<ManageDirectQueryDataConnectionsTable {...newProps} />);

await waitFor(() => {
const dataSourceSelector = screen.getByTestId('dataSourceSelectorComboBox');
expect(dataSourceSelector).toBeInTheDocument();
});

// Verify that the hideLocalCluster prop is passed correctly
expect(getHideLocalCluster).toHaveBeenCalled();
expect(getHideLocalCluster().enabled).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { DATACONNECTIONS_BASE, observabilityMetricsID } from '../../../constants
import { getRenderCreateAccelerationFlyout } from '../../../plugin';
import { InstallIntegrationFlyout } from '../integrations/installed_integrations_table';
import { redirectToExplorerS3 } from '../associated_object_management/utils/associated_objects_tab_utils';
import { isPluginInstalled } from '../../utils';
import { isPluginInstalled, getHideLocalCluster } from '../../utils';

interface DataConnection {
connectionType: DirectQueryDatasourceType;
Expand Down Expand Up @@ -306,6 +306,7 @@ export const ManageDirectQueryDataConnectionsTable: React.FC<ManageDirectQueryDa
uiSettings={uiSettings}
disabled={false}
compressed={true}
hideLocalCluster={getHideLocalCluster().enabled}
/>
</EuiFlexItem>
)}
Expand Down

0 comments on commit eb99c5c

Please sign in to comment.