diff --git a/x-pack/plugins/cases/public/components/create/custom_fields.test.tsx b/x-pack/plugins/cases/public/components/create/custom_fields.test.tsx index 45fe037371b64..864ba68ff690a 100644 --- a/x-pack/plugins/cases/public/components/create/custom_fields.test.tsx +++ b/x-pack/plugins/cases/public/components/create/custom_fields.test.tsx @@ -16,8 +16,7 @@ import { customFieldsConfigurationMock } from '../../containers/mock'; import { CustomFields } from './custom_fields'; import * as i18n from './translations'; -// FLAKY: https://github.com/elastic/kibana/issues/176805 -describe.skip('CustomFields', () => { +describe('CustomFields', () => { let appMockRender: AppMockRenderer; const onSubmit = jest.fn(); diff --git a/x-pack/plugins/cases/public/components/create/flyout/create_case_flyout.test.tsx b/x-pack/plugins/cases/public/components/create/flyout/create_case_flyout.test.tsx index 2d0b86b142a14..ae41ae9ac2648 100644 --- a/x-pack/plugins/cases/public/components/create/flyout/create_case_flyout.test.tsx +++ b/x-pack/plugins/cases/public/components/create/flyout/create_case_flyout.test.tsx @@ -6,14 +6,30 @@ */ import React from 'react'; -import { act } from '@testing-library/react'; +import { screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { CreateCaseFlyout } from './create_case_flyout'; import type { AppMockRenderer } from '../../../common/mock'; import { createAppMockRenderer } from '../../../common/mock'; +import { useGetTags } from '../../../containers/use_get_tags'; +import { useGetCaseConfiguration } from '../../../containers/configure/use_get_case_configuration'; +import { useGetSupportedActionConnectors } from '../../../containers/configure/use_get_supported_action_connectors'; +import { useAvailableCasesOwners } from '../../app/use_available_owners'; +import { connectorsMock } from '../../../containers/mock'; +import { useCaseConfigureResponse } from '../../configure_cases/__mock__'; +import { waitForComponentToUpdate } from '../../../common/test_utils'; -jest.mock('../../../common/lib/kibana'); +jest.mock('../../../containers/use_get_tags'); +jest.mock('../../../containers/configure/use_get_supported_action_connectors'); +jest.mock('../../../containers/configure/use_get_case_configuration'); +jest.mock('../../markdown_editor/plugins/lens/use_lens_draft_comment'); +jest.mock('../../app/use_available_owners'); + +const useGetTagsMock = useGetTags as jest.Mock; +const useGetConnectorsMock = useGetSupportedActionConnectors as jest.Mock; +const useGetCaseConfigurationMock = useGetCaseConfiguration as jest.Mock; +const useAvailableOwnersMock = useAvailableCasesOwners as jest.Mock; const onClose = jest.fn(); const onSuccess = jest.fn(); @@ -23,49 +39,49 @@ const defaultProps = { owner: 'securitySolution', }; -// FLAKY: https://github.com/elastic/kibana/issues/174525 -// FLAKY: https://github.com/elastic/kibana/issues/174526 -// FLAKY: https://github.com/elastic/kibana/issues/174527 -// FLAKY: https://github.com/elastic/kibana/issues/174528 -describe.skip('CreateCaseFlyout', () => { - let mockedContext: AppMockRenderer; +describe('CreateCaseFlyout', () => { + let appMockRenderer: AppMockRenderer; + beforeEach(() => { - mockedContext = createAppMockRenderer(); jest.clearAllMocks(); + appMockRenderer = createAppMockRenderer(); + useAvailableOwnersMock.mockReturnValue(['securitySolution', 'observability']); + useGetTagsMock.mockReturnValue({ data: ['test'] }); + useGetConnectorsMock.mockReturnValue({ isLoading: false, data: connectorsMock }); + useGetCaseConfigurationMock.mockImplementation(() => useCaseConfigureResponse); }); it('renders', async () => { - const { getByTestId } = mockedContext.render(); - await act(async () => { - expect(getByTestId('create-case-flyout')).toBeTruthy(); - }); + appMockRenderer.render(); + await waitForComponentToUpdate(); + + expect(await screen.findByTestId('create-case-flyout')).toBeInTheDocument(); }); it('should call onCloseCaseModal when closing the flyout', async () => { - const { getByTestId } = mockedContext.render(); - await act(async () => { - userEvent.click(getByTestId('euiFlyoutCloseButton')); + appMockRenderer.render(); + await waitForComponentToUpdate(); + + userEvent.click(await screen.findByTestId('euiFlyoutCloseButton')); + + await waitFor(() => { + expect(onClose).toBeCalled(); }); - expect(onClose).toBeCalled(); }); it('renders headerContent when passed', async () => { const headerContent =

; - const { getByTestId } = mockedContext.render( - - ); + appMockRenderer.render(); + await waitForComponentToUpdate(); - await act(async () => { - expect(getByTestId('testing123')).toBeTruthy(); - expect(getByTestId('create-case-flyout-header').children.length).toEqual(2); - }); + expect(await screen.findByTestId('testing123')).toBeInTheDocument(); + expect((await screen.findByTestId('create-case-flyout-header')).children.length).toEqual(2); }); it('does not render headerContent when undefined', async () => { - const { getByTestId } = mockedContext.render(); + appMockRenderer.render(); + await waitForComponentToUpdate(); - await act(async () => { - expect(getByTestId('create-case-flyout-header').children.length).toEqual(1); - }); + expect((await screen.findByTestId('create-case-flyout-header')).children.length).toEqual(1); }); }); diff --git a/x-pack/plugins/cases/public/components/custom_fields/index.test.tsx b/x-pack/plugins/cases/public/components/custom_fields/index.test.tsx index 188fb08d4016e..15a280716c3c0 100644 --- a/x-pack/plugins/cases/public/components/custom_fields/index.test.tsx +++ b/x-pack/plugins/cases/public/components/custom_fields/index.test.tsx @@ -17,8 +17,7 @@ import { MAX_CUSTOM_FIELDS_PER_CASE } from '../../../common/constants'; import { CustomFields } from '.'; import * as i18n from './translations'; -// Flaky: https://github.com/elastic/kibana/issues/176805 -describe.skip('CustomFields', () => { +describe('CustomFields', () => { let appMockRender: AppMockRenderer; const props = { diff --git a/x-pack/plugins/cases/public/components/custom_fields/text/configure.test.tsx b/x-pack/plugins/cases/public/components/custom_fields/text/configure.test.tsx index 29d3f4268443a..455163f225a2b 100644 --- a/x-pack/plugins/cases/public/components/custom_fields/text/configure.test.tsx +++ b/x-pack/plugins/cases/public/components/custom_fields/text/configure.test.tsx @@ -12,8 +12,7 @@ import userEvent from '@testing-library/user-event'; import { FormTestComponent } from '../../../common/test_utils'; import { Configure } from './configure'; -// Failing: See https://github.com/elastic/kibana/issues/176600 -describe.skip('Configure ', () => { +describe('Configure ', () => { const onSubmit = jest.fn(); beforeEach(() => {