Skip to content

Commit

Permalink
[Cases] Fix severity loading spinner visible while updating tags or a…
Browse files Browse the repository at this point in the history
  • Loading branch information
js-jankisalvi committed Jun 2, 2023
1 parent 7205072 commit e3da05c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Expand Up @@ -36,6 +36,7 @@ import { defaultInfiniteUseFindCaseUserActions, defaultUseFindCaseUserActions }
import { ActionTypes } from '../../../../common/api';
import { useGetCaseUserActionsStats } from '../../../containers/use_get_case_user_actions_stats';
import { useInfiniteFindCaseUserActions } from '../../../containers/use_infinite_find_case_user_actions';
import { useOnUpdateField } from '../use_on_update_field';

jest.mock('../../../containers/use_infinite_find_case_user_actions');
jest.mock('../../../containers/use_find_case_user_actions');
Expand All @@ -51,6 +52,7 @@ jest.mock('../../../containers/use_get_tags');
jest.mock('../../../containers/user_profiles/use_bulk_get_user_profiles');
jest.mock('../../../containers/use_get_case_connectors');
jest.mock('../../../containers/use_get_case_users');
jest.mock('../use_on_update_field');

(useGetTags as jest.Mock).mockReturnValue({ data: ['coke', 'pepsi'], refetch: jest.fn() });

Expand Down Expand Up @@ -118,11 +120,12 @@ const useGetConnectorsMock = useGetSupportedActionConnectors as jest.Mock;
const usePostPushToServiceMock = usePostPushToService as jest.Mock;
const useGetCaseConnectorsMock = useGetCaseConnectors as jest.Mock;
const useGetCaseUsersMock = useGetCaseUsers as jest.Mock;
const useOnUpdateFieldMock = useOnUpdateField as jest.Mock;

// FLAKY: https://github.com/elastic/kibana/issues/151979
// FLAKY: https://github.com/elastic/kibana/issues/151980
// FLAKY: https://github.com/elastic/kibana/issues/151981
describe.skip('Case View Page activity tab', () => {
describe('Case View Page activity tab', () => {
const caseConnectors = getCaseConnectorsMockResponse();

beforeAll(() => {
Expand All @@ -138,6 +141,10 @@ describe.skip('Case View Page activity tab', () => {
isLoading: false,
data: caseConnectors,
});
useOnUpdateFieldMock.mockReturnValue({
isLoading: false,
useOnUpdateField: jest.fn,
});
});
let appMockRender: AppMockRenderer;

Expand Down Expand Up @@ -228,6 +235,30 @@ describe.skip('Case View Page activity tab', () => {
expect(result.queryByTestId('user-actions-list')).not.toBeInTheDocument();
});

it('should show a loading when updating severity ', async () => {
useOnUpdateFieldMock.mockReturnValue({ isLoading: true, loadingKey: 'severity' });

const result = appMockRender.render(<CaseViewActivity {...caseProps} />);

expect(
result
.getByTestId('case-severity-selection')
.classList.contains('euiSuperSelectControl-isLoading')
).toBeTruthy();
});

it('should not show a loading for severity when updating tags', async () => {
useOnUpdateFieldMock.mockReturnValue({ isLoading: true, loadingKey: 'tags' });

const result = appMockRender.render(<CaseViewActivity {...caseProps} />);

expect(
result
.getByTestId('case-severity-selection')
.classList.contains('euiSuperSelectControl-isLoading')
).not.toBeTruthy();
});

it('should not render the assignees on basic license', () => {
appMockRender = createAppMockRenderer({ license: basicLicense });

Expand Down
Expand Up @@ -271,7 +271,7 @@ export const CaseViewActivity = ({
) : null}
<SeveritySidebarSelector
isDisabled={!permissions.update}
isLoading={isLoading}
isLoading={isLoading && loadingKey === 'severity'}
selectedSeverity={caseData.severity}
onSeverityChange={onUpdateSeverity}
/>
Expand Down

0 comments on commit e3da05c

Please sign in to comment.