Skip to content

Commit

Permalink
[8.15] [Security solution][Alert Details] Enable preview feature flag…
Browse files Browse the repository at this point in the history
… and cypress tests (#188580) (#189005)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[Security solution][Alert Details] Enable preview feature flag and
cypress tests (#188580)](#188580)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"christineweng","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-07-23T20:01:56Z","message":"[Security
solution][Alert Details] Enable preview feature flag and cypress tests
(#188580)\n\n## Summary\r\n\r\nThis PR inverted feature flag
`entityAlertPreviewEnabled` to\r\n`entityAlertPreviewDisabled` and
related cypress tests. The flag\r\ninversion will allow customers to
disable the feature if issues arise.\r\n\r\n\r\n### Checklist\r\n\r\n-
[x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests
changed","sha":"f6a837dae0a6438b534e934edfd3232effe966b3","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Threat
Hunting","release_note:feature","Team:Threat
Hunting:Investigations","v8.15.0","v8.16.0"],"title":"[Security
solution][Alert Details] Enable preview feature flag and cypress
tests","number":188580,"url":"https://github.com/elastic/kibana/pull/188580","mergeCommit":{"message":"[Security
solution][Alert Details] Enable preview feature flag and cypress tests
(#188580)\n\n## Summary\r\n\r\nThis PR inverted feature flag
`entityAlertPreviewEnabled` to\r\n`entityAlertPreviewDisabled` and
related cypress tests. The flag\r\ninversion will allow customers to
disable the feature if issues arise.\r\n\r\n\r\n### Checklist\r\n\r\n-
[x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests
changed","sha":"f6a837dae0a6438b534e934edfd3232effe966b3"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"8.15","label":"v8.15.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/188580","number":188580,"mergeCommit":{"message":"[Security
solution][Alert Details] Enable preview feature flag and cypress tests
(#188580)\n\n## Summary\r\n\r\nThis PR inverted feature flag
`entityAlertPreviewEnabled` to\r\n`entityAlertPreviewDisabled` and
related cypress tests. The flag\r\ninversion will allow customers to
disable the feature if issues arise.\r\n\r\n\r\n### Checklist\r\n\r\n-
[x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests
changed","sha":"f6a837dae0a6438b534e934edfd3232effe966b3"}}]}]
BACKPORT-->

Co-authored-by: christineweng <[email protected]>
  • Loading branch information
kibanamachine and christineweng authored Jul 24, 2024
1 parent bd96a7f commit 42ef1e6
Show file tree
Hide file tree
Showing 21 changed files with 40 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ export const allowedExperimentalValues = Object.freeze({
securitySolutionNotesEnabled: false,

/**
* Enables entity and alert previews
* Disables entity and alert previews
*/
entityAlertPreviewEnabled: false,
entityAlertPreviewDisabled: false,

/**
* Enables the Assistant Model Evaluation advanced setting and API endpoint, introduced in `8.11.0`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('RiskInputsTab', () => {
});

it('it renders alert preview button when feature flag is enable', () => {
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
mockUseRiskScore.mockReturnValue({
loading: false,
error: false,
Expand All @@ -152,7 +152,7 @@ describe('RiskInputsTab', () => {
});

it('it does not render alert preview button when feature flag is disable', () => {
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
mockUseRiskScore.mockReturnValue({
loading: false,
error: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const RiskInputsTab = ({ entityType, entityName, scopeId }: RiskInputsTab
}),
[]
);
const isPreviewEnabled = useIsExperimentalFeatureEnabled('entityAlertPreviewEnabled');
const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled');

const inputColumns: Array<EuiBasicTableColumn<InputAlert>> = useMemo(
() => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const renderCorrelationsTable = (panelContext: DocumentDetailsContext) =>
describe('CorrelationsDetailsAlertsTable', () => {
beforeEach(() => {
jest.mocked(useExpandableFlyoutApi).mockReturnValue(mockFlyoutApi);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
jest.mocked(usePaginatedAlerts).mockReturnValue({
setPagination: jest.fn(),
setSorting: jest.fn(),
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('CorrelationsDetailsAlertsTable', () => {
});

it('renders open preview button when feature flag is on', () => {
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
const { getByTestId, getAllByTestId } = renderCorrelationsTable({
...mockContextValue,
isPreviewMode: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const CorrelationsDetailsAlertsTable: FC<CorrelationsDetailsAlertsTablePr
sorting,
error,
} = usePaginatedAlerts(alertIds || []);
const isPreviewEnabled = useIsExperimentalFeatureEnabled('entityAlertPreviewEnabled');
const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled');

const onTableChange = useCallback(
({ page, sort }: Criteria<Record<string, unknown>>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('<HostDetails />', () => {
mockUseHostDetails.mockReturnValue(mockHostDetailsResponse);
mockUseRiskScore.mockReturnValue(mockRiskScoreResponse);
mockUseHostsRelatedUsers.mockReturnValue(mockRelatedUsersResponse);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
});

it('should render host details correctly', () => {
Expand All @@ -168,7 +168,7 @@ describe('<HostDetails />', () => {
});

it('should render host name as clicable link when feature flag is true', () => {
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
const { getByTestId } = renderHostDetails(mockContextValue);
expect(getByTestId(HOST_DETAILS_LINK_TEST_ID)).toBeInTheDocument();

Expand Down Expand Up @@ -272,7 +272,7 @@ describe('<HostDetails />', () => {
});

it('should render user name as clicable link when feature flag is true', () => {
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
const { getAllByTestId } = renderHostDetails(mockContextValue);
expect(getAllByTestId(HOST_DETAILS_RELATED_USERS_LINK_TEST_ID).length).toBe(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const HostDetails: React.FC<HostDetailsProps> = ({ hostName, timestamp, s
const isEntityAnalyticsAuthorized = isPlatinumOrTrialLicense && hasEntityAnalyticsCapability;

const { openPreviewPanel } = useExpandableFlyoutApi();
const isPreviewEnabled = useIsExperimentalFeatureEnabled('entityAlertPreviewEnabled');
const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled');

const narrowDateRange = useCallback(
(score, interval) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('PrevalenceDetails', () => {
jest.clearAllMocks();
licenseServiceMock.isPlatinumPlus.mockReturnValue(true);
jest.mocked(useExpandableFlyoutApi).mockReturnValue(mockFlyoutApi);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
});

it('should render the table with all data if license is platinum', () => {
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('PrevalenceDetails', () => {
});

it('should render host and user name as clickable link if feature flag is true', () => {
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
(usePrevalence as jest.Mock).mockReturnValue(mockPrevelanceReturnValue);

const { getByTestId } = renderPrevalenceDetails();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ export const PrevalenceDetails: React.FC = () => {
const { telemetry } = useKibana().services;

const isPlatinumPlus = useLicense().isPlatinumPlus();
const isPreviewEnabled = useIsExperimentalFeatureEnabled('entityAlertPreviewEnabled');
const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled');

// these two are used by the usePrevalence hook to fetch the data
const [start, setStart] = useState(DEFAULT_FROM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe('<UserDetails />', () => {
mockUseObservedUserDetails.mockReturnValue(mockUserDetailsResponse);
mockUseRiskScore.mockReturnValue(mockRiskScoreResponse);
mockUseUsersRelatedHosts.mockReturnValue(mockRelatedHostsResponse);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
});

it('should render user details correctly', () => {
Expand All @@ -165,7 +165,7 @@ describe('<UserDetails />', () => {
});

it('should render user name as clicable link when feature flag is true', () => {
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
const { getByTestId } = renderUserDetails(mockContextValue);
expect(getByTestId(USER_DETAILS_LINK_TEST_ID)).toBeInTheDocument();

Expand Down Expand Up @@ -254,7 +254,7 @@ describe('<UserDetails />', () => {
});

it('should render host name as clicable link when feature flag is true', () => {
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
const { getAllByTestId } = renderUserDetails(mockContextValue);
expect(getAllByTestId(USER_DETAILS_RELATED_HOSTS_LINK_TEST_ID).length).toBe(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const UserDetails: React.FC<UserDetailsProps> = ({ userName, timestamp, s
const isEntityAnalyticsAuthorized = isPlatinumOrTrialLicense && hasEntityAnalyticsCapability;

const { openPreviewPanel } = useExpandableFlyoutApi();
const isPreviewEnabled = useIsExperimentalFeatureEnabled('entityAlertPreviewEnabled');
const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled');

const narrowDateRange = useCallback(
(score, interval) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const renderHighlightedFieldsCell = (values: string[], field: string) =>
describe('<HighlightedFieldsCell />', () => {
beforeAll(() => {
jest.mocked(useExpandableFlyoutApi).mockReturnValue(mockFlyoutApi);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
});

it('should render a basic cell', () => {
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('<HighlightedFieldsCell />', () => {
});

it('should open host preview when click on host when feature flag is on', () => {
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
const { getByTestId } = renderHighlightedFieldsCell(['test host'], 'host.name');

getByTestId(HIGHLIGHTED_FIELDS_LINKED_CELL_TEST_ID).click();
Expand All @@ -114,7 +114,7 @@ describe('<HighlightedFieldsCell />', () => {
});

it('should open user preview when click on user when feature flag is on', () => {
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
const { getByTestId } = renderHighlightedFieldsCell(['test user'], 'user.name');

getByTestId(HIGHLIGHTED_FIELDS_LINKED_CELL_TEST_ID).click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ interface LinkFieldCellProps {
const LinkFieldCell: VFC<LinkFieldCellProps> = ({ field, value }) => {
const { scopeId, eventId, indexName } = useDocumentDetailsContext();
const { openLeftPanel, openPreviewPanel } = useExpandableFlyoutApi();
const isPreviewEnabled = useIsExperimentalFeatureEnabled('entityAlertPreviewEnabled');
const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled');
const { telemetry } = useKibana().services;

const goToInsightsEntities = useCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const renderHostEntityContent = () =>
describe('<HostEntityContent />', () => {
beforeAll(() => {
jest.mocked(useExpandableFlyoutApi).mockReturnValue(mockFlyoutApi);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
});

describe('license is valid', () => {
Expand Down Expand Up @@ -184,7 +184,7 @@ describe('<HostEntityContent />', () => {
it('should open host preview when clicking on title when feature flag is on', () => {
mockUseHostDetails.mockReturnValue([false, { hostDetails: hostData }]);
mockUseRiskScore.mockReturnValue({ data: riskLevel, isAuthorized: true });
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);

const { getByTestId } = renderHostEntityContent();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const HostEntityOverview: React.FC<HostEntityOverviewProps> = ({ hostName
const { openLeftPanel, openPreviewPanel } = useExpandableFlyoutApi();
const { telemetry } = useKibana().services;

const isPreviewEnabled = useIsExperimentalFeatureEnabled('entityAlertPreviewEnabled');
const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled');

const goToEntitiesTab = useCallback(() => {
openLeftPanel({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const renderUserEntityOverview = () =>
describe('<UserEntityOverview />', () => {
beforeAll(() => {
jest.mocked(useExpandableFlyoutApi).mockReturnValue(mockFlyoutApi);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
});

describe('license is valid', () => {
Expand Down Expand Up @@ -198,7 +198,7 @@ describe('<UserEntityOverview />', () => {
it('should open user preview if feature flag is true', () => {
mockUseUserDetails.mockReturnValue([false, { userDetails: userData }]);
mockUseRiskScore.mockReturnValue({ data: riskLevel, isAuthorized: true });
mockUseIsExperimentalFeatureEnabled.mockReturnValue(true);
mockUseIsExperimentalFeatureEnabled.mockReturnValue(false);

const { getByTestId } = render(
<TestProviders>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const UserEntityOverview: React.FC<UserEntityOverviewProps> = ({ userName
const { openLeftPanel, openPreviewPanel } = useExpandableFlyoutApi();
const { telemetry } = useKibana().services;

const isPreviewEnabled = useIsExperimentalFeatureEnabled('entityAlertPreviewEnabled');
const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled');

const goToEntitiesTab = useCallback(() => {
openLeftPanel({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import {
DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_ENTITIES_BUTTON,
DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_HOST_DETAILS,
DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_HOST_DETAILS_RIGHT_SECTION,
DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_HOST_DETAILS_TITLE,
DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_HOST_DETAILS_LINK,
DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_USER_DETAILS,
DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_USER_DETAILS_RIGHT_SECTION,
DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_USER_DETAILS_TITLE,
DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_USER_DETAILS_LINK,
} from '../../../../screens/expandable_flyout/alert_details_left_panel_entities_tab';
import {
Expand Down Expand Up @@ -68,34 +66,20 @@ describe(
.should('have.text', 'Entities')
.and('have.class', 'euiButtonGroupButton-isSelected');

// github.com/elastic/security-team/issues/9933
// Comment out when feature flag 'entityAlertPreviewEnabled' is enabled
cy.get(DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_USER_DETAILS_TITLE).should(
'contain.text',
'test'
);
cy.get(DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_USER_DETAILS_RIGHT_SECTION).should(
'contain.text',
'Related hosts: 0'
);
cy.get(DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_USER_DETAILS).should('exist');

// github.com/elastic/security-team/issues/9933
// Comment out when feature flag 'entityAlertPreviewEnabled' is enabled
cy.get(DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_HOST_DETAILS_TITLE).should(
'contain.text',
'siem-kibana'
);
cy.get(DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_HOST_DETAILS_RIGHT_SECTION).should(
'contain.text',
'Related users: 0'
);
cy.get(DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_HOST_DETAILS).should('exist');
});

// github.com/elastic/security-team/issues/9933
// Enable when feature flag 'entityAlertPreviewEnabled' is enabled
it.skip('should open host preview when click on host details title', () => {
it('should open host preview when click on host details title', () => {
cy.get(DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_HOST_DETAILS_LINK).should(
'contain.text',
'siem-kibana'
Expand All @@ -115,9 +99,7 @@ describe(
cy.get(HOST_PREVIEW_PANEL_FOOTER).should('not.exist');
});

// github.com/elastic/security-team/issues/9933
// Enable when feature flag 'entityAlertPreviewEnabled' is enabled
it.skip('should open user preview when click on user details title', () => {
it('should open user preview when click on user details title', () => {
cy.get(DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_USER_DETAILS_LINK).should('contain.text', 'test');
cy.get(DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_USER_DETAILS_LINK).click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ describe(
);
});

// github.com/elastic/security-team/issues/9933
// Enable when feature flag 'entityAlertPreviewEnabled' is enabled
it.skip('should open host preview when click on host details title', () => {
it('should open host preview when click on host details title', () => {
cy.get(DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_PREVALENCE_TABLE_HOST_CELL).click();

cy.get(PREVIEW_SECTION).should('exist');
Expand All @@ -118,9 +116,7 @@ describe(
cy.get(HOST_PREVIEW_PANEL_FOOTER).should('not.exist');
});

// github.com/elastic/security-team/issues/9933
// Enable when feature flag 'entityAlertPreviewEnabled' is enabled
it.skip('should open user preview when click on user details title', () => {
it('should open user preview when click on user details title', () => {
cy.get(DOCUMENT_DETAILS_FLYOUT_INSIGHTS_TAB_PREVALENCE_TABLE_USER_CELL).click();

cy.get(PREVIEW_SECTION).should('exist');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ import {
openTableTab,
} from '../../../../tasks/expandable_flyout/alert_details_right_panel';

// github.com/elastic/security-team/issues/9933
// Enable when feature flag 'entityAlertPreviewEnabled' is enabled
describe.skip(
describe(
'Opening alert previews from alert details flyout',
{ tags: ['@ess', '@serverless'] },
() => {
Expand Down
Loading

0 comments on commit 42ef1e6

Please sign in to comment.