Skip to content

Commit

Permalink
copy: render empty value placeholder in case of an error
Browse files Browse the repository at this point in the history
  • Loading branch information
janmonschke committed Mar 22, 2022
1 parent a40ab7f commit 3c38cc4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { EventFieldsData } from '../types';
import { TimelineId } from '../../../../../common/types';
import { AlertSummaryRow } from '../helpers';
import { useAlertPrevalence } from '../../../containers/alerts/use_alert_prevalence';
import { getEmptyValue } from '../../../components/empty_value';

jest.mock('../../../lib/kibana');
jest.mock('../../../containers/alerts/use_alert_prevalence', () => ({
Expand Down Expand Up @@ -75,7 +76,7 @@ describe('PrevalenceCellRenderer', () => {
});

describe('When an error was returned', () => {
test('it should return null', async () => {
test('it should return empty value placeholder', async () => {
mockUseAlertPrevalence.mockImplementation(() => ({
loading: false,
count: 123,
Expand All @@ -88,6 +89,7 @@ describe('PrevalenceCellRenderer', () => {
);
expect(container.getElementsByClassName('euiLoadingSpinner')).toHaveLength(0);
expect(screen.queryByText('123')).toBeNull();
expect(screen.queryByText(getEmptyValue())).toBeTruthy();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import React from 'react';
import { EuiLoadingSpinner } from '@elastic/eui';

import { AlertSummaryRow } from '../helpers';
import { getEmptyValue } from '../../../components/empty_value';
import { useAlertPrevalence } from '../../../containers/alerts/use_alert_prevalence';

const PrevalenceCell = React.memo<AlertSummaryRow['description']>(
Expand All @@ -23,7 +24,7 @@ const PrevalenceCell = React.memo<AlertSummaryRow['description']>(
if (loading) {
return <EuiLoadingSpinner />;
} else if (error) {
return null;
return <>{getEmptyValue()}</>;
}

return <>{count}</>;
Expand Down

0 comments on commit 3c38cc4

Please sign in to comment.