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.
[MD] Expose picker using function in data source management plugin se…
…tup (opensearch-project#6030) (opensearch-project#6037) * expose picker using function in plugin setup Signed-off-by: Lu Yu <nluyu@amazon.com> * add changelog and test Signed-off-by: Lu Yu <nluyu@amazon.com> --------- Signed-off-by: Lu Yu <nluyu@amazon.com> (cherry picked from commit 49d1649) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
3213c31
commit 0cad69d
Showing
5 changed files
with
275 additions
and
2 deletions.
There are no files selected for viewing
216 changes: 216 additions & 0 deletions
216
...nt/public/components/cluster_selector/__snapshots__/create_cluster_selector.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
40 changes: 40 additions & 0 deletions
40
...ata_source_management/public/components/cluster_selector/create_cluster_selector.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,40 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { createClusterSelector } from './create_cluster_selector'; | ||
import { SavedObjectsClientContract } from '../../../../../core/public'; | ||
import { notificationServiceMock } from '../../../../../core/public/mocks'; | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
describe('create cluster selector', () => { | ||
let client: SavedObjectsClientContract; | ||
const { toasts } = notificationServiceMock.createStartContract(); | ||
|
||
beforeEach(() => { | ||
client = { | ||
find: jest.fn().mockResolvedValue([]), | ||
} as any; | ||
}); | ||
|
||
it('should render normally', () => { | ||
const props = { | ||
savedObjectsClient: client, | ||
notifications: toasts, | ||
onSelectedDataSource: jest.fn(), | ||
disabled: false, | ||
hideLocalCluster: false, | ||
fullWidth: false, | ||
}; | ||
const TestComponent = createClusterSelector(); | ||
const component = render(<TestComponent {...props} />); | ||
expect(component).toMatchSnapshot(); | ||
expect(client.find).toBeCalledWith({ | ||
fields: ['id', 'description', 'title'], | ||
perPage: 10000, | ||
type: 'data-source', | ||
}); | ||
expect(toasts.addWarning).toBeCalledTimes(0); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
...ins/data_source_management/public/components/cluster_selector/create_cluster_selector.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,11 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { ClusterSelector, ClusterSelectorProps } from './cluster_selector'; | ||
|
||
export function createClusterSelector() { | ||
return (props: ClusterSelectorProps) => <ClusterSelector {...props} />; | ||
} |
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