Skip to content

Commit 55953a4

Browse files
[Cloud Security] update sanity ui tests (#190050)
1 parent 853f32c commit 55953a4

File tree

4 files changed

+51
-15
lines changed

4 files changed

+51
-15
lines changed

x-pack/test/cloud_security_posture_functional/cloud_tests/benchmark_sanity.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
3434
const benchmarksRows = await benchmark.benchmarkPage.getBenchmarkTableRows();
3535
for (const row of benchmarksRows) {
3636
const benchmarkName = await benchmark.benchmarkPage.getCisNameCellData(row);
37-
const evaluated = await benchmark.benchmarkPage.getEvaluatedCellData(row);
38-
const compliance = await benchmark.benchmarkPage.getComplianceCellData(row);
39-
expect(await evaluated).to.not.contain(
40-
'Add',
37+
const isEvaluationEmpty = await benchmark.benchmarkPage.isEvaluationEmpty(row);
38+
const isComplianceEmpty = await benchmark.benchmarkPage.isComplianceEmpty(row);
39+
40+
expect(isEvaluationEmpty).to.eql(
41+
false,
4142
`The ${benchmarkName} does not have evaluated data`
4243
);
43-
expect(await compliance).to.not.contain(
44-
'No',
44+
45+
expect(isComplianceEmpty).to.eql(
46+
false,
4547
`The ${benchmarkName} does not have compliance data`
4648
);
4749
}

x-pack/test/cloud_security_posture_functional/cloud_tests/dashboard_sanity.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
7373
const findingsLinkCount = await dashboard.getFindingsLinksCount(TAB_TYPES.CLOUD);
7474
for (let i = 0; i < findingsLinkCount; i++) {
7575
const link = await dashboard.getFindingsLinkAtIndex(TAB_TYPES.CLOUD, i);
76-
// for (const link of findingsLink) {
7776
await link.click();
7877
await pageObjects.header.waitUntilLoadingHasFinished();
7978
const groupSelector = await findings.groupSelector();

x-pack/test/cloud_security_posture_functional/page_objects/benchmark_page.ts

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
ELASTIC_HTTP_VERSION_HEADER,
1111
X_ELASTIC_INTERNAL_ORIGIN_REQUEST,
1212
} from '@kbn/core-http-common';
13+
import { WebElementWrapper } from '@kbn/ftr-common-functional-ui-services';
1314
import type { FtrProviderContext } from '../ftr_provider_context';
1415

1516
export const CSP_BECNHMARK_TABLE = 'csp_benchmarks_table';
@@ -43,25 +44,50 @@ export function BenchmarkPagePageProvider({ getService, getPageObjects }: FtrPro
4344

4445
getBenchmarkTableRows: async () => {
4546
const benchmarkTable = await testSubjects.find(CSP_BECNHMARK_TABLE);
46-
return await benchmarkTable.findAllByXpath(`//tbody//tr`);
47+
const tableRows = await benchmarkTable.findAllByXpath(`//tbody//tr`);
48+
return tableRows;
4749
},
4850

49-
getCellData: async (row: any, cellDataTestSubj: string) => {
51+
getCellData: async (row: WebElementWrapper, cellDataTestSubj: string) => {
5052
const cell = await row.findByTestSubject(cellDataTestSubj);
5153
return await cell.getVisibleText();
5254
},
5355

54-
getEvaluatedCellData: async (row: any) => {
56+
getEvaluatedCellData: async (row: WebElementWrapper) => {
5557
return await benchmarkPage.getCellData(row, 'benchmark-table-column-evaluated');
5658
},
5759

58-
getComplianceCellData: async (row: any) => {
60+
getComplianceCellData: async (row: WebElementWrapper) => {
5961
return await benchmarkPage.getCellData(row, 'benchmark-table-column-compliance');
6062
},
6163

62-
getCisNameCellData: async (row: any) => {
64+
getCisNameCellData: async (row: WebElementWrapper) => {
6365
return await benchmarkPage.getCellData(row, 'benchmark-table-column-cis-name');
6466
},
67+
68+
isEvaluationEmpty: async (row: WebElementWrapper) => {
69+
try {
70+
const notEvaluated = await row.findAllByTestSubject('benchmark-not-evaluated-account', 200);
71+
return notEvaluated.length > 0;
72+
} catch (error) {
73+
if (error.name === 'StaleElementReferenceError' || error.name === 'NoSuchElementError') {
74+
return false;
75+
}
76+
throw error;
77+
}
78+
},
79+
80+
isComplianceEmpty: async (row: WebElementWrapper) => {
81+
try {
82+
const noCompliance = await row.findAllByTestSubject('benchmark-score-no-findings', 200);
83+
return noCompliance.length > 0;
84+
} catch (error) {
85+
if (error.name === 'StaleElementReferenceError' || error.name === 'NoSuchElementError') {
86+
return false;
87+
}
88+
throw error;
89+
}
90+
},
6591
};
6692

6793
const navigateToBenchnmarkPage = async (space?: string) => {

x-pack/test/cloud_security_posture_functional/page_objects/csp_dashboard_page.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,29 @@ export function CspDashboardPageProvider({ getService, getPageObjects }: FtrProv
105105
getFindingsLinks: async (tab: (typeof TAB_TYPES)[keyof typeof TAB_TYPES]) => {
106106
await dashboard.getDashoard(tab);
107107
const pageContainer = await testSubjects.find('pageContainer');
108-
return await pageContainer.findAllByXpath(`//button[contains(@class, 'euiLink')]`);
108+
return [
109+
await pageContainer.findByTestSubject('dashboard-summary-passed-findings'),
110+
await pageContainer.findByTestSubject('dashboard-summary-failed-findings'),
111+
...(await pageContainer.findAllByTestSubject('grouped-findings-evaluation-link')),
112+
...(await pageContainer.findAllByTestSubject('view-all-failed-findings')),
113+
...(await pageContainer.findAllByTestSubject('benchmark-section-bench-name')),
114+
...(await pageContainer.findAllByTestSubject('benchmark-asset-type')),
115+
...(await pageContainer.findAllByTestSubject('compliance-score-section-passed')),
116+
...(await pageContainer.findAllByTestSubject('compliance-score-section-failed')),
117+
];
109118
},
110119

111120
getFindingsLinkAtIndex: async (
112121
tab: (typeof TAB_TYPES)[keyof typeof TAB_TYPES],
113122
linkIndex = 0
114123
) => {
115124
const allLinks = await dashboard.getFindingsLinks(tab);
116-
return await allLinks[linkIndex];
125+
return allLinks[linkIndex];
117126
},
118127

119128
getFindingsLinksCount: async (tab: (typeof TAB_TYPES)[keyof typeof TAB_TYPES]) => {
120129
const allLinks = await dashboard.getFindingsLinks(tab);
121-
return await allLinks.length;
130+
return allLinks.length;
122131
},
123132

124133
getIntegrationDashboardContainer: () => testSubjects.find('dashboard-container'),

0 commit comments

Comments
 (0)