Skip to content

Commit

Permalink
Merge branch 'main' into function-subtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimkibana authored Jul 26, 2024
2 parents 8c3af90 + 218146e commit ef63a40
Show file tree
Hide file tree
Showing 65 changed files with 3,634 additions and 820 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ check_for_changed_files "yarn openapi:bundle:entity-analytics" true

echo -e "\n[Security Solution OpenAPI Bundling] Lists API\n"

echo -e "\n[Security Solution OpenAPI Bundling] Endpoint Management API\n"

(cd x-pack/plugins/security_solution && yarn openapi:bundle:endpoint-management)
check_for_changed_files "yarn openapi:bundle:endpoint-management" true

(cd packages/kbn-securitysolution-lists-common && yarn openapi:bundle)
check_for_changed_files "yarn openapi:bundle" true

Expand Down
2 changes: 1 addition & 1 deletion config/serverless.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ telemetry.labels.serverless: search

# Alerts and LLM config
xpack.actions.enabledActionTypes:
['.email', '.index', '.slack', '.jira', '.webhook', '.teams', '.gen-ai', '.bedrock']
['.email', '.index', '.slack', '.jira', '.webhook', '.teams', '.gen-ai', '.bedrock', '.gemini']

# Customize empty page state for analytics apps
no_data_page.analyticsNoDataPageFlavor: 'serverless_search'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface ConnectorCronEditorProps {
export const ConnectorCronEditor: React.FC<ConnectorCronEditorProps> = ({
dataTelemetryIdPrefix,
disabled = false,
frequencyBlockList = ['MINUTE'],
frequencyBlockList = [],
hasSyncTypeChanges,
onReset,
onSave,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,6 @@ export const ConnectorContentScheduling: React.FC<ConnectorContentSchedulingProp
hasSyncTypeChanges={hasSyncTypeChanges}
setHasSyncTypeChanges={setHasSyncTypeChanges}
disabled={isGated}
frequencyBlockList={
type === SyncJobType.ACCESS_CONTROL || type === SyncJobType.FULL ? [] : undefined
}
scheduling={scheduling[type]}
onReset={() => {
setScheduling({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const onAddPanelActionClick =
export const getAddPanelActionMenuItemsGroup = (
api: PresentationContainer,
actions: Array<Action<object>> | undefined,
closePopover: () => void
onPanelSelected: () => void
) => {
const grouped: Record<string, GroupedAddPanelActions> = {};

Expand All @@ -72,7 +72,7 @@ export const getAddPanelActionMenuItemsGroup = (
name: actionName,
icon:
(typeof item.getIconType === 'function' ? item.getIconType(context) : undefined) ?? 'empty',
onClick: onAddPanelActionClick(item, context, closePopover),
onClick: onAddPanelActionClick(item, context, onPanelSelected),
'data-test-subj': `create-action-${actionName}`,
description: item?.getDisplayNameTooltip?.(context),
order: item.order ?? 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React, { type ComponentProps } from 'react';
import { render, screen, fireEvent, act } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { __IntlProvider as IntlProvider } from '@kbn/i18n-react';
import { DashboardPanelSelectionListFlyout } from './dashboard_panel_selection_flyout';
import type { GroupedAddPanelActions } from './add_panel_action_menu_items';

const defaultProps: Omit<
ComponentProps<typeof DashboardPanelSelectionListFlyout>,
'fetchDashboardPanels'
> = {
close: jest.fn(),
paddingSize: 's',
};

const renderComponent = ({
fetchDashboardPanels,
}: Pick<ComponentProps<typeof DashboardPanelSelectionListFlyout>, 'fetchDashboardPanels'>) =>
render(
<IntlProvider locale="en">
<DashboardPanelSelectionListFlyout
{...defaultProps}
fetchDashboardPanels={fetchDashboardPanels}
/>
</IntlProvider>
);

const panelConfiguration: GroupedAddPanelActions[] = [
{
id: 'panel1',
title: 'App 1',
items: [
{
icon: 'icon1',
id: 'mockFactory',
name: 'Factory 1',
description: 'Factory 1 description',
'data-test-subj': 'createNew-mockFactory',
onClick: jest.fn(),
order: 0,
},
],
order: 10,
'data-test-subj': 'dashboardEditorMenu-group1Group',
},
];

describe('DashboardPanelSelectionListFlyout', () => {
it('renders a loading indicator when fetchDashboardPanel has not yielded any value', async () => {
const promiseDelay = 5000;

renderComponent({
fetchDashboardPanels: jest.fn(
() =>
new Promise((resolve) => {
setTimeout(() => resolve(panelConfiguration), promiseDelay);
})
),
});

expect(
await screen.findByTestId('dashboardPanelSelectionLoadingIndicator')
).toBeInTheDocument();
});

it('renders an error indicator when fetchDashboardPanel errors', async () => {
renderComponent({
fetchDashboardPanels: jest.fn().mockRejectedValue(new Error('simulated error')),
});

expect(await screen.findByTestId('dashboardPanelSelectionErrorIndicator')).toBeInTheDocument();
});

it('renders the list of available panels when fetchDashboardPanel resolves a value', async () => {
renderComponent({ fetchDashboardPanels: jest.fn().mockResolvedValue(panelConfiguration) });

expect(await screen.findByTestId(panelConfiguration[0]['data-test-subj']!)).toBeInTheDocument();
});

it('renders a not found message when a user searches for an item that is not in the selection list', async () => {
renderComponent({ fetchDashboardPanels: jest.fn().mockResolvedValue(panelConfiguration) });

expect(await screen.findByTestId(panelConfiguration[0]['data-test-subj']!)).toBeInTheDocument();

act(() => {
userEvent.type(
screen.getByTestId('dashboardPanelSelectionFlyout__searchInput'),
'non existent panel'
);
});

expect(await screen.findByTestId('dashboardPanelSelectionNoPanelMessage')).toBeInTheDocument();
});

it('invokes the close method when the flyout close btn is clicked', async () => {
renderComponent({ fetchDashboardPanels: jest.fn().mockResolvedValue(panelConfiguration) });

fireEvent.click(await screen.findByTestId('dashboardPanelSelectionCloseBtn'));

expect(defaultProps.close).toHaveBeenCalled();
});
});
Loading

0 comments on commit ef63a40

Please sign in to comment.