[Security Solution] Making manage_lists.cy.ts tests more robust (#171675)

This commit is contained in:
Gloria Hornero 2023-11-23 10:25:54 +01:00 committed by GitHub
parent e3e74eb8c4
commit 14bec21d8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View file

@ -6,6 +6,7 @@
*/
import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types';
import { ELASTICSEARCH_USERNAME } from '../env_var_names_constants';
export interface Exception {
field: string;
@ -61,5 +62,15 @@ export const expectedExportedExceptionList = (
exceptionListResponse: Cypress.Response<ExceptionListSchema>
): string => {
const jsonRule = exceptionListResponse.body;
return `{"_version":"${jsonRule._version}","created_at":"${jsonRule.created_at}","created_by":"system_indices_superuser","description":"${jsonRule.description}","id":"${jsonRule.id}","immutable":false,"list_id":"${jsonRule.list_id}","name":"${jsonRule.name}","namespace_type":"single","os_types":[],"tags":[],"tie_breaker_id":"${jsonRule.tie_breaker_id}","type":"${jsonRule.type}","updated_at":"${jsonRule.updated_at}","updated_by":"system_indices_superuser","version":1}\n{"exported_exception_list_count":1,"exported_exception_list_item_count":0,"missing_exception_list_item_count":0,"missing_exception_list_items":[],"missing_exception_lists":[],"missing_exception_lists_count":0}\n`;
return `{"_version":"${jsonRule._version}","created_at":"${
jsonRule.created_at
}","created_by":"${Cypress.env(ELASTICSEARCH_USERNAME)}","description":"${
jsonRule.description
}","id":"${jsonRule.id}","immutable":false,"list_id":"${jsonRule.list_id}","name":"${
jsonRule.name
}","namespace_type":"single","os_types":[],"tags":[],"tie_breaker_id":"${
jsonRule.tie_breaker_id
}","type":"${jsonRule.type}","updated_at":"${jsonRule.updated_at}","updated_by":"${Cypress.env(
ELASTICSEARCH_USERNAME
)}","version":1}\n{"exported_exception_list_count":1,"exported_exception_list_item_count":0,"missing_exception_list_item_count":0,"missing_exception_list_items":[],"missing_exception_lists":[],"missing_exception_lists_count":0}\n`;
};

View file

@ -5,7 +5,12 @@
* 2.0.
*/
import { INPUT_FILE, TOASTER, TOASTER_BODY } from '../screens/alerts_detection_rules';
import {
INPUT_FILE,
TOASTER,
TOASTER_BODY,
TOASTER_CLOSE_ICON,
} from '../screens/alerts_detection_rules';
import {
EXCEPTIONS_TABLE,
EXCEPTIONS_TABLE_SEARCH,
@ -70,6 +75,12 @@ export const exportExceptionList = (listId: string) => {
.click();
cy.get(EXCEPTIONS_TABLE_EXPORT_MODAL_BTN).first().click();
cy.get(EXCEPTIONS_TABLE_EXPIRED_EXCEPTION_ITEMS_MODAL_CONFIRM_BTN).first().click();
cy.root().then(($page) => {
const element = $page.find(TOASTER_CLOSE_ICON);
if (element.length > 0) {
closeErrorToast();
}
});
};
export const assertNumberLinkedRules = (listId: string, numberOfRulesAsString: string) => {