Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,31 @@ describe('HostAlertsTable', () => {
},
]);
});

it('should render cellActions when count is bigger than zero', () => {
mockUseHostAlertsItemsReturn({
items: [parsedVulnerableHostsAlertsResult[0]],
});
const { getAllByTestId } = renderComponent();

expect(getAllByTestId('cellActions-renderContent-host.name').length).toBe(5);
});

it('should not render cellActions when count is zero', () => {
mockUseHostAlertsItemsReturn({
items: [
{
hostName: 'Host-342m5gl1g2',
totalAlerts: 100,
critical: 0,
high: 0,
low: 0,
medium: 0,
},
],
});
const { getAllByTestId } = renderComponent();

expect(getAllByTestId('cellActions-renderContent-host.name').length).toBe(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -179,30 +179,33 @@ const getTableColumns: GetTableColumns = (handleClick) => [
name: i18n.STATUS_CRITICAL_LABEL,
render: (count: number, { hostName }) => (
<EuiHealth data-test-subj="hostSeverityAlertsTable-critical" color={SEVERITY_COLOR.critical}>
<SecurityCellActions
field={{
name: 'host.name',
value: hostName,
type: 'keyword',
aggregatable: true,
}}
mode={CellActionsMode.HOVER_RIGHT}
triggerId={SecurityCellActionsTrigger.ALERTS_COUNT}
metadata={{
andFilters: [
{ field: 'kibana.alert.severity', value: 'critical' },
{ field: 'kibana.alert.workflow_status', value: 'open' },
],
}}
>
<EuiLink
data-test-subj="hostSeverityAlertsTable-criticalLink"
disabled={count === 0}
onClick={() => handleClick({ hostName, severity: 'critical' })}
{count > 0 ? (
<SecurityCellActions
field={{
name: 'host.name',
value: hostName,
type: 'keyword',
aggregatable: true,
}}
mode={CellActionsMode.HOVER_RIGHT}
triggerId={SecurityCellActionsTrigger.ALERTS_COUNT}
metadata={{
andFilters: [
{ field: 'kibana.alert.severity', value: 'critical' },
{ field: 'kibana.alert.workflow_status', value: 'open' },
],
}}
>
<FormattedCount count={count} />
</EuiLink>
</SecurityCellActions>
<EuiLink
data-test-subj="hostSeverityAlertsTable-criticalLink"
onClick={() => handleClick({ hostName, severity: 'critical' })}
>
<FormattedCount count={count} />
</EuiLink>
</SecurityCellActions>
) : (
<FormattedCount count={count} />
)}
</EuiHealth>
),
},
Expand All @@ -211,29 +214,30 @@ const getTableColumns: GetTableColumns = (handleClick) => [
name: i18n.STATUS_HIGH_LABEL,
render: (count: number, { hostName }) => (
<EuiHealth data-test-subj="hostSeverityAlertsTable-high" color={SEVERITY_COLOR.high}>
<SecurityCellActions
field={{
name: 'host.name',
value: hostName,
type: 'keyword',
aggregatable: true,
}}
mode={CellActionsMode.HOVER_RIGHT}
triggerId={SecurityCellActionsTrigger.ALERTS_COUNT}
metadata={{
andFilters: [
{ field: 'kibana.alert.severity', value: 'high' },
{ field: 'kibana.alert.workflow_status', value: 'open' },
],
}}
>
<EuiLink
disabled={count === 0}
onClick={() => handleClick({ hostName, severity: 'high' })}
{count > 0 ? (
<SecurityCellActions
field={{
name: 'host.name',
value: hostName,
type: 'keyword',
aggregatable: true,
}}
mode={CellActionsMode.HOVER_RIGHT}
triggerId={SecurityCellActionsTrigger.ALERTS_COUNT}
metadata={{
andFilters: [
{ field: 'kibana.alert.severity', value: 'high' },
{ field: 'kibana.alert.workflow_status', value: 'open' },
],
}}
>
<FormattedCount count={count} />
</EuiLink>
</SecurityCellActions>
<EuiLink onClick={() => handleClick({ hostName, severity: 'high' })}>
<FormattedCount count={count} />
</EuiLink>
</SecurityCellActions>
) : (
<FormattedCount count={count} />
)}
</EuiHealth>
),
},
Expand All @@ -242,29 +246,30 @@ const getTableColumns: GetTableColumns = (handleClick) => [
name: i18n.STATUS_MEDIUM_LABEL,
render: (count: number, { hostName }) => (
<EuiHealth data-test-subj="hostSeverityAlertsTable-medium" color={SEVERITY_COLOR.medium}>
<SecurityCellActions
field={{
name: 'host.name',
value: hostName,
type: 'keyword',
aggregatable: true,
}}
mode={CellActionsMode.HOVER_RIGHT}
triggerId={SecurityCellActionsTrigger.ALERTS_COUNT}
metadata={{
andFilters: [
{ field: 'kibana.alert.severity', value: 'medium' },
{ field: 'kibana.alert.workflow_status', value: 'open' },
],
}}
>
<EuiLink
disabled={count === 0}
onClick={() => handleClick({ hostName, severity: 'medium' })}
{count > 0 ? (
<SecurityCellActions
field={{
name: 'host.name',
value: hostName,
type: 'keyword',
aggregatable: true,
}}
mode={CellActionsMode.HOVER_RIGHT}
triggerId={SecurityCellActionsTrigger.ALERTS_COUNT}
metadata={{
andFilters: [
{ field: 'kibana.alert.severity', value: 'medium' },
{ field: 'kibana.alert.workflow_status', value: 'open' },
],
}}
>
<FormattedCount count={count} />
</EuiLink>
</SecurityCellActions>
<EuiLink onClick={() => handleClick({ hostName, severity: 'medium' })}>
<FormattedCount count={count} />
</EuiLink>
</SecurityCellActions>
) : (
<FormattedCount count={count} />
)}
</EuiHealth>
),
},
Expand All @@ -273,29 +278,30 @@ const getTableColumns: GetTableColumns = (handleClick) => [
name: i18n.STATUS_LOW_LABEL,
render: (count: number, { hostName }) => (
<EuiHealth data-test-subj="hostSeverityAlertsTable-low" color={SEVERITY_COLOR.low}>
<SecurityCellActions
field={{
name: 'host.name',
value: hostName,
type: 'keyword',
aggregatable: true,
}}
mode={CellActionsMode.HOVER_RIGHT}
triggerId={SecurityCellActionsTrigger.ALERTS_COUNT}
metadata={{
andFilters: [
{ field: 'kibana.alert.severity', value: 'low' },
{ field: 'kibana.alert.workflow_status', value: 'open' },
],
}}
>
<EuiLink
disabled={count === 0}
onClick={() => handleClick({ hostName, severity: 'low' })}
{count > 0 ? (
<SecurityCellActions
field={{
name: 'host.name',
value: hostName,
type: 'keyword',
aggregatable: true,
}}
mode={CellActionsMode.HOVER_RIGHT}
triggerId={SecurityCellActionsTrigger.ALERTS_COUNT}
metadata={{
andFilters: [
{ field: 'kibana.alert.severity', value: 'low' },
{ field: 'kibana.alert.workflow_status', value: 'open' },
],
}}
>
<FormattedCount count={count} />
</EuiLink>
</SecurityCellActions>
<EuiLink onClick={() => handleClick({ hostName, severity: 'low' })}>
<FormattedCount count={count} />
</EuiLink>
</SecurityCellActions>
) : (
<FormattedCount count={count} />
)}
</EuiHealth>
),
},
Expand Down
Loading