-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into adding-api-tests-for-modules-jobs-exists-end…
…point
- Loading branch information
Showing
40 changed files
with
683 additions
and
1,088 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 0 additions & 78 deletions
78
...ty_solution/public/common/components/event_details/cti_details/host_risk_summary.test.tsx
This file was deleted.
Oops, something went wrong.
96 changes: 96 additions & 0 deletions
96
...ecurity_solution/public/common/components/event_details/cti_details/risk_summary.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* 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 { TestProviders } from '../../../mock'; | ||
import type { RiskEntity } from './risk_summary'; | ||
import * as i18n from './translations'; | ||
import { RiskSummary } from './risk_summary'; | ||
import { RiskScoreEntity, RiskSeverity } from '../../../../../common/search_strategy'; | ||
import { getEmptyValue } from '../../empty_value'; | ||
|
||
describe.each([RiskScoreEntity.host, RiskScoreEntity.user])( | ||
'RiskSummary entityType: %s', | ||
(riskEntity) => { | ||
it(`renders ${riskEntity} risk data`, () => { | ||
const riskSeverity = RiskSeverity.low; | ||
const risk = { | ||
loading: false, | ||
isModuleEnabled: true, | ||
result: [ | ||
{ | ||
'@timestamp': '1641902481', | ||
[riskEntity === RiskScoreEntity.host ? 'host' : 'user']: { | ||
name: 'test-host-name', | ||
risk: { | ||
multipliers: [], | ||
calculated_score_norm: 9999, | ||
calculated_level: riskSeverity, | ||
rule_risks: [], | ||
}, | ||
}, | ||
}, | ||
], // as unknown as HostRiskScore[] | UserRiskScore[], | ||
} as unknown as RiskEntity['risk']; | ||
|
||
const props = { | ||
riskEntity, | ||
risk, | ||
} as RiskEntity; | ||
|
||
const { getByText } = render( | ||
<TestProviders> | ||
<RiskSummary {...props} /> | ||
</TestProviders> | ||
); | ||
|
||
expect(getByText(riskSeverity)).toBeInTheDocument(); | ||
expect(getByText(i18n.RISK_DATA_TITLE(riskEntity))).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders spinner when loading', () => { | ||
const risk = { | ||
loading: true, | ||
isModuleEnabled: true, | ||
result: [], | ||
}; | ||
|
||
const props = { | ||
riskEntity, | ||
risk, | ||
} as RiskEntity; | ||
const { getByTestId } = render( | ||
<TestProviders> | ||
<RiskSummary {...props} /> | ||
</TestProviders> | ||
); | ||
|
||
expect(getByTestId('loading')).toBeInTheDocument(); | ||
}); | ||
|
||
it(`renders empty value when there is no ${riskEntity} data`, () => { | ||
const risk = { | ||
loading: false, | ||
isModuleEnabled: true, | ||
result: [], | ||
}; | ||
const props = { | ||
riskEntity, | ||
risk, | ||
} as RiskEntity; | ||
const { getByText } = render( | ||
<TestProviders> | ||
<RiskSummary {...props} /> | ||
</TestProviders> | ||
); | ||
|
||
expect(getByText(getEmptyValue())).toBeInTheDocument(); | ||
}); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.