mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Improve risk score formatting consistency (#145235)
issue: https://github.com/elastic/kibana/issues/145091 ## Summary Update the User and Host page to round risk scores everywhere.
This commit is contained in:
parent
ee5b3613d2
commit
f49746a0d8
5 changed files with 32 additions and 5 deletions
|
@ -38,7 +38,7 @@ describe('risk tab', () => {
|
|||
it('renders the table', () => {
|
||||
kqlSearch('host.name: "siem-kibana" {enter}');
|
||||
cy.get(HOST_BY_RISK_TABLE_CELL).eq(3).should('have.text', 'siem-kibana');
|
||||
cy.get(HOST_BY_RISK_TABLE_CELL).eq(4).should('have.text', '21.00');
|
||||
cy.get(HOST_BY_RISK_TABLE_CELL).eq(4).should('have.text', '21');
|
||||
cy.get(HOST_BY_RISK_TABLE_CELL).eq(5).should('have.text', 'Low');
|
||||
clearSearchBar();
|
||||
});
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { getHostRiskScoreColumns } from './columns';
|
||||
import { TestProviders } from '../../../common/mock';
|
||||
import type { HostRiskScoreColumns } from '.';
|
||||
|
||||
describe('getHostRiskScoreColumns', () => {
|
||||
test('should render host score rounded', () => {
|
||||
const columns: HostRiskScoreColumns = getHostRiskScoreColumns({
|
||||
dispatchSeverityUpdate: jest.fn(),
|
||||
});
|
||||
|
||||
const riskScore = 10.11111111;
|
||||
const riskScoreColumn = columns[1];
|
||||
const renderedColumn = riskScoreColumn.render!(riskScore, null);
|
||||
|
||||
const { queryByTestId } = render(<TestProviders>{renderedColumn}</TestProviders>);
|
||||
|
||||
expect(queryByTestId('risk-score-truncate')).toHaveTextContent('10');
|
||||
});
|
||||
});
|
|
@ -77,7 +77,7 @@ export const getHostRiskScoreColumns = ({
|
|||
if (riskScore != null) {
|
||||
return (
|
||||
<span data-test-subj="risk-score-truncate" title={`${riskScore}`}>
|
||||
{riskScore.toFixed(2)}
|
||||
{Math.round(riskScore)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ describe('getUserRiskScoreColumns', () => {
|
|||
expect(queryByTestId('users-link-anchor')).toHaveTextContent(username);
|
||||
});
|
||||
|
||||
test('should render user score truncated', () => {
|
||||
test('should render user score rounded', () => {
|
||||
const columns: UserRiskScoreColumns = getUserRiskScoreColumns(defaultProps);
|
||||
|
||||
const riskScore = 10.11111111;
|
||||
|
@ -50,6 +50,6 @@ describe('getUserRiskScoreColumns', () => {
|
|||
|
||||
const { queryByTestId } = render(<TestProviders>{renderedColumn}</TestProviders>);
|
||||
|
||||
expect(queryByTestId('risk-score-truncate')).toHaveTextContent('10.11');
|
||||
expect(queryByTestId('risk-score-truncate')).toHaveTextContent('10');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -78,7 +78,7 @@ export const getUserRiskScoreColumns = ({
|
|||
if (riskScore != null) {
|
||||
return (
|
||||
<span data-test-subj="risk-score-truncate" title={`${riskScore}`}>
|
||||
{riskScore.toFixed(2)}
|
||||
{Math.round(riskScore)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue