diff --git a/x-pack/plugins/cases/public/common/mock/test_providers.tsx b/x-pack/plugins/cases/public/common/mock/test_providers.tsx index 820ae554c3aa7..aef1024cc8afc 100644 --- a/x-pack/plugins/cases/public/common/mock/test_providers.tsx +++ b/x-pack/plugins/cases/public/common/mock/test_providers.tsx @@ -9,7 +9,7 @@ import React, { useMemo } from 'react'; import { MemoryRouter } from 'react-router-dom'; -import { render as reactRender } from '@testing-library/react'; +import { render as reactRender, waitFor } from '@testing-library/react'; import type { RenderOptions, RenderResult } from '@testing-library/react'; import type { ILicense } from '@kbn/licensing-plugin/public'; import type { ScopedFilesClient } from '@kbn/files-plugin/public'; @@ -124,6 +124,7 @@ export interface AppMockRenderer { queryClient: QueryClient; AppWrapper: React.FC<{ children: React.ReactNode }>; getFilesClient: () => ScopedFilesClient; + clearQueryCache: () => Promise; } export const testQueryClient = new QueryClient({ @@ -202,6 +203,12 @@ export const createAppMockRenderer = ({ }); }; + const clearQueryCache = async () => { + queryClient.getQueryCache().clear(); + + await waitFor(() => expect(queryClient.isFetching()).toBe(0)); + }; + return { coreStart: services, queryClient, @@ -210,5 +217,6 @@ export const createAppMockRenderer = ({ externalReferenceAttachmentTypeRegistry, persistableStateAttachmentTypeRegistry, getFilesClient, + clearQueryCache, }; }; diff --git a/x-pack/plugins/cases/public/components/all_cases/columns_popover.test.tsx b/x-pack/plugins/cases/public/components/all_cases/columns_popover.test.tsx index 4d6eb887c86d5..109ad955f629f 100644 --- a/x-pack/plugins/cases/public/components/all_cases/columns_popover.test.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/columns_popover.test.tsx @@ -14,8 +14,7 @@ import type { AppMockRenderer } from '../../common/mock'; import { createAppMockRenderer } from '../../common/mock'; import { ColumnsPopover } from './columns_popover'; -// FLAKY: https://github.com/elastic/kibana/issues/174682 -describe.skip('ColumnsPopover', () => { +describe('ColumnsPopover', () => { let appMockRenderer: AppMockRenderer; beforeEach(() => { @@ -23,6 +22,10 @@ describe.skip('ColumnsPopover', () => { jest.clearAllMocks(); }); + afterEach(async () => { + await appMockRenderer.clearQueryCache(); + }); + const selectedColumns = [ { field: 'title', name: 'Title', isChecked: true }, { field: 'category', name: 'Category', isChecked: false }, diff --git a/x-pack/plugins/cases/public/components/all_cases/use_actions.test.tsx b/x-pack/plugins/cases/public/components/all_cases/use_actions.test.tsx index 4335d24910f39..9256f4aad82fe 100644 --- a/x-pack/plugins/cases/public/components/all_cases/use_actions.test.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/use_actions.test.tsx @@ -28,8 +28,7 @@ import { jest.mock('../../containers/api'); jest.mock('../../containers/user_profiles/api'); -// FLAKY: https://github.com/elastic/kibana/issues/188361 -describe.skip('useActions', () => { +describe('useActions', () => { let appMockRender: AppMockRenderer; beforeEach(() => { @@ -37,6 +36,10 @@ describe.skip('useActions', () => { jest.clearAllMocks(); }); + afterEach(async () => { + await appMockRender.clearQueryCache(); + }); + it('renders column actions', async () => { const { result } = renderHook(() => useActions({ disableActions: false }), { wrapper: appMockRender.AppWrapper, diff --git a/x-pack/plugins/cases/public/components/case_form_fields/severity.test.tsx b/x-pack/plugins/cases/public/components/case_form_fields/severity.test.tsx index d063c2fea3421..9502c6b709220 100644 --- a/x-pack/plugins/cases/public/components/case_form_fields/severity.test.tsx +++ b/x-pack/plugins/cases/public/components/case_form_fields/severity.test.tsx @@ -6,7 +6,9 @@ */ import React from 'react'; -import { screen, waitFor, render } from '@testing-library/react'; +import { screen, waitFor } from '@testing-library/react'; +import type { AppMockRenderer } from '../../common/mock'; +import { createAppMockRenderer } from '../../common/mock'; import { Severity } from './severity'; import userEvent from '@testing-library/user-event'; import { waitForEuiPopoverOpen } from '@elastic/eui/lib/test/rtl'; @@ -15,8 +17,18 @@ import { FormTestComponent } from '../../common/test_utils'; const onSubmit = jest.fn(); describe('Severity form field', () => { + let appMockRender: AppMockRenderer; + + beforeEach(() => { + appMockRender = createAppMockRenderer(); + }); + + afterEach(async () => { + await appMockRender.clearQueryCache(); + }); + it('renders', async () => { - render( + appMockRender.render( @@ -28,7 +40,7 @@ describe('Severity form field', () => { // default to LOW in this test configuration it('defaults to the correct value', async () => { - render( + appMockRender.render( @@ -39,7 +51,7 @@ describe('Severity form field', () => { }); it('selects the correct value when changed', async () => { - render( + appMockRender.render( @@ -61,7 +73,7 @@ describe('Severity form field', () => { }); it('disables when loading data', async () => { - render( + appMockRender.render( diff --git a/x-pack/plugins/cases/public/components/case_form_fields/sync_alerts_toggle.test.tsx b/x-pack/plugins/cases/public/components/case_form_fields/sync_alerts_toggle.test.tsx index 01a688c474241..024ebd790cff2 100644 --- a/x-pack/plugins/cases/public/components/case_form_fields/sync_alerts_toggle.test.tsx +++ b/x-pack/plugins/cases/public/components/case_form_fields/sync_alerts_toggle.test.tsx @@ -14,8 +14,7 @@ import { FormTestComponent } from '../../common/test_utils'; import type { AppMockRenderer } from '../../common/mock'; import { createAppMockRenderer } from '../../common/mock'; -// Failing: See https://github.com/elastic/kibana/issues/190270 -describe.skip('SyncAlertsToggle', () => { +describe('SyncAlertsToggle', () => { let appMockRender: AppMockRenderer; const onSubmit = jest.fn(); const defaultFormProps = { @@ -31,6 +30,10 @@ describe.skip('SyncAlertsToggle', () => { appMockRender = createAppMockRenderer(); }); + afterEach(async () => { + await appMockRender.clearQueryCache(); + }); + it('it renders', async () => { appMockRender.render( diff --git a/x-pack/plugins/cases/public/components/case_view/components/case_view_files.test.tsx b/x-pack/plugins/cases/public/components/case_view/components/case_view_files.test.tsx index d092114bde964..e6469b8af7560 100644 --- a/x-pack/plugins/cases/public/components/case_view/components/case_view_files.test.tsx +++ b/x-pack/plugins/cases/public/components/case_view/components/case_view_files.test.tsx @@ -26,8 +26,7 @@ const caseData: CaseUI = { comments: [...basicCase.comments, alertCommentWithIndices], }; -// FLAKY: https://github.com/elastic/kibana/issues/185046 -describe.skip('Case View Page files tab', () => { +describe('Case View Page files tab', () => { let appMockRender: AppMockRenderer; useGetCaseFilesMock.mockReturnValue({ @@ -37,10 +36,11 @@ describe.skip('Case View Page files tab', () => { beforeEach(() => { appMockRender = createAppMockRenderer(); + jest.clearAllMocks(); }); - afterEach(() => { - jest.clearAllMocks(); + afterEach(async () => { + await appMockRender.clearQueryCache(); }); it('should render the utility bar for the files table', async () => { diff --git a/x-pack/plugins/cases/public/components/case_view/components/custom_fields.test.tsx b/x-pack/plugins/cases/public/components/case_view/components/custom_fields.test.tsx index c0779043ec148..47928a289a891 100644 --- a/x-pack/plugins/cases/public/components/case_view/components/custom_fields.test.tsx +++ b/x-pack/plugins/cases/public/components/case_view/components/custom_fields.test.tsx @@ -16,16 +16,17 @@ import { customFieldsMock, customFieldsConfigurationMock } from '../../../contai import userEvent from '@testing-library/user-event'; import { CustomFieldTypes } from '../../../../common/types/domain'; -describe.skip('Case View Page files tab', () => { +describe('Case View Page files tab', () => { const onSubmit = jest.fn(); let appMockRender: AppMockRenderer; beforeEach(() => { appMockRender = createAppMockRenderer(); + jest.clearAllMocks(); }); - afterEach(() => { - jest.clearAllMocks(); + afterEach(async () => { + await appMockRender.clearQueryCache(); }); it('should render the custom fields correctly', async () => { diff --git a/x-pack/plugins/cases/public/components/connector_selector/form.test.tsx b/x-pack/plugins/cases/public/components/connector_selector/form.test.tsx index 508af2099b913..c87dd5bb1d10b 100644 --- a/x-pack/plugins/cases/public/components/connector_selector/form.test.tsx +++ b/x-pack/plugins/cases/public/components/connector_selector/form.test.tsx @@ -19,8 +19,7 @@ jest.mock('../../common/lib/kibana'); const useKibanaMock = useKibana as jest.Mocked; -// FLAKY: https://github.com/elastic/kibana/issues/189530 -describe.skip('ConnectorSelector', () => { +describe('ConnectorSelector', () => { const handleChange = jest.fn(); const defaultProps = { connectors: [], @@ -45,6 +44,10 @@ describe.skip('ConnectorSelector', () => { }); }); + afterEach(async () => { + await appMock.clearQueryCache(); + }); + it('should render', async () => { appMock.render( diff --git a/x-pack/plugins/cases/public/components/create/template.test.tsx b/x-pack/plugins/cases/public/components/create/template.test.tsx index 837b87827e591..8048a038064c1 100644 --- a/x-pack/plugins/cases/public/components/create/template.test.tsx +++ b/x-pack/plugins/cases/public/components/create/template.test.tsx @@ -13,8 +13,7 @@ import { createAppMockRenderer } from '../../common/mock'; import { templatesConfigurationMock } from '../../containers/mock'; import { TemplateSelector } from './templates'; -// FLAKY: https://github.com/elastic/kibana/issues/178457 -describe.skip('CustomFields', () => { +describe('CustomFields', () => { let appMockRender: AppMockRenderer; const onTemplateChange = jest.fn(); @@ -23,6 +22,10 @@ describe.skip('CustomFields', () => { appMockRender = createAppMockRenderer(); }); + afterEach(async () => { + await appMockRender.clearQueryCache(); + }); + it('renders correctly', async () => { appMockRender.render( { +describe('FormFields ', () => { let appMockRender: AppMockRenderer; const onSubmit = jest.fn(); @@ -25,6 +24,10 @@ describe.skip('FormFields ', () => { appMockRender = createAppMockRenderer(); }); + afterEach(async () => { + await appMockRender.clearQueryCache(); + }); + it('renders correctly', async () => { appMockRender.render( diff --git a/x-pack/plugins/cases/public/components/description/index.test.tsx b/x-pack/plugins/cases/public/components/description/index.test.tsx index 05f2477eda715..d5f3b26684080 100644 --- a/x-pack/plugins/cases/public/components/description/index.test.tsx +++ b/x-pack/plugins/cases/public/components/description/index.test.tsx @@ -27,8 +27,7 @@ const defaultProps = { isLoadingDescription: false, }; -// Failing: See https://github.com/elastic/kibana/issues/185879 -describe.skip('Description', () => { +describe('Description', () => { const onUpdateField = jest.fn(); let appMockRender: AppMockRenderer; @@ -37,6 +36,10 @@ describe.skip('Description', () => { appMockRender = createAppMockRenderer(); }); + afterEach(async () => { + await appMockRender.clearQueryCache(); + }); + it('renders description correctly', async () => { appMockRender.render(); diff --git a/x-pack/plugins/cases/public/components/files/file_attachment_event.test.tsx b/x-pack/plugins/cases/public/components/files/file_attachment_event.test.tsx index 48ab9c3c669af..af1a09f169216 100644 --- a/x-pack/plugins/cases/public/components/files/file_attachment_event.test.tsx +++ b/x-pack/plugins/cases/public/components/files/file_attachment_event.test.tsx @@ -16,8 +16,7 @@ import { createAppMockRenderer } from '../../common/mock'; import { basicFileMock } from '../../containers/mock'; import { FileAttachmentEvent } from './file_attachment_event'; -// FLAKY: https://github.com/elastic/kibana/issues/174661 -describe.skip('FileAttachmentEvent', () => { +describe('FileAttachmentEvent', () => { let appMockRender: AppMockRenderer; beforeEach(() => { @@ -25,6 +24,10 @@ describe.skip('FileAttachmentEvent', () => { appMockRender = createAppMockRenderer(); }); + afterEach(async () => { + await appMockRender.clearQueryCache(); + }); + it('renders clickable name', async () => { appMockRender.render( diff --git a/x-pack/plugins/cases/public/components/files/file_preview.test.tsx b/x-pack/plugins/cases/public/components/files/file_preview.test.tsx index 8f24a9073c9be..3312d9e497817 100644 --- a/x-pack/plugins/cases/public/components/files/file_preview.test.tsx +++ b/x-pack/plugins/cases/public/components/files/file_preview.test.tsx @@ -16,8 +16,7 @@ import { createAppMockRenderer, mockedTestProvidersOwner } from '../../common/mo import { basicFileMock } from '../../containers/mock'; import { FilePreview } from './file_preview'; -// FLAKY: https://github.com/elastic/kibana/issues/182364 -describe.skip('FilePreview', () => { +describe('FilePreview', () => { let appMockRender: AppMockRenderer; beforeEach(() => { @@ -25,6 +24,10 @@ describe.skip('FilePreview', () => { appMockRender = createAppMockRenderer(); }); + afterEach(async () => { + await appMockRender.clearQueryCache(); + }); + it('FilePreview rendered correctly', async () => { appMockRender.render(); diff --git a/x-pack/plugins/cases/public/components/files/file_type.test.tsx b/x-pack/plugins/cases/public/components/files/file_type.test.tsx index 242fb2fa6af09..ae1d3e2339e97 100644 --- a/x-pack/plugins/cases/public/components/files/file_type.test.tsx +++ b/x-pack/plugins/cases/public/components/files/file_type.test.tsx @@ -17,8 +17,7 @@ import { basicCase, basicFileMock } from '../../containers/mock'; import { getFileType } from './file_type'; import { FILE_ATTACHMENT_TYPE } from '../../../common/constants'; -// FLAKY: https://github.com/elastic/kibana/issues/175841 -describe.skip('getFileType', () => { +describe('getFileType', () => { const fileType = getFileType(); it('invalid props return blank FileAttachmentViewObject', () => { @@ -45,6 +44,10 @@ describe.skip('getFileType', () => { jest.clearAllMocks(); }); + afterEach(async () => { + await appMockRender.clearQueryCache(); + }); + it('event renders a clickable name if the file is an image', async () => { appMockRender = createAppMockRenderer(); @@ -142,7 +145,10 @@ describe.skip('getFileType', () => { it('empty externalReferenceMetadata returns blank FileAttachmentViewObject', () => { expect( - fileType.getAttachmentViewObject({ ...attachmentViewProps, externalReferenceMetadata: {} }) + fileType.getAttachmentViewObject({ + ...attachmentViewProps, + externalReferenceMetadata: {}, + }) ).toEqual({ event: 'added an unknown file', hideDefaultActions: true, diff --git a/x-pack/plugins/cases/public/components/filter_popover/index.test.tsx b/x-pack/plugins/cases/public/components/filter_popover/index.test.tsx index c79705f109a74..072a6661203fa 100644 --- a/x-pack/plugins/cases/public/components/filter_popover/index.test.tsx +++ b/x-pack/plugins/cases/public/components/filter_popover/index.test.tsx @@ -15,8 +15,7 @@ import { createAppMockRenderer } from '../../common/mock'; import { FilterPopover } from '.'; -// FLAKY: https://github.com/elastic/kibana/issues/176679 -describe.skip('FilterPopover ', () => { +describe('FilterPopover ', () => { let appMockRender: AppMockRenderer; const onSelectedOptionsChanged = jest.fn(); const tags: string[] = ['coke', 'pepsi']; @@ -26,6 +25,10 @@ describe.skip('FilterPopover ', () => { jest.clearAllMocks(); }); + afterEach(async () => { + await appMockRender.clearQueryCache(); + }); + it('renders button label correctly', async () => { appMockRender.render( { +describe('EditableMarkdown', () => { let appMockRender: AppMockRenderer; beforeEach(() => { @@ -74,6 +73,10 @@ describe.skip('EditableMarkdown', () => { sessionStorage.removeItem(draftStorageKey); }); + afterEach(async () => { + await appMockRender.clearQueryCache(); + }); + it('Save button click calls onSaveContent and onChangeEditable when text area value changed', async () => { appMockRender.render(); diff --git a/x-pack/plugins/cases/public/components/templates/template_fields.test.tsx b/x-pack/plugins/cases/public/components/templates/template_fields.test.tsx index 19efd1a8643bf..f5dda51104653 100644 --- a/x-pack/plugins/cases/public/components/templates/template_fields.test.tsx +++ b/x-pack/plugins/cases/public/components/templates/template_fields.test.tsx @@ -13,8 +13,7 @@ import { createAppMockRenderer } from '../../common/mock'; import { FormTestComponent } from '../../common/test_utils'; import { TemplateFields } from './template_fields'; -// FLAKY: https://github.com/elastic/kibana/issues/187854 -describe.skip('Template fields', () => { +describe('Template fields', () => { let appMockRenderer: AppMockRenderer; const onSubmit = jest.fn(); const formDefaultValue = { templateTags: [] }; @@ -28,6 +27,10 @@ describe.skip('Template fields', () => { appMockRenderer = createAppMockRenderer(); }); + afterEach(async () => { + await appMockRenderer.clearQueryCache(); + }); + it('renders template fields correctly', async () => { appMockRenderer.render( diff --git a/x-pack/plugins/cases/public/components/templates/template_tags.test.tsx b/x-pack/plugins/cases/public/components/templates/template_tags.test.tsx index ed94b28d80d5e..6b084a3317e3f 100644 --- a/x-pack/plugins/cases/public/components/templates/template_tags.test.tsx +++ b/x-pack/plugins/cases/public/components/templates/template_tags.test.tsx @@ -15,8 +15,7 @@ import { FormTestComponent } from '../../common/test_utils'; import { TemplateTags } from './template_tags'; import { showEuiComboBoxOptions } from '@elastic/eui/lib/test/rtl'; -// FLAKY: https://github.com/elastic/kibana/issues/189293 -describe.skip('TemplateTags', () => { +describe('TemplateTags', () => { let appMockRenderer: AppMockRenderer; const onSubmit = jest.fn(); const formDefaultValue = { templateTags: [] }; @@ -26,6 +25,10 @@ describe.skip('TemplateTags', () => { appMockRenderer = createAppMockRenderer(); }); + afterEach(async () => { + await appMockRenderer.clearQueryCache(); + }); + it('renders template tags', async () => { appMockRenderer.render( diff --git a/x-pack/plugins/cases/public/components/user_actions/property_actions/alert_property_actions.test.tsx b/x-pack/plugins/cases/public/components/user_actions/property_actions/alert_property_actions.test.tsx index 64dfa08944ea1..43601412c0bfe 100644 --- a/x-pack/plugins/cases/public/components/user_actions/property_actions/alert_property_actions.test.tsx +++ b/x-pack/plugins/cases/public/components/user_actions/property_actions/alert_property_actions.test.tsx @@ -17,8 +17,7 @@ import { } from '../../../common/mock'; import { AlertPropertyActions } from './alert_property_actions'; -// FLAKY: https://github.com/elastic/kibana/issues/174667 -describe.skip('AlertPropertyActions', () => { +describe('AlertPropertyActions', () => { let appMock: AppMockRenderer; const props = { @@ -32,6 +31,10 @@ describe.skip('AlertPropertyActions', () => { appMock = createAppMockRenderer(); }); + afterEach(async () => { + await appMock.clearQueryCache(); + }); + it('renders the correct number of actions', async () => { appMock.render(); diff --git a/x-pack/plugins/cases/public/components/user_actions/property_actions/registered_attachments_property_actions.test.tsx b/x-pack/plugins/cases/public/components/user_actions/property_actions/registered_attachments_property_actions.test.tsx index a1f407a1c98cd..92c6c2cb5e3d3 100644 --- a/x-pack/plugins/cases/public/components/user_actions/property_actions/registered_attachments_property_actions.test.tsx +++ b/x-pack/plugins/cases/public/components/user_actions/property_actions/registered_attachments_property_actions.test.tsx @@ -18,8 +18,7 @@ import { import { RegisteredAttachmentsPropertyActions } from './registered_attachments_property_actions'; import { AttachmentActionType } from '../../../client/attachment_framework/types'; -// Failing: See https://github.com/elastic/kibana/issues/174384 -describe.skip('RegisteredAttachmentsPropertyActions', () => { +describe('RegisteredAttachmentsPropertyActions', () => { let appMock: AppMockRenderer; const props = { @@ -34,6 +33,10 @@ describe.skip('RegisteredAttachmentsPropertyActions', () => { appMock = createAppMockRenderer(); }); + afterEach(async () => { + await appMock.clearQueryCache(); + }); + it('renders the correct number of actions', async () => { appMock.render(); diff --git a/x-pack/plugins/cases/public/components/user_actions/property_actions/user_comment_property_actions.test.tsx b/x-pack/plugins/cases/public/components/user_actions/property_actions/user_comment_property_actions.test.tsx index c24d26fa3b283..bf090a94ad062 100644 --- a/x-pack/plugins/cases/public/components/user_actions/property_actions/user_comment_property_actions.test.tsx +++ b/x-pack/plugins/cases/public/components/user_actions/property_actions/user_comment_property_actions.test.tsx @@ -17,8 +17,7 @@ import { import { UserCommentPropertyActions } from './user_comment_property_actions'; import { waitFor } from '@testing-library/react'; -// FLAKY: https://github.com/elastic/kibana/issues/175310 -describe.skip('UserCommentPropertyActions', () => { +describe('UserCommentPropertyActions', () => { let appMock: AppMockRenderer; const props = { @@ -33,6 +32,10 @@ describe.skip('UserCommentPropertyActions', () => { jest.clearAllMocks(); }); + afterEach(async () => { + await appMock.clearQueryCache(); + }); + it('renders the correct number of actions', async () => { appMock.render();