[Explore] Risk score restart button bug fix (#142416) (#142508)

(cherry picked from commit e1aa6a6d24)

Co-authored-by: Steph Milovic <stephanie.milovic@elastic.co>
This commit is contained in:
Kibana Machine 2022-10-03 14:02:56 -06:00 committed by GitHub
parent 42418b83ca
commit c41d09d28c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View file

@ -15,6 +15,8 @@ import { restartRiskScoreTransforms } from './utils';
jest.mock('./utils');
const mockRestartRiskScoreTransforms = restartRiskScoreTransforms as jest.Mock;
describe('RiskScoreRestartButton', () => {
const mockRefetch = jest.fn();
beforeEach(() => {
@ -33,7 +35,7 @@ describe('RiskScoreRestartButton', () => {
);
});
it('calls restartRiskScoreTransforms', async () => {
it('calls restartRiskScoreTransforms with correct entity', async () => {
render(
<TestProviders>
<RiskScoreRestartButton refetch={mockRefetch} riskScoreEntity={riskScoreEntity} />
@ -43,8 +45,10 @@ describe('RiskScoreRestartButton', () => {
await act(async () => {
await userEvent.click(screen.getByTestId(`restart_${riskScoreEntity}_risk_score`));
});
expect(restartRiskScoreTransforms).toHaveBeenCalled();
expect(mockRestartRiskScoreTransforms).toHaveBeenCalled();
expect(mockRestartRiskScoreTransforms.mock.calls[0][0].riskScoreEntity).toEqual(
riskScoreEntity
);
});
it('Update button state while installing', async () => {

View file

@ -9,7 +9,7 @@ import { EuiButton } from '@elastic/eui';
import React, { useCallback } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { RiskScoreEntity } from '../../../../../common/search_strategy';
import type { RiskScoreEntity } from '../../../../../common/search_strategy';
import { useSpaceId } from '../../../hooks/use_space_id';
import { useKibana } from '../../../lib/kibana';
import type { inputsModel } from '../../../store';
@ -39,11 +39,11 @@ const RiskScoreRestartButtonComponent = ({
notifications,
refetch,
renderDocLink,
riskScoreEntity: RiskScoreEntity.host,
riskScoreEntity,
spaceId,
theme,
});
}, [fetch, http, notifications, refetch, renderDocLink, spaceId, theme]);
}, [fetch, http, notifications, refetch, renderDocLink, riskScoreEntity, spaceId, theme]);
return (
<EuiButton