diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/expandable_flyout/alert_details_right_panel.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/expandable_flyout/alert_details_right_panel.cy.ts index 950d804ae352c..ed4476bcfe450 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/expandable_flyout/alert_details_right_panel.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/expandable_flyout/alert_details_right_panel.cy.ts @@ -8,20 +8,11 @@ import { upperFirst } from 'lodash'; import { - DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_CREATE_BUTTON, - DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_DESCRIPTION_INPUT, - DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_NAME_INPUT, EXISTING_CASE_SELECT_BUTTON, VIEW_CASE_TOASTER_LINK, } from '../../../../screens/expandable_flyout/common'; -import { - createNewCaseFromCases, - expandFirstAlertExpandableFlyout, - navigateToAlertsPage, - navigateToCasesPage, -} from '../../../../tasks/expandable_flyout/common'; -import { ALERT_CHECKBOX } from '../../../../screens/alerts'; -import { CASE_DETAILS_PAGE_TITLE } from '../../../../screens/case_details'; +import { expandFirstAlertExpandableFlyout } from '../../../../tasks/expandable_flyout/common'; +import { ALERT_CHECKBOX, EMPTY_ALERT_TABLE } from '../../../../screens/alerts'; import { DOCUMENT_DETAILS_FLYOUT_COLLAPSE_DETAILS_BUTTON, DOCUMENT_DETAILS_FLYOUT_EXPAND_DETAILS_BUTTON, @@ -51,6 +42,7 @@ import { import { collapseDocumentDetailsExpandableFlyoutLeftSection, expandDocumentDetailsExpandableFlyoutLeftSection, + fillOutFormToCreateNewCase, openJsonTab, openTableTab, openTakeActionButton, @@ -65,8 +57,7 @@ import { getNewRule } from '../../../../objects/rule'; import { ALERTS_URL } from '../../../../urls/navigation'; import { waitForAlertsToPopulate } from '../../../../tasks/create_new_rule'; -// FLAKY: https://github.com/elastic/kibana/issues/168317 -describe.skip('Alert details expandable flyout right panel', () => { +describe('Alert details expandable flyout right panel', { tags: ['@ess', '@serverless'] }, () => { const rule = getNewRule(); beforeEach(() => { @@ -77,14 +68,14 @@ describe.skip('Alert details expandable flyout right panel', () => { waitForAlertsToPopulate(); }); - it('should display header and footer basics', { tags: ['@ess', '@serverless'] }, () => { + it('should display header and footer basics', () => { expandFirstAlertExpandableFlyout(); - cy.get(DOCUMENT_DETAILS_FLYOUT_HEADER_TITLE).should('be.visible').and('have.text', rule.name); + cy.get(DOCUMENT_DETAILS_FLYOUT_HEADER_TITLE).should('have.text', rule.name); - cy.get(DOCUMENT_DETAILS_FLYOUT_HEADER_STATUS).should('be.visible'); + cy.get(DOCUMENT_DETAILS_FLYOUT_HEADER_STATUS).should('have.text', 'open'); - cy.get(DOCUMENT_DETAILS_FLYOUT_HEADER_RISK_SCORE).should('be.visible'); + cy.get(DOCUMENT_DETAILS_FLYOUT_HEADER_RISK_SCORE).should('have.text', 'Risk score:'); cy.get(DOCUMENT_DETAILS_FLYOUT_HEADER_RISK_SCORE_VALUE) .should('be.visible') .and('have.text', rule.risk_score); @@ -95,72 +86,65 @@ describe.skip('Alert details expandable flyout right panel', () => { cy.log('Verify all 3 tabs are visible'); - cy.get(DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB).should('be.visible').and('have.text', 'Overview'); - cy.get(DOCUMENT_DETAILS_FLYOUT_TABLE_TAB).should('be.visible').and('have.text', 'Table'); - cy.get(DOCUMENT_DETAILS_FLYOUT_JSON_TAB).should('be.visible').and('have.text', 'JSON'); + cy.get(DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB) + .should('have.text', 'Overview') + .and('have.class', 'euiTab-isSelected'); + cy.get(DOCUMENT_DETAILS_FLYOUT_TABLE_TAB) + .should('have.text', 'Table') + .and('not.have.class', 'euiTab-isSelected'); + cy.get(DOCUMENT_DETAILS_FLYOUT_JSON_TAB) + .should('have.text', 'JSON') + .and('not.have.class', 'euiTab-isSelected'); cy.log('Verify the expand/collapse button is visible and functionality works'); expandDocumentDetailsExpandableFlyoutLeftSection(); - cy.get(DOCUMENT_DETAILS_FLYOUT_COLLAPSE_DETAILS_BUTTON) - .should('be.visible') - .and('have.text', 'Collapse details'); + cy.get(DOCUMENT_DETAILS_FLYOUT_COLLAPSE_DETAILS_BUTTON).should('have.text', 'Collapse details'); collapseDocumentDetailsExpandableFlyoutLeftSection(); - cy.get(DOCUMENT_DETAILS_FLYOUT_EXPAND_DETAILS_BUTTON) - .should('be.visible') - .and('have.text', 'Expand details'); + cy.get(DOCUMENT_DETAILS_FLYOUT_EXPAND_DETAILS_BUTTON).should('have.text', 'Expand details'); cy.log('Verify the take action button is visible on all tabs'); - cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER).scrollIntoView(); cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER).should('be.visible'); cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_TAKE_ACTION_BUTTON).should('be.visible'); openTableTab(); - cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER).scrollIntoView(); + cy.get(DOCUMENT_DETAILS_FLYOUT_TABLE_TAB).should('have.class', 'euiTab-isSelected'); cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER).should('be.visible'); cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_TAKE_ACTION_BUTTON).should('be.visible'); openJsonTab(); - cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER).scrollIntoView(); + cy.get(DOCUMENT_DETAILS_FLYOUT_JSON_TAB).should('have.class', 'euiTab-isSelected'); cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER).should('be.visible'); cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_TAKE_ACTION_BUTTON).should('be.visible'); }); // TODO this will change when add to existing case is improved // https://github.com/elastic/security-team/issues/6298 - it('should add to existing case', { tags: ['@ess', '@serverless'] }, () => { - navigateToCasesPage(); - createNewCaseFromCases(); - - cy.get(CASE_DETAILS_PAGE_TITLE).should('be.visible').and('have.text', 'case'); - navigateToAlertsPage(); + it('should add to existing case', () => { expandFirstAlertExpandableFlyout(); + openTakeActionButtonAndSelectItem(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE); + fillOutFormToCreateNewCase(); openTakeActionButtonAndSelectItem(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_EXISTING_CASE); cy.get(EXISTING_CASE_SELECT_BUTTON).should('be.visible').contains('Select').click(); + cy.get(VIEW_CASE_TOASTER_LINK).should('be.visible').and('contain.text', 'View case'); }); // TODO this will change when add to new case is improved // https://github.com/elastic/security-team/issues/6298 - it('should add to new case', { tags: ['@ess', '@serverless'] }, () => { + it('should add to new case', () => { expandFirstAlertExpandableFlyout(); openTakeActionButtonAndSelectItem(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE); - - cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_NAME_INPUT).type('case'); - cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_DESCRIPTION_INPUT).type( - 'case description' - ); - cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_CREATE_BUTTON).click(); + fillOutFormToCreateNewCase(); cy.get(VIEW_CASE_TOASTER_LINK).should('be.visible').and('contain.text', 'View case'); }); - // Issue reported int: https://github.com/elastic/kibana/issues/167809 - it('should mark as acknowledged', { tags: ['@ess', '@brokenInServerless'] }, () => { - cy.get(ALERT_CHECKBOX).should('have.length', 2); + it('should mark as acknowledged', () => { + cy.get(ALERT_CHECKBOX).should('have.length', 1); expandFirstAlertExpandableFlyout(); openTakeActionButtonAndSelectItem(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_MARK_AS_ACKNOWLEDGED); @@ -169,68 +153,62 @@ describe.skip('Alert details expandable flyout right panel', () => { // cy.get(KIBANA_TOAST) // .should('be.visible') // .and('have.text', 'Successfully marked 1 alert as acknowledged.'); - cy.get(ALERT_CHECKBOX).should('have.length', 1); + cy.get(EMPTY_ALERT_TABLE).should('exist'); }); - // Issue reported int: https://github.com/elastic/kibana/issues/167809 - it('should mark as closed', { tags: ['@ess', '@brokenInServerless'] }, () => { - cy.get(ALERT_CHECKBOX).should('have.length', 2); + it('should mark as closed', () => { + cy.get(ALERT_CHECKBOX).should('have.length', 1); expandFirstAlertExpandableFlyout(); openTakeActionButtonAndSelectItem(DOCUMENT_DETAILS_FLYOUT_FOOTER_MARK_AS_CLOSED); // TODO figure out how to verify the toasts pops up // cy.get(KIBANA_TOAST).should('be.visible').and('have.text', 'Successfully closed 1 alert.'); - cy.get(ALERT_CHECKBOX).should('have.length', 1); + cy.get(EMPTY_ALERT_TABLE).should('exist'); }); // these actions are now grouped together as we're not really testing their functionality but just the existence of the option in the dropdown - // Issue reported int: https://github.com/elastic/kibana/issues/167809 - it( - 'should test other action within take action dropdown', - { tags: ['@ess', '@brokenInServerless'] }, - () => { - expandFirstAlertExpandableFlyout(); - - cy.log('should add endpoint exception'); - - // TODO figure out why this option is disabled in Cypress but not running the app locally - // https://github.com/elastic/security-team/issues/6300 - openTakeActionButton(); - cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_ENDPOINT_EXCEPTION).should('be.disabled'); - - cy.log('should add rule exception'); - - // TODO this isn't fully testing the add rule exception yet - // https://github.com/elastic/security-team/issues/6301 - selectTakeActionItem(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_RULE_EXCEPTION); - cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_RULE_EXCEPTION_FLYOUT_HEADER).should('be.visible'); - cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_RULE_EXCEPTION_FLYOUT_CANCEL_BUTTON) - .should('be.visible') - .click(); - - // cy.log('should isolate host'); - - // TODO figure out why isolate host isn't showing up in the dropdown - // https://github.com/elastic/security-team/issues/6302 - // openTakeActionButton(); - // cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_ISOLATE_HOST).should('be.visible'); - - cy.log('should respond'); - - // TODO this will change when respond is improved - // https://github.com/elastic/security-team/issues/6303 - openTakeActionButton(); - cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_RESPOND).should('be.disabled'); - - cy.log('should investigate in timeline'); - - selectTakeActionItem(DOCUMENT_DETAILS_FLYOUT_FOOTER_INVESTIGATE_IN_TIMELINE); - cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_INVESTIGATE_IN_TIMELINE_SECTION) - .first() - .within(() => - cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_INVESTIGATE_IN_TIMELINE_ENTRY).should('be.visible') - ); - } - ); + it('should test other action within take action dropdown', () => { + expandFirstAlertExpandableFlyout(); + + cy.log('should add endpoint exception'); + + // TODO figure out why this option is disabled in Cypress but not running the app locally + // https://github.com/elastic/security-team/issues/6300 + openTakeActionButton(); + cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_ENDPOINT_EXCEPTION).should('be.disabled'); + + cy.log('should add rule exception'); + + // TODO this isn't fully testing the add rule exception yet + // https://github.com/elastic/security-team/issues/6301 + selectTakeActionItem(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_RULE_EXCEPTION); + cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_RULE_EXCEPTION_FLYOUT_HEADER).should('exist'); + cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_RULE_EXCEPTION_FLYOUT_CANCEL_BUTTON) + .should('be.visible') + .click(); + + // cy.log('should isolate host'); + + // TODO figure out why isolate host isn't showing up in the dropdown + // https://github.com/elastic/security-team/issues/6302 + // openTakeActionButton(); + // cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_ISOLATE_HOST).should('be.visible'); + + cy.log('should respond'); + + // TODO this will change when respond is improved + // https://github.com/elastic/security-team/issues/6303 + openTakeActionButton(); + cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_RESPOND).should('be.disabled'); + + cy.log('should investigate in timeline'); + + selectTakeActionItem(DOCUMENT_DETAILS_FLYOUT_FOOTER_INVESTIGATE_IN_TIMELINE); + cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_INVESTIGATE_IN_TIMELINE_SECTION) + .first() + .within(() => + cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_INVESTIGATE_IN_TIMELINE_ENTRY).should('exist') + ); + }); }); diff --git a/x-pack/test/security_solution_cypress/cypress/screens/expandable_flyout/common.ts b/x-pack/test/security_solution_cypress/cypress/screens/expandable_flyout/common.ts index bc0119464374c..f3c0df5cf8f31 100644 --- a/x-pack/test/security_solution_cypress/cypress/screens/expandable_flyout/common.ts +++ b/x-pack/test/security_solution_cypress/cypress/screens/expandable_flyout/common.ts @@ -10,18 +10,13 @@ import { getDataTestSubjectSelectorStartWith, } from '../../helpers/common'; -export const KIBANA_NAVBAR_ALERTS_PAGE = getDataTestSubjectSelector( - 'solutionSideNavItemLink-alerts' -); -export const KIBANA_NAVBAR_CASES_PAGE = getDataTestSubjectSelector('solutionSideNavItemLink-cases'); export const VIEW_CASE_TOASTER_LINK = getDataTestSubjectSelector('toaster-content-case-view-link'); -export const CREATE_CASE_BUTTON = `[data-test-subj="createNewCaseBtn"]`; export const NEW_CASE_NAME_INPUT = `[data-test-subj="input"][aria-describedby="caseTitle"]`; export const NEW_CASE_DESCRIPTION_INPUT = getDataTestSubjectSelector('euiMarkdownEditorTextArea'); -export const NEW_CASE_CREATE_BUTTON = getDataTestSubjectSelector('create-case-submit'); export const EXISTING_CASE_SELECT_BUTTON = getDataTestSubjectSelectorStartWith('cases-table-row-select-'); export const DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_NAME_INPUT = NEW_CASE_NAME_INPUT; export const DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_DESCRIPTION_INPUT = NEW_CASE_DESCRIPTION_INPUT; -export const DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_CREATE_BUTTON = NEW_CASE_CREATE_BUTTON; +export const DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_CREATE_BUTTON = + getDataTestSubjectSelector('create-case-submit'); diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/expandable_flyout/alert_details_right_panel.ts b/x-pack/test/security_solution_cypress/cypress/tasks/expandable_flyout/alert_details_right_panel.ts index 350c069639870..11e1b6a0b0ef9 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/expandable_flyout/alert_details_right_panel.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/expandable_flyout/alert_details_right_panel.ts @@ -13,9 +13,15 @@ import { DOCUMENT_DETAILS_FLYOUT_FOOTER_TAKE_ACTION_BUTTON, DOCUMENT_DETAILS_FLYOUT_FOOTER_TAKE_ACTION_BUTTON_DROPDOWN, DOCUMENT_DETAILS_FLYOUT_JSON_TAB, - DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB, DOCUMENT_DETAILS_FLYOUT_TABLE_TAB, } from '../../screens/expandable_flyout/alert_details_right_panel'; +import { + DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_CREATE_BUTTON, + DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_DESCRIPTION_INPUT, + DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_NAME_INPUT, + VIEW_CASE_TOASTER_LINK, +} from '../../screens/expandable_flyout/common'; +import { TOASTER_CLOSE_ICON } from '../../screens/alerts_detection_rules'; /* Header */ @@ -35,14 +41,6 @@ export const collapseDocumentDetailsExpandableFlyoutLeftSection = () => { cy.get(DOCUMENT_DETAILS_FLYOUT_COLLAPSE_DETAILS_BUTTON).click(); }; -/** - * Open the Overview tab in the document details expandable flyout right section - */ -export const openOverviewTab = () => { - cy.get(DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB).scrollIntoView(); - cy.get(DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB).click(); -}; - /** * Open the Table tab in the document details expandable flyout right section */ @@ -95,3 +93,16 @@ export const selectTakeActionItem = (option: string) => { .should('be.visible') .within(() => cy.get(option).should('be.visible').click()); }; + +/** + * Create new case from the expandable flyout take action button + */ +export const fillOutFormToCreateNewCase = () => { + cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_NAME_INPUT).type('case'); + cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_DESCRIPTION_INPUT).type('case description'); + + cy.get(DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_CREATE_BUTTON).click(); + + cy.get(VIEW_CASE_TOASTER_LINK).should('be.visible'); + cy.get(TOASTER_CLOSE_ICON).should('be.visible').click(); +}; diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/expandable_flyout/common.ts b/x-pack/test/security_solution_cypress/cypress/tasks/expandable_flyout/common.ts index 424d723e732b5..bc1d8e1cd8171 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/expandable_flyout/common.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/expandable_flyout/common.ts @@ -8,33 +8,13 @@ import { EXPAND_ALERT_BTN } from '../../screens/alerts'; import { DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE } from '../../screens/expandable_flyout/alert_details_right_panel'; import { - CREATE_CASE_BUTTON, DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_CREATE_BUTTON, DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_DESCRIPTION_INPUT, DOCUMENT_DETAILS_FLYOUT_FOOTER_ADD_TO_NEW_CASE_NAME_INPUT, - KIBANA_NAVBAR_ALERTS_PAGE, - KIBANA_NAVBAR_CASES_PAGE, - NEW_CASE_CREATE_BUTTON, - NEW_CASE_DESCRIPTION_INPUT, - NEW_CASE_NAME_INPUT, VIEW_CASE_TOASTER_LINK, } from '../../screens/expandable_flyout/common'; import { openTakeActionButtonAndSelectItem } from './alert_details_right_panel'; -/** - * Navigates to the alerts page by clicking on the Kibana sidenav entry - */ -export const navigateToAlertsPage = () => { - cy.get(KIBANA_NAVBAR_ALERTS_PAGE).should('be.visible').click(); -}; - -/** - * Navigates to the cases page by clicking on the Kibana sidenav entry - */ -export const navigateToCasesPage = () => { - cy.get(KIBANA_NAVBAR_CASES_PAGE).click(); -}; - /** * Find the first alert row in the alerts table then click on the expand icon button to open the flyout */ @@ -42,18 +22,6 @@ export const expandFirstAlertExpandableFlyout = () => { cy.get(EXPAND_ALERT_BTN).first().click(); }; -/** - * Create a new case from the cases page - */ -export const createNewCaseFromCases = () => { - cy.get(CREATE_CASE_BUTTON).should('be.visible').click(); - cy.get(NEW_CASE_NAME_INPUT).should('be.visible').click(); - cy.get(NEW_CASE_NAME_INPUT).type('case'); - cy.get(NEW_CASE_DESCRIPTION_INPUT).should('be.visible').click(); - cy.get(NEW_CASE_DESCRIPTION_INPUT).type('case description'); - cy.get(NEW_CASE_CREATE_BUTTON).should('be.visible').click(); -}; - /** * create a new case from the expanded expandable flyout */