Skip to content

Commit

Permalink
[7.x] [Security Solution][Case] Show error banner after loading conne…
Browse files Browse the repository at this point in the history
…ctors (#90134) (#90160)
  • Loading branch information
cnasikas authored Feb 3, 2021
1 parent 12820e1 commit 733ee6e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 } },
Expand Down Expand Up @@ -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();
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export const CaseComponent = React.memo<CaseProps>(
connectors,
updateCase: handleUpdateCase,
userCanCrud,
isValidConnector,
isValidConnector: isLoadingConnectors ? true : isValidConnector,
alerts,
});

Expand Down

0 comments on commit 733ee6e

Please sign in to comment.