diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_calculate_entity_risk_score.test.ts b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_calculate_entity_risk_score.test.ts index d54663c74cda8..cd271ac1a0d20 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_calculate_entity_risk_score.test.ts +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_calculate_entity_risk_score.test.ts @@ -5,11 +5,10 @@ * 2.0. */ -import { act, renderHook } from '@testing-library/react-hooks'; import { TestProviders } from '../../../common/mock'; import { RiskScoreEntity } from '../../../../common/search_strategy'; import { useCalculateEntityRiskScore } from './use_calculate_entity_risk_score'; -import { waitFor } from '@testing-library/react'; +import { waitFor, renderHook, act } from '@testing-library/react'; import { RiskEngineStatusEnum } from '../../../../common/api/entity_analytics/risk_engine/engine_status_route.gen'; const enabledRiskEngineStatus = { diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_risk_score.test.tsx b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_risk_score.test.tsx index 60fdb04dffa96..840c215cbb2ba 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_risk_score.test.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_risk_score.test.tsx @@ -4,7 +4,8 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { renderHook } from '@testing-library/react-hooks'; + +import { waitFor, renderHook } from '@testing-library/react'; import { useRiskScore } from './use_risk_score'; import { TestProviders } from '../../../common/mock'; @@ -218,7 +219,7 @@ describe.each([RiskScoreEntity.host, RiskScoreEntity.user])( totalCount: 0, }, }); - const { result, waitFor } = renderHook(() => useRiskScore({ riskEntity }), { + const { result } = renderHook(() => useRiskScore({ riskEntity }), { wrapper: TestProviders, }); await waitFor(() => { diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_risk_score_feature_status.test.ts b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_risk_score_feature_status.test.ts index 30719d1559f54..592ad1ce007f2 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_risk_score_feature_status.test.ts +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_risk_score_feature_status.test.ts @@ -4,7 +4,8 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { act, renderHook } from '@testing-library/react-hooks'; + +import { renderHook, act } from '@testing-library/react'; import { TestProviders } from '../../../common/mock'; import { useRiskScoreFeatureStatus } from './use_risk_score_feature_status'; diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_schedule_now_risk_engine_mutation.test.tsx b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_schedule_now_risk_engine_mutation.test.tsx index a85f750b60c1e..c7cf1ea0b6efd 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_schedule_now_risk_engine_mutation.test.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/api/hooks/use_schedule_now_risk_engine_mutation.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { act } from '@testing-library/react-hooks'; +import { act } from '@testing-library/react'; import { useScheduleNowRiskEngineMutation } from './use_schedule_now_risk_engine_mutation'; import { renderMutation } from '../../../management/hooks/test_utils'; import { RISK_ENGINE_SCHEDULE_NOW_URL } from '../../../../common/constants'; diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/hooks.test.ts b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/hooks.test.ts index a3b9a2e0ce24e..2fa4e6ce943b5 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/hooks.test.ts +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/hooks.test.ts @@ -7,8 +7,7 @@ import { createTelemetryServiceMock } from '../../../common/lib/telemetry/telemetry_service.mock'; import { TestProviders } from '@kbn/timelines-plugin/public/mock'; -import { waitFor } from '@testing-library/react'; -import { renderHook } from '@testing-library/react-hooks'; +import { waitFor, renderHook } from '@testing-library/react'; import { useFileValidation } from './hooks'; import { useKibana as mockUseKibana } from '../../../common/lib/kibana/__mocks__'; diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/columns.test.tsx b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/columns.test.tsx index 6083c18dfb38d..4a8bf9e895d85 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/columns.test.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/columns.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook } from '@testing-library/react'; import { AnomalyEntity } from '../../../common/components/ml/anomaly/use_anomalies_search'; import type { SecurityJob } from '../../../common/components/ml_popover/types'; import { useAnomaliesColumns } from './columns'; diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_analytics_risk_score/use_entity.test.ts b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_analytics_risk_score/use_entity.test.ts index 25d772c26762c..cfece07b299cf 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_analytics_risk_score/use_entity.test.ts +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_analytics_risk_score/use_entity.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook } from '@testing-library/react'; import { RiskScoreEntity } from '../../../../common/search_strategy/security_solution/risk_score'; import { useEntityInfo } from './use_entity'; diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_details_flyout/hooks/use_risk_input_actions_panels.test.tsx b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_details_flyout/hooks/use_risk_input_actions_panels.test.tsx index 363edc4df9b1d..17e5dc616e536 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_details_flyout/hooks/use_risk_input_actions_panels.test.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_details_flyout/hooks/use_risk_input_actions_panels.test.tsx @@ -8,8 +8,7 @@ import type { EuiContextMenuPanelDescriptor } from '@elastic/eui'; import { EuiContextMenu } from '@elastic/eui'; import { casesPluginMock } from '@kbn/cases-plugin/public/mocks'; -import { render } from '@testing-library/react'; -import { renderHook } from '@testing-library/react-hooks'; +import { render, renderHook } from '@testing-library/react'; import React from 'react'; import { TestProviders } from '../../../../common/mock'; import { alertInputDataMock } from '../mocks'; diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/hooks/use_entities_list_filters.test.ts b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/hooks/use_entities_list_filters.test.ts index cdf0583374538..42dd6956b0fa4 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/hooks/use_entities_list_filters.test.ts +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/hooks/use_entities_list_filters.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook } from '@testing-library/react'; import { useEntitiesListFilters } from './use_entities_list_filters'; import { useGlobalFilterQuery } from '../../../../common/hooks/use_global_filter_query'; import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/hooks/use_entities_list_query.test.tsx b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/hooks/use_entities_list_query.test.tsx index 5f2363272791b..8afc27d1c4306 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/hooks/use_entities_list_query.test.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/hooks/use_entities_list_query.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook, waitFor } from '@testing-library/react'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { useEntitiesListQuery } from './use_entities_list_query'; import { useEntityAnalyticsRoutes } from '../../../api/api'; @@ -31,17 +31,14 @@ describe('useEntitiesListQuery', () => { fetchEntitiesListMock.mockResolvedValueOnce({ data: 'test data' }); - const { result, waitFor } = renderHook( - () => useEntitiesListQuery({ ...searchParams, skip: false }), - { - wrapper: TestWrapper, - } - ); - - await waitFor(() => result.current.isSuccess); + const { result } = renderHook(() => useEntitiesListQuery({ ...searchParams, skip: false }), { + wrapper: TestWrapper, + }); - expect(fetchEntitiesListMock).toHaveBeenCalledWith({ params: searchParams }); - expect(result.current.data).toEqual({ data: 'test data' }); + await waitFor(() => { + expect(fetchEntitiesListMock).toHaveBeenCalledWith({ params: searchParams }); + expect(result.current.data).toEqual({ data: 'test data' }); + }); }); it('should not call fetchEntitiesList if skip is true', async () => { diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/risk_score_donut_chart/use_risk_donut_chart_data.test.ts b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/risk_score_donut_chart/use_risk_donut_chart_data.test.ts index 376417bb9f4dd..e3c75f0f41bd9 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/risk_score_donut_chart/use_risk_donut_chart_data.test.ts +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/risk_score_donut_chart/use_risk_donut_chart_data.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook } from '@testing-library/react'; import { RiskSeverity } from '../../../../common/search_strategy'; import { useRiskDonutChartData } from './use_risk_donut_chart_data'; import type { SeverityCount } from '../severity/types'; diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/lens_attributes/risk_score_donut.test.ts b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/lens_attributes/risk_score_donut.test.ts index 148be86013b42..24980d5013ef9 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/lens_attributes/risk_score_donut.test.ts +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/lens_attributes/risk_score_donut.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook } from '@testing-library/react'; import { wrapper } from '../../common/components/visualization_actions/mocks'; import { useLensAttributes } from '../../common/components/visualization_actions/use_lens_attributes'; diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/lens_attributes/risk_score_over_time_area.test.ts b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/lens_attributes/risk_score_over_time_area.test.ts index 0212363ea9a65..4ffdda459560a 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/lens_attributes/risk_score_over_time_area.test.ts +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/lens_attributes/risk_score_over_time_area.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook } from '@testing-library/react'; import type { XYState } from '@kbn/lens-plugin/public'; import { getRiskScoreOverTimeAreaAttributes } from './risk_score_over_time_area'; diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/lens_attributes/risk_score_summary.test.ts b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/lens_attributes/risk_score_summary.test.ts index ac7028fa90280..e08610a8feaf4 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/lens_attributes/risk_score_summary.test.ts +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/lens_attributes/risk_score_summary.test.ts @@ -6,7 +6,7 @@ */ import { RiskScoreEntity } from '../../../common/entity_analytics/risk_engine'; -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook } from '@testing-library/react'; import { getRiskScoreSummaryAttributes } from './risk_score_summary'; import { RiskSeverity } from '../../../common/search_strategy'; import type { MetricVisualizationState } from '@kbn/lens-plugin/public'; diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/host_right/hooks/use_observed_host_fields.test.ts b/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/host_right/hooks/use_observed_host_fields.test.ts index 4c947809a85f4..11cf670ba24a0 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/host_right/hooks/use_observed_host_fields.test.ts +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/host_right/hooks/use_observed_host_fields.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook } from '@testing-library/react'; import { useObservedHostFields } from './use_observed_host_fields'; import { mockObservedHostData } from '../../mocks'; import { TestProviders } from '../../../../common/mock'; diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/shared/hooks/use_managed_user.test.ts b/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/shared/hooks/use_managed_user.test.ts index 4eb1678823de7..ac48c7b87e060 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/shared/hooks/use_managed_user.test.ts +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/shared/hooks/use_managed_user.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook } from '@testing-library/react'; import type { Integration } from '../../../../../common/api/detection_engine'; import { TestProviders } from '../../../../common/mock'; import { ENTRA_ID_PACKAGE_NAME } from '../constants'; diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/user_right/hooks/use_managed_user_items.test.tsx b/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/user_right/hooks/use_managed_user_items.test.tsx index f20ad512fbef4..68379597eac70 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/user_right/hooks/use_managed_user_items.test.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/user_right/hooks/use_managed_user_items.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook } from '@testing-library/react'; import { mockGlobalState, TestProviders, createMockStore } from '../../../../common/mock'; import { useManagedUserItems } from './use_managed_user_items'; import { mockEntraUserFields, mockOktaUserFields } from '../mocks'; diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/user_right/hooks/use_observed_user_items.test.ts b/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/user_right/hooks/use_observed_user_items.test.ts index 753cd8a1344d0..82814100f295f 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/user_right/hooks/use_observed_user_items.test.ts +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/user_right/hooks/use_observed_user_items.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook } from '@testing-library/react'; import { mockObservedUser } from '../mocks'; import { TestProviders } from '../../../../common/mock'; import { useObservedUserItems } from './use_observed_user_items';