-
Notifications
You must be signed in to change notification settings - Fork 916
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-workspace-update-page-missing-apps
- Loading branch information
Showing
14 changed files
with
157 additions
and
2 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
56 changes: 56 additions & 0 deletions
56
src/plugins/data/public/ui/index_pattern_select/index_pattern_select.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,56 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { shallow } from 'enzyme'; | ||
import { SavedObjectsClientContract } from '../../../../../core/public'; | ||
import React from 'react'; | ||
import IndexPatternSelect from './index_pattern_select'; | ||
|
||
describe('IndexPatternSelect', () => { | ||
let client: SavedObjectsClientContract; | ||
const bulkGetMock = jest.fn(); | ||
|
||
const nextTick = () => new Promise((res) => process.nextTick(res)); | ||
|
||
beforeEach(() => { | ||
client = { | ||
find: jest.fn().mockResolvedValue({ | ||
savedObjects: [ | ||
{ | ||
references: [{ id: 'testDataSourceId', type: 'data-source' }], | ||
attributes: { title: 'testTitle1' }, | ||
}, | ||
{ | ||
references: [{ id: 'testDataSourceId', type: 'data-source' }], | ||
attributes: { title: 'testTitle2' }, | ||
}, | ||
], | ||
}), | ||
bulkGet: bulkGetMock, | ||
get: jest.fn().mockResolvedValue({ | ||
references: [{ id: 'someId', type: 'data-source' }], | ||
attributes: { title: 'testTitle' }, | ||
}), | ||
} as any; | ||
}); | ||
|
||
it('should render index pattern select', async () => { | ||
const onChangeMock = jest.fn(); | ||
const compInstance = shallow( | ||
<IndexPatternSelect | ||
placeholder={'test index pattern'} | ||
indexPatternId={'testId'} | ||
onChange={onChangeMock} | ||
data-test-subj={'testId'} | ||
savedObjectsClient={client} | ||
/> | ||
).instance(); | ||
|
||
bulkGetMock.mockResolvedValue({ savedObjects: [{ attributes: { title: 'test1' } }] }); | ||
compInstance.debouncedFetch(''); | ||
await new Promise((resolve) => setTimeout(resolve, 300)); | ||
await nextTick(); | ||
expect(bulkGetMock).toBeCalledWith([{ id: 'testDataSourceId', type: 'data-source' }]); | ||
}); | ||
}); |
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
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
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
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
14 changes: 14 additions & 0 deletions
14
...ce_management/public/components/no_data_source/__snapshots__/no_data_source.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
src/plugins/data_source_management/public/components/no_data_source/index.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,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { NoDataSource } from './no_data_source'; |
16 changes: 16 additions & 0 deletions
16
src/plugins/data_source_management/public/components/no_data_source/no_data_source.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,16 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { ShallowWrapper, shallow } from 'enzyme'; | ||
import React from 'react'; | ||
import { NoDataSource } from './no_data_source'; | ||
|
||
describe('NoDataSource', () => { | ||
let component: ShallowWrapper<any, Readonly<{}>, React.Component<{}, {}, any>>; | ||
it('should render normally', () => { | ||
component = shallow(<NoDataSource />); | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
src/plugins/data_source_management/public/components/no_data_source/no_data_source.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,24 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { EuiButtonEmpty } from '@elastic/eui'; | ||
|
||
export const NoDataSource = () => { | ||
const label = ' No data sources'; | ||
return ( | ||
<EuiButtonEmpty | ||
className="euiHeaderLink" | ||
data-test-subj="dataSourceViewContextMenuHeaderLink" | ||
iconType="alert" | ||
iconSide="left" | ||
size="s" | ||
color="primary" | ||
> | ||
{label} | ||
</EuiButtonEmpty> | ||
); | ||
}; |