Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cloud Security] Cypress for Alerts Contextual Flyout #202214

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ export const AlertsDetailsTable = memo(
name: '',
width: '5%',
render: (id: string, alert: ContextualFlyoutAlertsField) => (
<EuiLink onClick={() => handleOnEventAlertDetailPanelOpened(id, alert.index, tableId)}>
<EuiLink
onClick={() => handleOnEventAlertDetailPanelOpened(id, alert.index, tableId)}
data-test-subj={'alertPreviewExpandButtonTestSubject'}
>
<EuiIcon type={'expand'} />
</EuiLink>
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { createRule } from '../../tasks/api_calls/rules';
import { getNewRule } from '../../objects/rule';
import { getDataTestSubjectSelector } from '../../helpers/common';

import { deleteAlertsAndRules } from '../../tasks/api_calls/common';
import { waitForAlertsToPopulate } from '../../tasks/create_new_rule';
import { login } from '../../tasks/login';
import { ALERTS_URL } from '../../urls/navigation';
import { visit } from '../../tasks/navigation';
import {
expandFirstAlertHostFlyout,
expandFirstAlertUserFlyout,
} from '../../tasks/asset_criticality/common';

const CSP_INSIGHT_ALERTS_TITLE = getDataTestSubjectSelector(
'securitySolutionFlyoutInsightsAlertsTitleLink'
);

const CSP_INSIGHT_TAB_TITLE = getDataTestSubjectSelector('securitySolutionFlyoutInsightInputsTab');
const CSP_INSIGHT_TABLE = getDataTestSubjectSelector(
'securitySolutionFlyoutMisconfigurationFindingsTable'
);

const ALERT_PREVIEW_EXPAND_BUTTON = getDataTestSubjectSelector(
'alertPreviewExpandButtonTestSubject'
);

const EXPAND_DETAILS_BUTTON = getDataTestSubjectSelector(
'securitySolutionFlyoutNavigationExpandDetailButton'
);

const PREVIEW_SECTION = getDataTestSubjectSelector('previewSection');

const clickAlertsTitle = () => {
cy.get(CSP_INSIGHT_ALERTS_TITLE).click();
};

const clickAlertPreviewExpandButton = () => {
cy.get(ALERT_PREVIEW_EXPAND_BUTTON).click();
};

const clickExpandButton = () => {
cy.get(EXPAND_DETAILS_BUTTON).click();
};

const checkAlertsTitleExistAndClickable = () => {
cy.log('check if Alerts preview title shown');
cy.get(CSP_INSIGHT_ALERTS_TITLE).should('be.visible');
waitForAlertsToPopulate();
clickAlertsTitle();
};

describe('Alert details expandable flyout', { tags: ['@ess', '@serverless'] }, () => {
beforeEach(() => {
deleteAlertsAndRules();
login();
createRule(getNewRule());
visit(ALERTS_URL);
waitForAlertsToPopulate();
});

context('Host name - Has Alerts', () => {
beforeEach(() => {
cy.reload();
});
it('should display Alerts preview under Insights Entities ', () => {
expandFirstAlertHostFlyout();
checkAlertsTitleExistAndClickable();
cy.get(CSP_INSIGHT_TAB_TITLE).should('be.visible');
cy.get(CSP_INSIGHT_TABLE).should('be.visible');
});

it('should display Alert preview flyout when clickin on Expand button on Alerts Row', () => {
expandFirstAlertHostFlyout();
checkAlertsTitleExistAndClickable();
cy.get(ALERT_PREVIEW_EXPAND_BUTTON).click();
cy.get(PREVIEW_SECTION).should('be.visible');
});
});

context('User name - Has Alerts', () => {
it('should display Alerts preview under Insights Entities ', () => {
expandFirstAlertUserFlyout();
checkAlertsTitleExistAndClickable();
cy.get(CSP_INSIGHT_TAB_TITLE).should('be.visible');
cy.get(CSP_INSIGHT_TABLE).should('be.visible');
});

it('should display Alert preview flyout when clickin on Expand button on Alerts Row', () => {
expandFirstAlertUserFlyout();
checkAlertsTitleExistAndClickable();
cy.get(ALERT_PREVIEW_EXPAND_BUTTON).click();
cy.get(PREVIEW_SECTION).should('be.visible');
});
});
});