Skip to content

Commit

Permalink
[Security Solution] - Update exceptions item UI (#135255)
Browse files Browse the repository at this point in the history
## Summary

Addresses #135254
  • Loading branch information
yctercero authored Jul 8, 2022
1 parent 6b018f7 commit 0a0b0a1
Show file tree
Hide file tree
Showing 25 changed files with 1,051 additions and 1,823 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { addExceptionFromFirstAlert, goToClosedAlerts, goToOpenedAlerts } from '
import { createCustomRuleEnabled } from '../../tasks/api_calls/rules';
import { goToRuleDetails } from '../../tasks/alerts_detection_rules';
import { waitForAlertsToPopulate } from '../../tasks/create_new_rule';
import { esArchiverLoad, esArchiverUnload } from '../../tasks/es_archiver';
import { esArchiverLoad, esArchiverUnload, esArchiverResetKibana } from '../../tasks/es_archiver';
import { login, visitWithoutDateRange } from '../../tasks/login';
import {
addsException,
Expand All @@ -26,15 +26,15 @@ import {
} from '../../tasks/rule_details';

import { DETECTIONS_RULE_MANAGEMENT_URL } from '../../urls/navigation';
import { cleanKibana, deleteAlertsAndRules } from '../../tasks/common';
import { deleteAlertsAndRules } from '../../tasks/common';

describe('Adds rule exception', () => {
const NUMBER_OF_AUDITBEAT_EXCEPTIONS_ALERTS = '1 alert';

before(() => {
cleanKibana();
login();
esArchiverResetKibana();
esArchiverLoad('exceptions');
login();
});

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import { createCustomRule } from '../../tasks/api_calls/rules';
import { goToRuleDetails } from '../../tasks/alerts_detection_rules';
import { esArchiverLoad, esArchiverResetKibana, esArchiverUnload } from '../../tasks/es_archiver';
import { login, visitWithoutDateRange } from '../../tasks/login';
import { openExceptionFlyoutFromRuleSettings, goToExceptionsTab } from '../../tasks/rule_details';
import {
openExceptionFlyoutFromRuleSettings,
goToExceptionsTab,
editException,
} from '../../tasks/rule_details';
import {
addExceptionEntryFieldMatchAnyValue,
addExceptionEntryFieldValue,
Expand All @@ -32,7 +36,6 @@ import {
EXCEPTION_ITEM_CONTAINER,
ADD_EXCEPTIONS_BTN,
EXCEPTION_FIELD_LIST,
EDIT_EXCEPTIONS_BTN,
EXCEPTION_EDIT_FLYOUT_SAVE_BTN,
EXCEPTION_FLYOUT_VERSION_CONFLICT,
EXCEPTION_FLYOUT_LIST_DELETED_ERROR,
Expand Down Expand Up @@ -302,8 +305,7 @@ describe('Exceptions flyout', () => {

context('When updating an item with version conflict', () => {
it('Displays version conflict error', () => {
cy.get(EDIT_EXCEPTIONS_BTN).should('be.visible');
cy.get(EDIT_EXCEPTIONS_BTN).click({ force: true });
editException();

// update exception item via api
updateExceptionListItem('simple_list_item', {
Expand Down Expand Up @@ -334,8 +336,7 @@ describe('Exceptions flyout', () => {

context('When updating an item for a list that has since been deleted', () => {
it('Displays missing exception list error', () => {
cy.get(EDIT_EXCEPTIONS_BTN).should('be.visible');
cy.get(EDIT_EXCEPTIONS_BTN).click({ force: true });
editException();

// delete exception list via api
deleteExceptionList(getExceptionList().list_id, getExceptionList().namespace_type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* 2.0.
*/

export const EDIT_EXCEPTIONS_BTN = '[data-test-subj="exceptionsViewerEditBtn"]';

export const ADD_EXCEPTIONS_BTN = '[data-test-subj="exceptionsHeaderAddExceptionBtn"]';

export const CLOSE_ALERTS_CHECKBOX =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ export const RISK_SCORE_OVERRIDE_DETAILS = 'Risk score override';

export const REFERENCE_URLS_DETAILS = 'Reference URLs';

export const REMOVE_EXCEPTION_BTN = '[data-test-subj="exceptionsViewerDeleteBtn"]';
export const EXCEPTION_ITEM_ACTIONS_BUTTON =
'button[data-test-subj="exceptionItemCardHeader-actionButton"]';

export const REMOVE_EXCEPTION_BTN = '[data-test-subj="exceptionItemCardHeader-actionItem-delete"]';

export const EDIT_EXCEPTION_BTN = '[data-test-subj="exceptionItemCardHeader-actionItem-edit"]';

export const RULE_SWITCH = '[data-test-subj="ruleSwitch"]';

Expand Down
10 changes: 10 additions & 0 deletions x-pack/plugins/security_solution/cypress/tasks/rule_details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import {
INDEX_PATTERNS_DETAILS,
DETAILS_TITLE,
DETAILS_DESCRIPTION,
EXCEPTION_ITEM_ACTIONS_BUTTON,
EDIT_EXCEPTION_BTN,
} from '../screens/rule_details';
import { addsFields, closeFieldsBrowser, filterFieldsBrowser } from './fields_browser';

Expand Down Expand Up @@ -96,7 +98,15 @@ export const goToExceptionsTab = () => {
.should('be.visible');
};

export const editException = () => {
cy.get(EXCEPTION_ITEM_ACTIONS_BUTTON).click();

cy.get(EDIT_EXCEPTION_BTN).click();
};

export const removeException = () => {
cy.get(EXCEPTION_ITEM_ACTIONS_BUTTON).click();

cy.get(REMOVE_EXCEPTION_BTN).click();
};

Expand Down

This file was deleted.

Loading

0 comments on commit 0a0b0a1

Please sign in to comment.