[Security Solution][Case] Show error banner after loading connectors (#90134)

This commit is contained in:
Christos Nasikas 2021-02-03 15:01:26 +02:00 committed by GitHub
parent 7a3279768d
commit 24bf256bb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 2 deletions

View file

@ -144,7 +144,7 @@ describe('CaseView ', () => {
jest.spyOn(routeData, 'useLocation').mockReturnValue(mockLocation);
useGetCaseUserActionsMock.mockImplementation(() => defaultUseGetCaseUserActions);
usePostPushToServiceMock.mockImplementation(() => ({ isLoading: false, postPushToService }));
useConnectorsMock.mockImplementation(() => ({ connectors: connectorsMock, isLoading: false }));
useConnectorsMock.mockImplementation(() => ({ connectors: connectorsMock, loading: false }));
useQueryAlertsMock.mockImplementation(() => ({
loading: false,
data: { hits: { hits: alertsHit } },
@ -705,4 +705,38 @@ describe('CaseView ', () => {
expect(updateObject.updateValue).toEqual({ syncAlerts: false });
});
});
describe('Callouts', () => {
it('it shows the danger callout when a connector has been deleted', async () => {
useConnectorsMock.mockImplementation(() => ({ connectors: [], loading: false }));
const wrapper = mount(
<TestProviders>
<Router history={mockHistory}>
<CaseComponent {...caseProps} />
</Router>
</TestProviders>
);
await waitFor(() => {
wrapper.update();
expect(wrapper.find('.euiCallOut--danger').first().exists()).toBeTruthy();
});
});
it('it does NOT shows the danger callout when connectors are loading', async () => {
useConnectorsMock.mockImplementation(() => ({ connectors: [], loading: true }));
const wrapper = mount(
<TestProviders>
<Router history={mockHistory}>
<CaseComponent {...caseProps} />
</Router>
</TestProviders>
);
await waitFor(() => {
wrapper.update();
expect(wrapper.find('.euiCallOut--danger').first().exists()).toBeFalsy();
});
});
});
});

View file

@ -295,7 +295,7 @@ export const CaseComponent = React.memo<CaseProps>(
connectors,
updateCase: handleUpdateCase,
userCanCrud,
isValidConnector,
isValidConnector: isLoadingConnectors ? true : isValidConnector,
alerts,
});