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.x] [ Siem Migrations ] Upsell Siem Migrations Start (#212607) #213046

Closed
wants to merge 1 commit into from
Closed
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
@@ -0,0 +1,44 @@
/*
* 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 React from 'react';
import { render, screen } from '@testing-library/react';
import { SiemMigrationStartUpsellSection } from './siem_migrations_start';

describe('SiemMigrationStartUpsellSection', () => {
it('should render the component with all sections correctly', () => {
render(
<SiemMigrationStartUpsellSection
title="title"
upgradeMessage="upgradeMessage"
upgradeHref="https://upgrade.Href"
/>
);

expect(screen.getByTestId('siemMigrationStartUpsellSection')).toBeVisible();

expect(screen.getByTestId('siemMigrationStartUpsellTitle')).toBeVisible();
expect(screen.getByTestId('siemMigrationStartUpsellTitle')).toHaveTextContent('title');

expect(screen.getByTestId('siemMigrationStartUpsellMessage')).toBeVisible();
expect(screen.getByTestId('siemMigrationStartUpsellMessage')).toHaveTextContent(
'upgradeMessage'
);

expect(screen.getByTestId('siemMigrationStartUpsellHref')).toBeVisible();
expect(screen.getByTestId('siemMigrationStartUpsellHref')).toHaveAttribute(
'href',
'https://upgrade.Href'
);
});

it('should render the component without upgradeHref', () => {
render(<SiemMigrationStartUpsellSection title="title" upgradeMessage="upgradeMessage" />);

expect(screen.queryByTestId('SiemMigrationStartUpsellHref')).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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 { EuiButton, EuiCallOut, EuiFlexGroup, EuiFlexItem, EuiPanel, EuiText } from '@elastic/eui';
import React from 'react';

export const SiemMigrationStartUpsellSection = React.memo(function SiemMigrationStartUpsellSection({
title,
upgradeMessage,
upgradeHref,
}: {
title: React.ReactNode;
upgradeMessage: React.ReactNode;
upgradeHref?: string;
}) {
return (
<>
<EuiPanel data-test-subj="siemMigrationStartUpsellSection" paddingSize="none" hasBorder>
<EuiCallOut
data-test-subj="siemMigrationStartUpsellTitle"
title={title}
color="warning"
iconType="lock"
>
<EuiFlexGroup>
<EuiFlexItem grow={true}>
<EuiText size="s" data-test-subj="siemMigrationStartUpsellMessage">
{upgradeMessage}
</EuiText>
</EuiFlexItem>
{upgradeHref ? (
<EuiFlexItem grow={false}>
<EuiButton
data-test-subj="siemMigrationStartUpsellHref"
href={upgradeHref}
color="warning"
fill
>
{'Manage License'}
</EuiButton>
</EuiFlexItem>
) : null}
</EuiFlexGroup>
</EuiCallOut>
</EuiPanel>
</>
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ export type UpsellingSectionId =
| 'endpoint_custom_notification'
| 'cloud_security_posture_integration_installation'
| 'ruleDetailsEndpointExceptions'
<<<<<<< HEAD
| 'integration_assistant';
=======
| 'automatic_import'
| 'siem_migrations_start';
>>>>>>> 44a184c701c ([ Siem Migrations ] Upsell Siem Migrations Start (#212607))

export type UpsellingMessageId =
| 'investigation_guide'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ export const CenteredLoadingSpinner = React.memo<CenteredLoadingSpinnerProps>(
[topOffset, euiTheme]
);

return <EuiLoadingSpinner {...euiLoadingSpinnerProps} style={style} />;
return (
<EuiLoadingSpinner
data-test-subj="centeredLoadingSpinner"
{...euiLoadingSpinnerProps}
style={style}
/>
);
}
);
CenteredLoadingSpinner.displayName = 'CenteredLoadingSpinner';
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import { UpsellingService } from '@kbn/security-solution-upselling/service';
import { calculateBounds } from '@kbn/data-plugin/common';
import { alertingPluginMock } from '@kbn/alerting-plugin/public/mocks';
import { createTelemetryServiceMock } from '../telemetry/telemetry_service.mock';
import { createSiemMigrationsMock } from '../../mock/mock_siem_migrations_service';

const mockUiSettings: Record<string, unknown> = {
[DEFAULT_TIME_RANGE]: { from: 'now-15m', to: 'now', mode: 'quick' },
Expand Down Expand Up @@ -128,6 +129,7 @@ export const createStartServicesMock = (
const mockSetHeaderActionMenu = jest.fn();
const timelineDataService = dataPluginMock.createStartContract();
const alerting = alertingPluginMock.createStartContract();
const siemMigrations = createSiemMigrationsMock();

/*
* Below mocks are needed by unified field list
Expand Down Expand Up @@ -254,6 +256,7 @@ export const createStartServicesMock = (
upselling: new UpsellingService(),
timelineDataService,
alerting,
siemMigrations,
} as unknown as StartServices;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ export * from './timeline_results';
export * from './utils';
export * from './create_store';
export * from './create_react_query_wrapper';
export * from './mock_siem_migrations_service';
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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 { createTelemetryServiceMock } from '../lib/telemetry/telemetry_service.mock';

const createRuleMigrationStorageMock = () => {
return {
get: jest.fn(),
set: jest.fn(),
remove: jest.fn(),
};
};

export const createSiemMigrationsMock = () => {
return {
rules: {
getLatestStats$: jest.fn(),
getMissingCapabilities: jest.fn(),
hasMissingCapabilities: jest.fn(),
isAvailable: jest.fn(),
startPolling: jest.fn(),
createRuleMigration: jest.fn(),
upsertMigrationResources: jest.fn(),
startRuleMigration: jest.fn(),
getRuleMigrationStats: jest.fn(),
getRuleMigrationsStats: jest.fn(),
getMissingResources: jest.fn(),
getIntegrations: jest.fn(),
connectorIdStorage: createRuleMigrationStorageMock(),
traceOptionsStorage: createRuleMigrationStorageMock(),
telemetry: createTelemetryServiceMock(),
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ export const aiConnectorCardConfig: OnboardingCardConfig<AIConnectorCardMetadata
)
),
checkComplete: checkAiConnectorsCardComplete,
licenseTypeRequired: 'enterprise',
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const startMigrationCardConfig: OnboardingCardConfig<StartMigrationCardMe
id: OnboardingCardId.siemMigrationsStart,
title: START_MIGRATION_CARD_TITLE,
icon: () => getCardIcon(OnboardingCardId.siemMigrationsStart),
licenseTypeRequired: 'enterprise',
Component: React.lazy(
() =>
import(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const RuleMigrationsPanels = React.memo<RuleMigrationsPanelsProps>(
);

return (
<EuiFlexGroup direction="column" gutterSize="m">
<EuiFlexGroup data-test-subj="ruleMigrationPanelGroup" direction="column" gutterSize="m">
<EuiFlexItem grow={false}>
{!isConnectorsCardComplete && (
<>
Expand Down
Loading