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

[8.12] [Security Solution][Detections] Flaky alert assignments tests (#173284) #173344

Merged
merged 1 commit into from
Dec 14, 2023
Merged
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 @@ -23,12 +23,12 @@ import { waitForAlertsToPopulate } from '../../../../../tasks/create_new_rule';
import {
alertDetailsFlyoutShowsAssignees,
alertDetailsFlyoutShowsAssigneesBadge,
alertsTableShowsAssigneesBadgeForAlert,
alertsTableShowsAssigneesBadgeForFirstAlert,
alertsTableShowsAssigneesForAlert,
updateAssigneesForAlert,
updateAssigneesForFirstAlert,
checkEmptyAssigneesStateInAlertDetailsFlyout,
checkEmptyAssigneesStateInAlertsTable,
removeAllAssigneesForAlert,
removeAllAssigneesForFirstAlert,
bulkUpdateAssignees,
alertsTableShowsAssigneesForAllAlerts,
bulkRemoveAllAssignees,
Expand All @@ -42,8 +42,7 @@ import {
} from '../../../../../tasks/alert_assignments';
import { ALERTS_COUNT } from '../../../../../screens/alerts';

// FLAKY: https://github.com/elastic/kibana/issues/172611
describe.skip('Alert user assignment - ESS & Serverless', { tags: ['@ess', '@serverless'] }, () => {
describe('Alert user assignment - ESS & Serverless', { tags: ['@ess', '@serverless'] }, () => {
before(() => {
cy.task('esArchiverLoad', { archiveName: 'auditbeat_multiple' });

Expand Down Expand Up @@ -79,13 +78,13 @@ describe.skip('Alert user assignment - ESS & Serverless', { tags: ['@ess', '@ser

it('alert with some assignees in alerts table', () => {
const users = [ROLES.detections_admin, ROLES.t1_analyst];
updateAssigneesForAlert(users);
updateAssigneesForFirstAlert(users);
alertsTableShowsAssigneesForAlert(users);
});

it(`alert with some assignees in alert's details flyout`, () => {
const users = [ROLES.detections_admin, ROLES.t1_analyst];
updateAssigneesForAlert(users);
updateAssigneesForFirstAlert(users);
expandFirstAlert();
alertDetailsFlyoutShowsAssignees(users);
});
Expand All @@ -98,13 +97,13 @@ describe.skip('Alert user assignment - ESS & Serverless', { tags: ['@ess', '@ser
ROLES.soc_manager,
ROLES.detections_admin,
];
updateAssigneesForAlert(users);
alertsTableShowsAssigneesBadgeForAlert(users);
updateAssigneesForFirstAlert(users);
alertsTableShowsAssigneesBadgeForFirstAlert(users);
});

it(`alert with many assignees (collapsed into badge) in alert's details flyout`, () => {
const users = [ROLES.detections_admin, ROLES.t1_analyst, ROLES.t2_analyst];
updateAssigneesForAlert(users);
updateAssigneesForFirstAlert(users);
expandFirstAlert();
alertDetailsFlyoutShowsAssigneesBadge(users);
});
Expand All @@ -114,7 +113,7 @@ describe.skip('Alert user assignment - ESS & Serverless', { tags: ['@ess', '@ser
it('adding new assignees via `More actions` in alerts table', () => {
// Assign users
const users = [ROLES.detections_admin, ROLES.t1_analyst];
updateAssigneesForAlert(users);
updateAssigneesForFirstAlert(users);

// Assignees should appear in the alerts table
alertsTableShowsAssigneesForAlert(users);
Expand Down Expand Up @@ -157,12 +156,12 @@ describe.skip('Alert user assignment - ESS & Serverless', { tags: ['@ess', '@ser
it('updating assignees via `More actions` in alerts table', () => {
// Initially assigned users
const initialAssignees = [ROLES.detections_admin, ROLES.t1_analyst];
updateAssigneesForAlert(initialAssignees);
updateAssigneesForFirstAlert(initialAssignees);
alertsTableShowsAssigneesForAlert(initialAssignees);

// Update assignees
const updatedAssignees = [ROLES.t1_analyst, ROLES.t2_analyst];
updateAssigneesForAlert(updatedAssignees);
updateAssigneesForFirstAlert(updatedAssignees);

const expectedAssignees = [ROLES.detections_admin, ROLES.t2_analyst];

Expand Down Expand Up @@ -221,10 +220,10 @@ describe.skip('Alert user assignment - ESS & Serverless', { tags: ['@ess', '@ser
it('removing all assignees via `More actions` in alerts table', () => {
// Initially assigned users
const initialAssignees = [ROLES.detections_admin, ROLES.t1_analyst];
updateAssigneesForAlert(initialAssignees);
updateAssigneesForFirstAlert(initialAssignees);
alertsTableShowsAssigneesForAlert(initialAssignees);

removeAllAssigneesForAlert();
removeAllAssigneesForFirstAlert();

// Alert should not show any assignee in alerts table or in details flyout
checkEmptyAssigneesStateInAlertsTable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ALERTS_URL } from '../../../../../urls/navigation';
import { waitForAlertsToPopulate } from '../../../../../tasks/create_new_rule';
import {
alertsTableShowsAssigneesForAlert,
updateAssigneesForAlert,
updateAssigneesForFirstAlert,
bulkRemoveAllAssignees,
loadPageAs,
} from '../../../../../tasks/alert_assignments';
Expand Down Expand Up @@ -78,7 +78,7 @@ describe.skip(
bulkRemoveAllAssignees();
refreshAlertPageFilter();

updateAssigneesForAlert([role]);
updateAssigneesForFirstAlert([role]);

// Assignees should appear in the alerts table
alertsTableShowsAssigneesForAlert([role]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ALERTS_URL } from '../../../../../urls/navigation';
import { waitForAlertsToPopulate } from '../../../../../tasks/create_new_rule';
import {
alertsTableShowsAssigneesForAlert,
updateAssigneesForAlert,
updateAssigneesForFirstAlert,
bulkRemoveAllAssignees,
loadPageAs,
} from '../../../../../tasks/alert_assignments';
Expand Down Expand Up @@ -78,7 +78,7 @@ describe.skip(
bulkRemoveAllAssignees();
refreshAlertPageFilter();

updateAssigneesForAlert([role]);
updateAssigneesForFirstAlert([role]);

// Assignees should appear in the alerts table
alertsTableShowsAssigneesForAlert([role]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from '../screens/alerts';
import { PAGE_TITLE } from '../screens/common/page';
import { DOCUMENT_DETAILS_FLYOUT_HEADER_ASSIGNEES } from '../screens/expandable_flyout/alert_details_right_panel';
import { selectFirstPageAlerts } from './alerts';
import { expandFirstAlertActions, selectFirstPageAlerts } from './alerts';
import { login } from './login';
import { visitWithTimeRange } from './navigation';

Expand Down Expand Up @@ -56,8 +56,8 @@ export const loadPageAs = (url: string, role?: SecurityRoleName) => {
waitForPageTitleToBeShown();
};

export const openAlertAssigningActionMenu = (alertIndex = 0) => {
cy.get(TIMELINE_CONTEXT_MENU_BTN).eq(alertIndex).click();
export const openFirstAlertAssigningActionMenu = () => {
expandFirstAlertActions();
cy.get(ALERT_ASSIGN_CONTEXT_MENU_ITEM).click();
};

Expand Down Expand Up @@ -93,8 +93,8 @@ export const alertsTableMoreActionsAreNotAvailable = () => {
cy.get(TIMELINE_CONTEXT_MENU_BTN).should('not.exist');
};

export const asigneesMenuItemsAreNotAvailable = (alertIndex = 0) => {
cy.get(TIMELINE_CONTEXT_MENU_BTN).eq(alertIndex).click();
export const asigneesMenuItemsAreNotAvailable = () => {
expandFirstAlertActions();
cy.get(ALERT_ASSIGN_CONTEXT_MENU_ITEM).should('not.exist');
cy.get(ALERT_UNASSIGN_CONTEXT_MENU_ITEM).should('not.exist');
};
Expand Down Expand Up @@ -126,12 +126,9 @@ export const alertsTableShowsAssigneesForAllAlerts = (users: SecurityRoleName[])
});
};

export const alertsTableShowsAssigneesBadgeForAlert = (
users: SecurityRoleName[],
alertIndex = 0
) => {
export const alertsTableShowsAssigneesBadgeForFirstAlert = (users: SecurityRoleName[]) => {
cy.get(ALERT_ASIGNEES_COLUMN)
.eq(alertIndex)
.first()
.within(() => {
cy.get(ALERT_ASSIGNEES_COUNT_BADGE).contains(users.length);
users.forEach((user) => cy.get(`.euiAvatar${ALERT_USER_AVATAR(user)}`).should('not.exist'));
Expand Down Expand Up @@ -166,10 +163,9 @@ export const selectAlertAssignee = (assignee: string) => {
/**
* This will update assignees for selected alert
* @param users The list of assugnees to update. If assignee is not assigned yet it will be assigned, otherwise it will be unassigned
* @param alertIndex The index of the alert in the alerts table
*/
export const updateAssigneesForAlert = (users: SecurityRoleName[], alertIndex = 0) => {
openAlertAssigningActionMenu(alertIndex);
export const updateAssigneesForFirstAlert = (users: SecurityRoleName[]) => {
openFirstAlertAssigningActionMenu();
waitForAssigneesToPopulatePopover();
users.forEach((user) => selectAlertAssignee(user));
updateAlertAssignees();
Expand Down Expand Up @@ -201,8 +197,8 @@ export const bulkUpdateAssignees = (users: SecurityRoleName[]) => {
cy.get(ALERTS_TABLE_ROW_LOADER).should('not.exist');
};

export const removeAllAssigneesForAlert = (alertIndex = 0) => {
cy.get(TIMELINE_CONTEXT_MENU_BTN).eq(alertIndex).click();
export const removeAllAssigneesForFirstAlert = () => {
expandFirstAlertActions();
cy.get(ALERT_UNASSIGN_CONTEXT_MENU_ITEM).click();
cy.get(ALERTS_TABLE_ROW_LOADER).should('not.exist');
};
Expand Down
Loading