[Cloud Security] Add test subjects for controls used in UI Sanity tests (#189510)

This commit is contained in:
Dmitry Gurevich 2024-07-31 14:03:52 +03:00 committed by GitHub
parent f52275cd1d
commit c0b60fef4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 48 additions and 11 deletions

View file

@ -38,6 +38,8 @@ import {
import { useKibana } from '../../common/hooks/use_kibana';
export const ERROR_STATE_TEST_SUBJECT = 'benchmark_page_error';
export const EMPTY_EVALUATION_TEST_SUBJECT = 'benchmark-not-evaluated-account';
export const EMPTY_SCORE_TEST_SUBJECT = 'benchmark-score-no-findings';
interface BenchmarksTableProps
extends Pick<EuiBasicTableProps<Benchmark>, 'loading' | 'error' | 'noItemsMessage' | 'sorting'>,
@ -170,7 +172,12 @@ const getBenchmarkTableColumns = (
if (benchmarkEvaluation === 0) {
return (
<EuiButtonEmpty href={integrationLink} iconType="plusInCircle" flush="left">
<EuiButtonEmpty
data-test-subj={EMPTY_EVALUATION_TEST_SUBJECT}
href={integrationLink}
iconType="plusInCircle"
flush="left"
>
{i18n.translate('xpack.csp.benchmarks.benchmarksTable.addIntegrationTitle', {
defaultMessage: 'Add {resourceCountLabel}',
values: { resourceCountLabel },
@ -215,10 +222,12 @@ const getBenchmarkTableColumns = (
);
return (
<FormattedMessage
id="xpack.csp.benchmarks.benchmarksTable.noFindingsScore"
defaultMessage="No Findings"
/>
<span data-test-subj={EMPTY_SCORE_TEST_SUBJECT}>
<FormattedMessage
id="xpack.csp.benchmarks.benchmarksTable.noFindingsScore"
defaultMessage="No Findings"
/>
</span>
);
},
},

View file

@ -26,6 +26,7 @@ import {
type EuiTextProps,
EuiToolTip,
EuiToolTipProps,
type CommonProps,
} from '@elastic/eui';
import { FormattedDate, FormattedTime } from '@kbn/i18n-react';
import moment from 'moment';
@ -50,13 +51,14 @@ const CounterButtonLink = ({
text,
count,
color,
'data-test-subj': dataTestSubj,
onClick,
}: {
count: number;
text: string;
color: EuiTextProps['color'];
onClick: EuiLinkButtonProps['onClick'];
}) => {
} & Pick<CommonProps, 'data-test-subj'>) => {
const { euiTheme } = useEuiTheme();
return (
@ -74,6 +76,7 @@ const CounterButtonLink = ({
<EuiLink
color="text"
onClick={onClick}
data-test-subj={dataTestSubj}
css={css`
display: flex;
&:hover {
@ -148,6 +151,7 @@ const PercentageLabels = ({
text="Passed Findings"
count={stats.totalPassed}
color={statusColors.passed}
data-test-subj="dashboard-summary-passed-findings"
onClick={() => onEvalCounterClick(RULE_PASSED)}
/>
</EuiFlexItem>
@ -156,6 +160,7 @@ const PercentageLabels = ({
text="Failed Findings"
count={stats.totalFailed}
color={statusColors.failed}
data-test-subj="dashboard-summary-failed-findings"
onClick={() => onEvalCounterClick(RULE_FAILED)}
/>
</EuiFlexItem>
@ -257,7 +262,12 @@ const CounterLink = ({
return (
<EuiToolTip content={tooltipContent}>
<EuiLink color="text" onClick={onClick} css={{ display: 'flex' }}>
<EuiLink
data-test-subj={`compliance-score-section-${text}`}
color="text"
onClick={onClick}
css={{ display: 'flex' }}
>
<EuiText color={color} style={{ fontWeight: euiTheme.font.weight.medium }} size="s">
<CompactFormattedNumber number={count} abbreviateAbove={999} />
&nbsp;

View file

@ -58,7 +58,12 @@ export const RisksTable = ({
defaultMessage: 'CIS Section',
}),
render: (name: GroupedFindingsEvaluation['name']) => (
<EuiLink onClick={() => onCellClick(name)} className="eui-textTruncate" color="text">
<EuiLink
data-test-subj="grouped-findings-evaluation-link"
onClick={() => onCellClick(name)}
className="eui-textTruncate"
color="text"
>
{name}
</EuiLink>
),
@ -106,7 +111,11 @@ export const RisksTable = ({
</EuiFlexItem>
<EuiFlexItem grow={false}>
<div>
<EuiButtonEmpty onClick={onViewAllClick} iconType="search">
<EuiButtonEmpty
data-test-subj="view-all-failed-findings"
onClick={onViewAllClick}
iconType="search"
>
{viewAllButtonTitle}
</EuiButtonEmpty>
</div>

View file

@ -163,14 +163,22 @@ export const BenchmarkDetailsBox = ({ benchmark }: { benchmark: BenchmarkData })
</EuiText>
}
>
<EuiLink onClick={benchmarkInfo.handleClick} color="text">
<EuiLink
onClick={benchmarkInfo.handleClick}
color="text"
data-test-subj="benchmark-section-bench-name"
>
<EuiTitle css={{ fontSize: 20 }}>
<h5>{benchmarkInfo.name}</h5>
</EuiTitle>
</EuiLink>
</EuiToolTip>
<EuiLink onClick={benchmarkInfo.handleClick} color="text">
<EuiLink
data-test-subj="benchmark-asset-type"
onClick={benchmarkInfo.handleClick}
color="text"
>
<EuiText size="xs">{benchmarkInfo.assetType}</EuiText>
</EuiLink>
</EuiFlexItem>

View file

@ -135,6 +135,7 @@ export const SummarySection = ({
button: (
<EuiButtonEmpty
iconType="search"
data-test-subj="dashboard-view-all-resources"
onClick={() => {
navToFindings(getPolicyTemplateQuery(dashboardType), [
FINDINGS_GROUPING_OPTIONS.RESOURCE_NAME,