Skip to content

Commit

Permalink
[Cloud Security] update sanity ui tests (elastic#190050)
Browse files Browse the repository at this point in the history
  • Loading branch information
gurevichdmitry authored Aug 8, 2024
1 parent 853f32c commit 55953a4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const benchmarksRows = await benchmark.benchmarkPage.getBenchmarkTableRows();
for (const row of benchmarksRows) {
const benchmarkName = await benchmark.benchmarkPage.getCisNameCellData(row);
const evaluated = await benchmark.benchmarkPage.getEvaluatedCellData(row);
const compliance = await benchmark.benchmarkPage.getComplianceCellData(row);
expect(await evaluated).to.not.contain(
'Add',
const isEvaluationEmpty = await benchmark.benchmarkPage.isEvaluationEmpty(row);
const isComplianceEmpty = await benchmark.benchmarkPage.isComplianceEmpty(row);

expect(isEvaluationEmpty).to.eql(
false,
`The ${benchmarkName} does not have evaluated data`
);
expect(await compliance).to.not.contain(
'No',

expect(isComplianceEmpty).to.eql(
false,
`The ${benchmarkName} does not have compliance data`
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const findingsLinkCount = await dashboard.getFindingsLinksCount(TAB_TYPES.CLOUD);
for (let i = 0; i < findingsLinkCount; i++) {
const link = await dashboard.getFindingsLinkAtIndex(TAB_TYPES.CLOUD, i);
// for (const link of findingsLink) {
await link.click();
await pageObjects.header.waitUntilLoadingHasFinished();
const groupSelector = await findings.groupSelector();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ELASTIC_HTTP_VERSION_HEADER,
X_ELASTIC_INTERNAL_ORIGIN_REQUEST,
} from '@kbn/core-http-common';
import { WebElementWrapper } from '@kbn/ftr-common-functional-ui-services';
import type { FtrProviderContext } from '../ftr_provider_context';

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

getBenchmarkTableRows: async () => {
const benchmarkTable = await testSubjects.find(CSP_BECNHMARK_TABLE);
return await benchmarkTable.findAllByXpath(`//tbody//tr`);
const tableRows = await benchmarkTable.findAllByXpath(`//tbody//tr`);
return tableRows;
},

getCellData: async (row: any, cellDataTestSubj: string) => {
getCellData: async (row: WebElementWrapper, cellDataTestSubj: string) => {
const cell = await row.findByTestSubject(cellDataTestSubj);
return await cell.getVisibleText();
},

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

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

getCisNameCellData: async (row: any) => {
getCisNameCellData: async (row: WebElementWrapper) => {
return await benchmarkPage.getCellData(row, 'benchmark-table-column-cis-name');
},

isEvaluationEmpty: async (row: WebElementWrapper) => {
try {
const notEvaluated = await row.findAllByTestSubject('benchmark-not-evaluated-account', 200);
return notEvaluated.length > 0;
} catch (error) {
if (error.name === 'StaleElementReferenceError' || error.name === 'NoSuchElementError') {
return false;
}
throw error;
}
},

isComplianceEmpty: async (row: WebElementWrapper) => {
try {
const noCompliance = await row.findAllByTestSubject('benchmark-score-no-findings', 200);
return noCompliance.length > 0;
} catch (error) {
if (error.name === 'StaleElementReferenceError' || error.name === 'NoSuchElementError') {
return false;
}
throw error;
}
},
};

const navigateToBenchnmarkPage = async (space?: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,29 @@ export function CspDashboardPageProvider({ getService, getPageObjects }: FtrProv
getFindingsLinks: async (tab: (typeof TAB_TYPES)[keyof typeof TAB_TYPES]) => {
await dashboard.getDashoard(tab);
const pageContainer = await testSubjects.find('pageContainer');
return await pageContainer.findAllByXpath(`//button[contains(@class, 'euiLink')]`);
return [
await pageContainer.findByTestSubject('dashboard-summary-passed-findings'),
await pageContainer.findByTestSubject('dashboard-summary-failed-findings'),
...(await pageContainer.findAllByTestSubject('grouped-findings-evaluation-link')),
...(await pageContainer.findAllByTestSubject('view-all-failed-findings')),
...(await pageContainer.findAllByTestSubject('benchmark-section-bench-name')),
...(await pageContainer.findAllByTestSubject('benchmark-asset-type')),
...(await pageContainer.findAllByTestSubject('compliance-score-section-passed')),
...(await pageContainer.findAllByTestSubject('compliance-score-section-failed')),
];
},

getFindingsLinkAtIndex: async (
tab: (typeof TAB_TYPES)[keyof typeof TAB_TYPES],
linkIndex = 0
) => {
const allLinks = await dashboard.getFindingsLinks(tab);
return await allLinks[linkIndex];
return allLinks[linkIndex];
},

getFindingsLinksCount: async (tab: (typeof TAB_TYPES)[keyof typeof TAB_TYPES]) => {
const allLinks = await dashboard.getFindingsLinks(tab);
return await allLinks.length;
return allLinks.length;
},

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

0 comments on commit 55953a4

Please sign in to comment.