From 8ca35cf032439569b58b5bc15c7daba0424a84af Mon Sep 17 00:00:00 2001
From: wafaanasr
Date: Tue, 18 Oct 2022 15:15:37 +0200
Subject: [PATCH] add missing tests
---
.../__snapshots__/list_header.test.tsx.snap | 1339 ++++++++++++++++-
.../__snapshots__/edit_modal.test.tsx.snap | 227 +++
.../edit_modal/edit_modal.test.tsx | 71 +
.../src/list_header/edit_modal/index.tsx | 29 +-
.../src/list_header/index.tsx | 82 +-
.../src/list_header/list_header.test.tsx | 65 +-
.../__snapshots__/menu_items.test.tsx.snap | 248 +++
.../src/list_header/menu_items/index.tsx | 4 +-
.../menu_items/menu_items.test.tsx | 81 +
.../src/list_header/use_list_header.test.ts | 92 ++
.../src/text_with_edit/index.tsx | 2 +-
11 files changed, 2117 insertions(+), 123 deletions(-)
create mode 100644 packages/kbn-securitysolution-exception-list-components/src/list_header/edit_modal/__snapshots__/edit_modal.test.tsx.snap
create mode 100644 packages/kbn-securitysolution-exception-list-components/src/list_header/edit_modal/edit_modal.test.tsx
create mode 100644 packages/kbn-securitysolution-exception-list-components/src/list_header/menu_items/__snapshots__/menu_items.test.tsx.snap
create mode 100644 packages/kbn-securitysolution-exception-list-components/src/list_header/menu_items/menu_items.test.tsx
create mode 100644 packages/kbn-securitysolution-exception-list-components/src/list_header/use_list_header.test.ts
diff --git a/packages/kbn-securitysolution-exception-list-components/src/list_header/__snapshots__/list_header.test.tsx.snap b/packages/kbn-securitysolution-exception-list-components/src/list_header/__snapshots__/list_header.test.tsx.snap
index c1c8196ac288d..5db6db5c6b467 100644
--- a/packages/kbn-securitysolution-exception-list-components/src/list_header/__snapshots__/list_header.test.tsx.snap
+++ b/packages/kbn-securitysolution-exception-list-components/src/list_header/__snapshots__/list_header.test.tsx.snap
@@ -1,6 +1,1227 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`ExceptionListHeader should render the List Header with name, default Description and disabled actions because of the ReadOnly mode 1`] = `
+exports[`ExceptionListHeader should render edit modal 1`] = `
+Object {
+ "asFragment": [Function],
+ "baseElement":
+
+
+ ,
+ "container": ,
+ "debug": [Function],
+ "findAllByAltText": [Function],
+ "findAllByDisplayValue": [Function],
+ "findAllByLabelText": [Function],
+ "findAllByPlaceholderText": [Function],
+ "findAllByRole": [Function],
+ "findAllByTestId": [Function],
+ "findAllByText": [Function],
+ "findAllByTitle": [Function],
+ "findByAltText": [Function],
+ "findByDisplayValue": [Function],
+ "findByLabelText": [Function],
+ "findByPlaceholderText": [Function],
+ "findByRole": [Function],
+ "findByTestId": [Function],
+ "findByText": [Function],
+ "findByTitle": [Function],
+ "getAllByAltText": [Function],
+ "getAllByDisplayValue": [Function],
+ "getAllByLabelText": [Function],
+ "getAllByPlaceholderText": [Function],
+ "getAllByRole": [Function],
+ "getAllByTestId": [Function],
+ "getAllByText": [Function],
+ "getAllByTitle": [Function],
+ "getByAltText": [Function],
+ "getByDisplayValue": [Function],
+ "getByLabelText": [Function],
+ "getByPlaceholderText": [Function],
+ "getByRole": [Function],
+ "getByTestId": [Function],
+ "getByText": [Function],
+ "getByTitle": [Function],
+ "queryAllByAltText": [Function],
+ "queryAllByDisplayValue": [Function],
+ "queryAllByLabelText": [Function],
+ "queryAllByPlaceholderText": [Function],
+ "queryAllByRole": [Function],
+ "queryAllByTestId": [Function],
+ "queryAllByText": [Function],
+ "queryAllByTitle": [Function],
+ "queryByAltText": [Function],
+ "queryByDisplayValue": [Function],
+ "queryByLabelText": [Function],
+ "queryByPlaceholderText": [Function],
+ "queryByRole": [Function],
+ "queryByTestId": [Function],
+ "queryByText": [Function],
+ "queryByTitle": [Function],
+ "rerender": [Function],
+ "unmount": [Function],
+}
+`;
+
+exports[`ExceptionListHeader should render the List Header with name, default description and actions 1`] = `
+Object {
+ "asFragment": [Function],
+ "baseElement":
+
+ ,
+ "container": ,
+ "debug": [Function],
+ "findAllByAltText": [Function],
+ "findAllByDisplayValue": [Function],
+ "findAllByLabelText": [Function],
+ "findAllByPlaceholderText": [Function],
+ "findAllByRole": [Function],
+ "findAllByTestId": [Function],
+ "findAllByText": [Function],
+ "findAllByTitle": [Function],
+ "findByAltText": [Function],
+ "findByDisplayValue": [Function],
+ "findByLabelText": [Function],
+ "findByPlaceholderText": [Function],
+ "findByRole": [Function],
+ "findByTestId": [Function],
+ "findByText": [Function],
+ "findByTitle": [Function],
+ "getAllByAltText": [Function],
+ "getAllByDisplayValue": [Function],
+ "getAllByLabelText": [Function],
+ "getAllByPlaceholderText": [Function],
+ "getAllByRole": [Function],
+ "getAllByTestId": [Function],
+ "getAllByText": [Function],
+ "getAllByTitle": [Function],
+ "getByAltText": [Function],
+ "getByDisplayValue": [Function],
+ "getByLabelText": [Function],
+ "getByPlaceholderText": [Function],
+ "getByRole": [Function],
+ "getByTestId": [Function],
+ "getByText": [Function],
+ "getByTitle": [Function],
+ "queryAllByAltText": [Function],
+ "queryAllByDisplayValue": [Function],
+ "queryAllByLabelText": [Function],
+ "queryAllByPlaceholderText": [Function],
+ "queryAllByRole": [Function],
+ "queryAllByTestId": [Function],
+ "queryAllByText": [Function],
+ "queryAllByTitle": [Function],
+ "queryByAltText": [Function],
+ "queryByDisplayValue": [Function],
+ "queryByLabelText": [Function],
+ "queryByPlaceholderText": [Function],
+ "queryByRole": [Function],
+ "queryByTestId": [Function],
+ "queryByText": [Function],
+ "queryByTitle": [Function],
+ "rerender": [Function],
+ "unmount": [Function],
+}
+`;
+
+exports[`ExceptionListHeader should render the List Header with name, default description and disabled actions because of the ReadOnly mode 1`] = `
Object {
"asFragment": [Function],
"baseElement":
@@ -31,14 +1252,14 @@ Object {
title="Rule exceptions"
type="button"
>
-
Rule exceptions
-
+
@@ -52,41 +1273,39 @@ Object {
-
-
+
-
Rule exceptions
-
+
@@ -265,41 +1486,39 @@ Object {
-
-
+
+
+
+ ,
+ "container":
,
+ "debug": [Function],
+ "findAllByAltText": [Function],
+ "findAllByDisplayValue": [Function],
+ "findAllByLabelText": [Function],
+ "findAllByPlaceholderText": [Function],
+ "findAllByRole": [Function],
+ "findAllByTestId": [Function],
+ "findAllByText": [Function],
+ "findAllByTitle": [Function],
+ "findByAltText": [Function],
+ "findByDisplayValue": [Function],
+ "findByLabelText": [Function],
+ "findByPlaceholderText": [Function],
+ "findByRole": [Function],
+ "findByTestId": [Function],
+ "findByText": [Function],
+ "findByTitle": [Function],
+ "getAllByAltText": [Function],
+ "getAllByDisplayValue": [Function],
+ "getAllByLabelText": [Function],
+ "getAllByPlaceholderText": [Function],
+ "getAllByRole": [Function],
+ "getAllByTestId": [Function],
+ "getAllByText": [Function],
+ "getAllByTitle": [Function],
+ "getByAltText": [Function],
+ "getByDisplayValue": [Function],
+ "getByLabelText": [Function],
+ "getByPlaceholderText": [Function],
+ "getByRole": [Function],
+ "getByTestId": [Function],
+ "getByText": [Function],
+ "getByTitle": [Function],
+ "queryAllByAltText": [Function],
+ "queryAllByDisplayValue": [Function],
+ "queryAllByLabelText": [Function],
+ "queryAllByPlaceholderText": [Function],
+ "queryAllByRole": [Function],
+ "queryAllByTestId": [Function],
+ "queryAllByText": [Function],
+ "queryAllByTitle": [Function],
+ "queryByAltText": [Function],
+ "queryByDisplayValue": [Function],
+ "queryByLabelText": [Function],
+ "queryByPlaceholderText": [Function],
+ "queryByRole": [Function],
+ "queryByTestId": [Function],
+ "queryByText": [Function],
+ "queryByTitle": [Function],
+ "rerender": [Function],
+ "unmount": [Function],
+}
+`;
diff --git a/packages/kbn-securitysolution-exception-list-components/src/list_header/edit_modal/edit_modal.test.tsx b/packages/kbn-securitysolution-exception-list-components/src/list_header/edit_modal/edit_modal.test.tsx
new file mode 100644
index 0000000000000..39786c1723b4f
--- /dev/null
+++ b/packages/kbn-securitysolution-exception-list-components/src/list_header/edit_modal/edit_modal.test.tsx
@@ -0,0 +1,71 @@
+/*
+ * 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 from 'react';
+import { fireEvent, render } from '@testing-library/react';
+import { EditModal } from '.';
+
+const onSave = jest.fn();
+const onCancel = jest.fn();
+
+describe('EditModal', () => {
+ it('should render the title and description from listDetails', () => {
+ const wrapper = render(
+
+ );
+ expect(wrapper).toMatchSnapshot();
+ expect(wrapper.getByTestId('editModalTitle')).toHaveTextContent('list name');
+ });
+ it('should call onSave', () => {
+ const wrapper = render(
+
+ );
+ fireEvent.submit(wrapper.getByTestId('editModalForm'));
+ expect(onSave).toBeCalled();
+ });
+ it('should call onCancel', () => {
+ const wrapper = render(
+
+ );
+ fireEvent.click(wrapper.getByTestId('editModalCancelBtn'));
+ expect(onCancel).toBeCalled();
+ });
+
+ it('should call change title, description and call onSave with the new props', () => {
+ const wrapper = render(
+
+ );
+ fireEvent.change(wrapper.getByTestId('editModalNameTextField'), {
+ target: { value: 'New list name' },
+ });
+ fireEvent.change(wrapper.getByTestId('editModalDescriptionTextField'), {
+ target: { value: 'New description name' },
+ });
+ fireEvent.submit(wrapper.getByTestId('editModalForm'));
+
+ expect(onSave).toBeCalledWith({
+ name: 'New list name',
+ description: 'New description name',
+ });
+ });
+});
diff --git a/packages/kbn-securitysolution-exception-list-components/src/list_header/edit_modal/index.tsx b/packages/kbn-securitysolution-exception-list-components/src/list_header/edit_modal/index.tsx
index 6363a1a3a5db8..8ef4174128436 100644
--- a/packages/kbn-securitysolution-exception-list-components/src/list_header/edit_modal/index.tsx
+++ b/packages/kbn-securitysolution-exception-list-components/src/list_header/edit_modal/index.tsx
@@ -40,21 +40,32 @@ const EditModalComponent: FC
= ({ listDetails, onSave, onCancel
onSave(newListDetails);
};
return (
-
+
-
+
{i18n.EXCEPTION_LIST_HEADER_EDIT_MODAL_TITLE(listDetails.name)}
-
+
-
+
= ({ listDetails, onSave, onCancel
-
+
{i18n.EXCEPTION_LIST_HEADER_EDIT_MODAL_CANCEL_BUTTON}
-
+
{i18n.EXCEPTION_LIST_HEADER_EDIT_MODAL_SAVE_BUTTON}
diff --git a/packages/kbn-securitysolution-exception-list-components/src/list_header/index.tsx b/packages/kbn-securitysolution-exception-list-components/src/list_header/index.tsx
index 288e6891e3c9e..570be26e2e84c 100644
--- a/packages/kbn-securitysolution-exception-list-components/src/list_header/index.tsx
+++ b/packages/kbn-securitysolution-exception-list-components/src/list_header/index.tsx
@@ -8,7 +8,7 @@
import React from 'react';
import type { FC } from 'react';
-import { EuiIcon, EuiPageHeader, EuiPageHeaderSection, EuiText, EuiTitle } from '@elastic/eui';
+import { EuiIcon, EuiPageHeader, EuiText } from '@elastic/eui';
import * as i18n from '../translations';
import {
textWithEditContainerCss,
@@ -25,7 +25,7 @@ import { useExceptionListHeader } from './use_list_header';
interface ExceptionListHeaderComponentProps {
name: string;
description?: string;
- listId?: string;
+ listId: string;
isReadonly: boolean;
linkedRules: Rule[];
dataTestSubj?: string;
@@ -61,31 +61,31 @@ const ExceptionListHeaderComponent: FC = ({
- // }
+ pageTitle={
+
+ }
responsive
data-test-subj={`${dataTestSubj || ''}PageHeader`}
- // description={
- //
- //
- //
- // {i18n.EXCEPTION_LIST_HEADER_LIST_ID}:
- // {listId}
- //
- //
- // }
+ description={
+
+
+
+ {i18n.EXCEPTION_LIST_HEADER_LIST_ID}:
+ {listId}
+
+
+ }
rightSideItems={[
= ({
breadcrumbs={[
{
text: (
-
+
{i18n.EXCEPTION_LIST_HEADER_BREADCRUMB}
-
+
),
color: 'primary',
'aria-current': false,
@@ -111,33 +111,7 @@ const ExceptionListHeaderComponent: FC = ({
onClick: (e) => e.preventDefault(),
},
]}
- >
-
-
-
-
-
-
-
-
-
- {i18n.EXCEPTION_LIST_HEADER_LIST_ID}:
- {listId}
-
-
-
-
+ />
{isModalVisible && (
)}
diff --git a/packages/kbn-securitysolution-exception-list-components/src/list_header/list_header.test.tsx b/packages/kbn-securitysolution-exception-list-components/src/list_header/list_header.test.tsx
index efa61d30078b3..df56194ce88e2 100644
--- a/packages/kbn-securitysolution-exception-list-components/src/list_header/list_header.test.tsx
+++ b/packages/kbn-securitysolution-exception-list-components/src/list_header/list_header.test.tsx
@@ -11,15 +11,26 @@ import { ExceptionListHeader } from '.';
import * as i18n from '../translations';
import { securityLinkAnchorComponentMock } from '../mocks/security_link_component.mock';
+import { useExceptionListHeader as useExceptionListHeaderMock } from './use_list_header';
const onEditListDetails = jest.fn();
const onExportList = jest.fn();
const onDeleteList = jest.fn();
const onManageRules = jest.fn();
+jest.mock('./use_list_header');
describe('ExceptionListHeader', () => {
- it('should render the List Header with name, default Description and disabled actions because of the ReadOnly mode', () => {
+ beforeAll(() => {
+ (useExceptionListHeaderMock as jest.Mock).mockReturnValue({
+ isModalVisible: false,
+ listDetails: { name: 'List Name', description: '' },
+ onSave: jest.fn(),
+ onCancel: jest.fn(),
+ });
+ });
+ it('should render the List Header with name, default description and disabled actions because of the ReadOnly mode', () => {
const wrapper = render(
{
i18n.EXCEPTION_LIST_HEADER_DESCRIPTION
);
expect(wrapper.queryByTestId('EditTitleIcon')).not.toBeInTheDocument();
+ expect(wrapper.getByTestId('ListID')).toHaveTextContent(
+ `${i18n.EXCEPTION_LIST_HEADER_LIST_ID}:List_Id`
+ );
+ expect(wrapper.getByTestId('Breadcrumb')).toHaveTextContent(
+ i18n.EXCEPTION_LIST_HEADER_BREADCRUMB
+ );
+ });
+ it('should render the List Header with name, default description and actions', () => {
+ const wrapper = render(
+
+ );
+ expect(wrapper).toMatchSnapshot();
+ fireEvent.click(wrapper.getByTestId('RightSideMenuItemsContainer'));
+ expect(wrapper.getByTestId('DescriptionText')).toHaveTextContent(
+ i18n.EXCEPTION_LIST_HEADER_DESCRIPTION
+ );
+ expect(wrapper.queryByTestId('TitleEditIcon')).toBeInTheDocument();
+ expect(wrapper.queryByTestId('DescriptionEditIcon')).toBeInTheDocument();
+ });
+ it('should render edit modal', () => {
+ (useExceptionListHeaderMock as jest.Mock).mockReturnValue({
+ isModalVisible: true,
+ listDetails: { name: 'List Name', description: 'List description' },
+ onSave: jest.fn(),
+ onCancel: jest.fn(),
+ });
+ const wrapper = render(
+
+ );
+ expect(wrapper).toMatchSnapshot();
+ expect(wrapper.getByTestId('EditModal')).toBeInTheDocument();
});
});
diff --git a/packages/kbn-securitysolution-exception-list-components/src/list_header/menu_items/__snapshots__/menu_items.test.tsx.snap b/packages/kbn-securitysolution-exception-list-components/src/list_header/menu_items/__snapshots__/menu_items.test.tsx.snap
new file mode 100644
index 0000000000000..ab3ad9df8aa81
--- /dev/null
+++ b/packages/kbn-securitysolution-exception-list-components/src/list_header/menu_items/__snapshots__/menu_items.test.tsx.snap
@@ -0,0 +1,248 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`MenuItems should render linkedRules, manageRules and menuActions 1`] = `
+Object {
+ "asFragment": [Function],
+ "baseElement":
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ,
+ "container":
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
,
+ "debug": [Function],
+ "findAllByAltText": [Function],
+ "findAllByDisplayValue": [Function],
+ "findAllByLabelText": [Function],
+ "findAllByPlaceholderText": [Function],
+ "findAllByRole": [Function],
+ "findAllByTestId": [Function],
+ "findAllByText": [Function],
+ "findAllByTitle": [Function],
+ "findByAltText": [Function],
+ "findByDisplayValue": [Function],
+ "findByLabelText": [Function],
+ "findByPlaceholderText": [Function],
+ "findByRole": [Function],
+ "findByTestId": [Function],
+ "findByText": [Function],
+ "findByTitle": [Function],
+ "getAllByAltText": [Function],
+ "getAllByDisplayValue": [Function],
+ "getAllByLabelText": [Function],
+ "getAllByPlaceholderText": [Function],
+ "getAllByRole": [Function],
+ "getAllByTestId": [Function],
+ "getAllByText": [Function],
+ "getAllByTitle": [Function],
+ "getByAltText": [Function],
+ "getByDisplayValue": [Function],
+ "getByLabelText": [Function],
+ "getByPlaceholderText": [Function],
+ "getByRole": [Function],
+ "getByTestId": [Function],
+ "getByText": [Function],
+ "getByTitle": [Function],
+ "queryAllByAltText": [Function],
+ "queryAllByDisplayValue": [Function],
+ "queryAllByLabelText": [Function],
+ "queryAllByPlaceholderText": [Function],
+ "queryAllByRole": [Function],
+ "queryAllByTestId": [Function],
+ "queryAllByText": [Function],
+ "queryAllByTitle": [Function],
+ "queryByAltText": [Function],
+ "queryByDisplayValue": [Function],
+ "queryByLabelText": [Function],
+ "queryByPlaceholderText": [Function],
+ "queryByRole": [Function],
+ "queryByTestId": [Function],
+ "queryByText": [Function],
+ "queryByTitle": [Function],
+ "rerender": [Function],
+ "unmount": [Function],
+}
+`;
diff --git a/packages/kbn-securitysolution-exception-list-components/src/list_header/menu_items/index.tsx b/packages/kbn-securitysolution-exception-list-components/src/list_header/menu_items/index.tsx
index 730540ea98f13..c95e312dd76c1 100644
--- a/packages/kbn-securitysolution-exception-list-components/src/list_header/menu_items/index.tsx
+++ b/packages/kbn-securitysolution-exception-list-components/src/list_header/menu_items/index.tsx
@@ -52,7 +52,7 @@ const MenuItemsComponent: FC = ({
>
= ({
{
+ it('should render linkedRules, manageRules and menuActions', () => {
+ const wrapper = render(
+
+ );
+ expect(wrapper).toMatchSnapshot();
+ expect(wrapper.getByTestId('LinkedRulesMenuItems')).toHaveTextContent('Linked to 1 rules');
+ expect(wrapper.getByTestId('ManageRulesButton')).toBeInTheDocument();
+ expect(wrapper.getByTestId('MenuActionsButtonIcon')).toBeInTheDocument();
+ });
+ it('should call onManageRules', () => {
+ const wrapper = render(
+
+ );
+ fireEvent.click(wrapper.getByTestId('ManageRulesButton'));
+ expect(onManageRules).toHaveBeenCalled();
+ });
+ it('should call onExportList', () => {
+ const wrapper = render(
+
+ );
+ fireEvent.click(wrapper.getByTestId('MenuActionsButtonIcon'));
+ fireEvent.click(wrapper.getByTestId('MenuActionsActionItem1'));
+
+ expect(onExportList).toHaveBeenCalled();
+ });
+ it('should call onDeleteList', () => {
+ const wrapper = render(
+
+ );
+ fireEvent.click(wrapper.getByTestId('MenuActionsButtonIcon'));
+ fireEvent.click(wrapper.getByTestId('MenuActionsActionItem2'));
+
+ expect(onDeleteList).toHaveBeenCalled();
+ });
+});
diff --git a/packages/kbn-securitysolution-exception-list-components/src/list_header/use_list_header.test.ts b/packages/kbn-securitysolution-exception-list-components/src/list_header/use_list_header.test.ts
new file mode 100644
index 0000000000000..9ddd782e132cd
--- /dev/null
+++ b/packages/kbn-securitysolution-exception-list-components/src/list_header/use_list_header.test.ts
@@ -0,0 +1,92 @@
+/*
+ * 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 { waitFor } from '@testing-library/dom';
+import { act, renderHook } from '@testing-library/react-hooks';
+import { useExceptionListHeader } from './use_list_header';
+
+describe('useExceptionListHeader', () => {
+ const onEditListDetails = jest.fn();
+ it('should return the default values', () => {
+ const {
+ result: { current },
+ } = renderHook(() =>
+ useExceptionListHeader({ name: 'list name', description: '', onEditListDetails })
+ );
+ const { isModalVisible, listDetails } = current;
+ expect(isModalVisible).toBeFalsy();
+ expect(listDetails).toStrictEqual({ name: 'list name', description: '' });
+ });
+ it('should change the isModalVisible to be true when onEdit is called', () => {
+ const {
+ result: { current },
+ } = renderHook(() =>
+ useExceptionListHeader({ name: 'list name', description: '', onEditListDetails })
+ );
+ const { isModalVisible, onEdit } = current;
+ act(() => {
+ onEdit();
+ });
+
+ waitFor(() => {
+ expect(isModalVisible).toBeTruthy();
+ });
+ });
+
+ it('should call onEditListDetails with the new details after editing', () => {
+ const {
+ result: { current },
+ } = renderHook(() =>
+ useExceptionListHeader({ name: 'list name', description: '', onEditListDetails })
+ );
+ const { isModalVisible, onEdit } = current;
+ act(() => {
+ onEdit();
+ });
+
+ waitFor(() => {
+ expect(isModalVisible).toBeTruthy();
+ });
+
+ const { onSave } = current;
+ act(() => {
+ onSave({ name: 'New name', description: 'New Description' });
+ });
+
+ waitFor(() => {
+ expect(isModalVisible).toBeFalsy();
+ expect(onEditListDetails).toBeCalledWith({
+ name: 'New name',
+ description: 'New Description',
+ });
+ });
+ });
+ it('should close the Modal when the cancel is called', () => {
+ const {
+ result: { current },
+ } = renderHook(() =>
+ useExceptionListHeader({ name: 'list name', description: '', onEditListDetails })
+ );
+ const { isModalVisible, onEdit } = current;
+ act(() => {
+ onEdit();
+ });
+
+ waitFor(() => {
+ expect(isModalVisible).toBeTruthy();
+ });
+
+ const { onCancel } = current;
+ act(() => {
+ onCancel();
+ });
+
+ waitFor(() => {
+ expect(isModalVisible).toBeFalsy();
+ });
+ });
+});
diff --git a/packages/kbn-securitysolution-exception-list-components/src/text_with_edit/index.tsx b/packages/kbn-securitysolution-exception-list-components/src/text_with_edit/index.tsx
index c9eaf02311e03..5b56b27053396 100644
--- a/packages/kbn-securitysolution-exception-list-components/src/text_with_edit/index.tsx
+++ b/packages/kbn-securitysolution-exception-list-components/src/text_with_edit/index.tsx
@@ -33,7 +33,7 @@ const TextWithEditComponent: FC = ({
{isReadonly ? null : (
(typeof onEdit === 'function' ? onEdit() : null)}