From 09ce877cad73a474054acef0736663369e8082e7 Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 23 Aug 2023 10:47:21 -0600 Subject: [PATCH 01/20] remove unneeded usages of isErrorResponse --- examples/search_examples/public/search/app.tsx | 7 ------- examples/search_examples/public/search_sessions/app.tsx | 3 --- examples/search_examples/public/sql_search/app.tsx | 5 ----- .../log_categorization/use_categorize_request.ts | 4 +--- .../plugins/aiops/public/hooks/use_cancellable_search.ts | 3 --- .../components/events_viewer/use_timelines_events.tsx | 7 +------ .../public/common/containers/cti/event_enrichment/api.ts | 4 ++-- .../common/containers/events/last_event_time/index.ts | 5 +---- .../public/common/containers/matrix_histogram/index.ts | 7 +------ .../common/containers/use_search_strategy/index.tsx | 9 ++------- .../explore/network/containers/kpi_network/dns/index.tsx | 6 +----- .../containers/kpi_network/network_events/index.tsx | 6 +----- .../containers/kpi_network/tls_handshakes/index.tsx | 6 +----- .../containers/kpi_network/unique_flows/index.tsx | 6 +----- .../containers/kpi_network/unique_private_ips/index.tsx | 6 +----- .../containers/overview_cti_links/use_ti_data_sources.ts | 4 ++-- .../public/timelines/containers/index.tsx | 7 +------ .../public/timelines/containers/kpis/index.tsx | 6 +----- .../sections/alerts_table/hooks/use_fetch_alerts.tsx | 6 +----- 19 files changed, 18 insertions(+), 89 deletions(-) diff --git a/examples/search_examples/public/search/app.tsx b/examples/search_examples/public/search/app.tsx index e6aeeaae648bd..3b2a8634e6aa6 100644 --- a/examples/search_examples/public/search/app.tsx +++ b/examples/search_examples/public/search/app.tsx @@ -247,9 +247,6 @@ export const SearchExamplesApp = ({ text: toMountPoint(res.warning), }); } - } else if (isErrorResponse(res)) { - // TODO: Make response error status clearer - notifications.toasts.addDanger('An error has occurred'); } }, error: (e) => { @@ -401,10 +398,6 @@ export const SearchExamplesApp = ({ title: 'Query result', text: 'Query finished', }); - } else if (isErrorResponse(res)) { - setIsLoading(false); - // TODO: Make response error status clearer - notifications.toasts.addWarning('An error has occurred'); } }, error: (e) => { diff --git a/examples/search_examples/public/search_sessions/app.tsx b/examples/search_examples/public/search_sessions/app.tsx index 701665fd52075..8b7c7bbcaa144 100644 --- a/examples/search_examples/public/search_sessions/app.tsx +++ b/examples/search_examples/public/search_sessions/app.tsx @@ -40,7 +40,6 @@ import { IEsSearchRequest, IEsSearchResponse, isCompleteResponse, - isErrorResponse, QueryState, SearchSessionState, } from '@kbn/data-plugin/public'; @@ -724,8 +723,6 @@ function doSearch( title: 'Query result', text: mountReactNode(message), }); - } else if (isErrorResponse(res)) { - notifications.toasts.addWarning('An error has occurred'); } }), map((res) => ({ response: res, request: req, tookMs: performance.now() - startTs })), diff --git a/examples/search_examples/public/sql_search/app.tsx b/examples/search_examples/public/sql_search/app.tsx index f8278736e4a70..33406a53f9674 100644 --- a/examples/search_examples/public/sql_search/app.tsx +++ b/examples/search_examples/public/sql_search/app.tsx @@ -27,7 +27,6 @@ import { DataPublicPluginStart, IKibanaSearchResponse, isCompleteResponse, - isErrorResponse, } from '@kbn/data-plugin/public'; import { SQL_SEARCH_STRATEGY, @@ -70,10 +69,6 @@ export const SqlSearchExampleApp = ({ notifications, data }: SearchExamplesAppDe if (isCompleteResponse(res)) { setIsLoading(false); setResponse(res); - } else if (isErrorResponse(res)) { - setIsLoading(false); - setResponse(res); - notifications.toasts.addDanger('An error has occurred'); } }, error: (e) => { diff --git a/x-pack/plugins/aiops/public/components/log_categorization/use_categorize_request.ts b/x-pack/plugins/aiops/public/components/log_categorization/use_categorize_request.ts index a4ad155092f25..3108ec9391cef 100644 --- a/x-pack/plugins/aiops/public/components/log_categorization/use_categorize_request.ts +++ b/x-pack/plugins/aiops/public/components/log_categorization/use_categorize_request.ts @@ -7,7 +7,7 @@ import { cloneDeep, get } from 'lodash'; import { useRef, useCallback, useMemo } from 'react'; -import { isCompleteResponse, isErrorResponse } from '@kbn/data-plugin/public'; +import { isCompleteResponse } from '@kbn/data-plugin/public'; import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; import { createRandomSamplerWrapper } from '@kbn/ml-random-sampler-utils'; @@ -110,8 +110,6 @@ export function useCategorizeRequest() { next: (result) => { if (isCompleteResponse(result)) { resolve(processCategoryResults(result, field, unwrap)); - } else if (isErrorResponse(result)) { - reject(result); } else { // partial results // Ignore partial results for now. diff --git a/x-pack/plugins/aiops/public/hooks/use_cancellable_search.ts b/x-pack/plugins/aiops/public/hooks/use_cancellable_search.ts index 0450905bde912..a0d716364f192 100644 --- a/x-pack/plugins/aiops/public/hooks/use_cancellable_search.ts +++ b/x-pack/plugins/aiops/public/hooks/use_cancellable_search.ts @@ -9,7 +9,6 @@ import { useCallback, useRef, useState } from 'react'; import { type IKibanaSearchResponse, isCompleteResponse, - isErrorResponse, } from '@kbn/data-plugin/common'; import { tap } from 'rxjs/operators'; import { useAiopsAppContext } from './use_aiops_app_context'; @@ -38,8 +37,6 @@ export function useCancellableSearch() { if (isCompleteResponse(result)) { setIsFetching(false); resolve(result); - } else if (isErrorResponse(result)) { - reject(result); } else { // partial results // Ignore partial results for now. diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx index 3a70ccebb9ca6..f72205b4c2158 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx @@ -12,7 +12,7 @@ import { useDispatch } from 'react-redux'; import { Subscription } from 'rxjs'; import type { DataView } from '@kbn/data-views-plugin/public'; import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; -import { isCompleteResponse, isErrorResponse } from '@kbn/data-plugin/common'; +import { isCompleteResponse } from '@kbn/data-plugin/common'; import type { Inspect, PaginationInputPaginated, @@ -270,11 +270,6 @@ export const useTimelineEventsHandler = ({ setFilterStatus(request.filterStatus); setLoading(false); - searchSubscription$.current.unsubscribe(); - } else if (isErrorResponse(response)) { - setLoading(false); - endTracking('invalid'); - addWarning(ERROR_TIMELINE_EVENTS); searchSubscription$.current.unsubscribe(); } }, diff --git a/x-pack/plugins/security_solution/public/common/containers/cti/event_enrichment/api.ts b/x-pack/plugins/security_solution/public/common/containers/cti/event_enrichment/api.ts index bf595de39ee5e..e120ce72d859b 100644 --- a/x-pack/plugins/security_solution/public/common/containers/cti/event_enrichment/api.ts +++ b/x-pack/plugins/security_solution/public/common/containers/cti/event_enrichment/api.ts @@ -9,7 +9,7 @@ import type { Observable } from 'rxjs'; import { filter } from 'rxjs/operators'; import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; -import { isErrorResponse, isCompleteResponse } from '@kbn/data-plugin/common'; +import { isCompleteResponse } from '@kbn/data-plugin/common'; import type { CtiEventEnrichmentRequestOptions, CtiEventEnrichmentStrategyResponse, @@ -47,5 +47,5 @@ export const getEventEnrichmentComplete = ( props: GetEventEnrichmentProps ): Observable => getEventEnrichment(props).pipe( - filter((response) => isErrorResponse(response) || isCompleteResponse(response)) + filter((response) => isCompleteResponse(response)) ); diff --git a/x-pack/plugins/security_solution/public/common/containers/events/last_event_time/index.ts b/x-pack/plugins/security_solution/public/common/containers/events/last_event_time/index.ts index b55c566084528..c908ad8f767af 100644 --- a/x-pack/plugins/security_solution/public/common/containers/events/last_event_time/index.ts +++ b/x-pack/plugins/security_solution/public/common/containers/events/last_event_time/index.ts @@ -10,7 +10,7 @@ import { noop } from 'lodash/fp'; import { useCallback, useEffect, useRef, useState } from 'react'; import { Subscription } from 'rxjs'; -import { isCompleteResponse, isErrorResponse } from '@kbn/data-plugin/common'; +import { isCompleteResponse } from '@kbn/data-plugin/common'; import type { inputsModel } from '../../../store'; import { useKibana } from '../../../lib/kibana'; import type { @@ -85,9 +85,6 @@ export const useTimelineLastEventTime = ({ lastSeen: response.lastSeen, refetch: refetch.current, })); - } else if (isErrorResponse(response)) { - setLoading(false); - addWarning(i18n.ERROR_LAST_EVENT_TIME); } }, error: (msg) => { diff --git a/x-pack/plugins/security_solution/public/common/containers/matrix_histogram/index.ts b/x-pack/plugins/security_solution/public/common/containers/matrix_histogram/index.ts index f75385fdd4955..c2393cb060c57 100644 --- a/x-pack/plugins/security_solution/public/common/containers/matrix_histogram/index.ts +++ b/x-pack/plugins/security_solution/public/common/containers/matrix_histogram/index.ts @@ -10,7 +10,7 @@ import { getOr, noop } from 'lodash/fp'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { Subscription } from 'rxjs'; -import { isErrorResponse, isCompleteResponse } from '@kbn/data-plugin/common'; +import { isCompleteResponse } from '@kbn/data-plugin/common'; import type { MatrixHistogramQueryProps } from '../../components/matrix_histogram/types'; import type { inputsModel } from '../../store'; import { createFilter } from '../helpers'; @@ -138,11 +138,6 @@ export const useMatrixHistogram = ({ })); endTracking('success'); searchSubscription$.current.unsubscribe(); - } else if (isErrorResponse(response)) { - setLoading(false); - addWarning(i18n.ERROR_MATRIX_HISTOGRAM); - endTracking('invalid'); - searchSubscription$.current.unsubscribe(); } }, error: (msg) => { diff --git a/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.tsx b/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.tsx index 65175f00074c8..c41b3e847f40f 100644 --- a/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.tsx +++ b/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.tsx @@ -65,16 +65,11 @@ export const useSearch = ( abortSignal, } ) - .pipe(filter((response) => isErrorResponse(response) || isCompleteResponse(response))); + .pipe(filter((response) => isCompleteResponse(response))); observable.subscribe({ next: (response) => { - if (isErrorResponse(response)) { - addWarning(i18n.INVALID_RESPONSE_WARNING_SEARCH_STRATEGY(factoryQueryType)); - endTracking('invalid'); - } else { - endTracking('success'); - } + endTracking('success'); }, error: () => { endTracking(abortSignal.aborted ? 'aborted' : 'error'); diff --git a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx index 806c8d67e0c8e..34722b8b2b99d 100644 --- a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx @@ -10,7 +10,7 @@ import { noop } from 'lodash/fp'; import { useCallback, useEffect, useRef, useState } from 'react'; import { Subscription } from 'rxjs'; -import { isCompleteResponse, isErrorResponse } from '@kbn/data-plugin/common'; +import { isCompleteResponse } from '@kbn/data-plugin/common'; import { useAppToasts } from '../../../../../common/hooks/use_app_toasts'; import type { inputsModel } from '../../../../../common/store'; import { createFilter } from '../../../../../common/containers/helpers'; @@ -97,10 +97,6 @@ export const useNetworkKpiDns = ({ refetch: refetch.current, })); searchSubscription$.current.unsubscribe(); - } else if (isErrorResponse(response)) { - setLoading(false); - addWarning(i18n.ERROR_NETWORK_KPI_DNS); - searchSubscription$.current.unsubscribe(); } }, error: (msg) => { diff --git a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx index fe631b6b7e975..078cc211e4cf9 100644 --- a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx @@ -10,7 +10,7 @@ import { noop } from 'lodash/fp'; import { useCallback, useEffect, useRef, useState } from 'react'; import { Subscription } from 'rxjs'; -import { isCompleteResponse, isErrorResponse } from '@kbn/data-plugin/common'; +import { isCompleteResponse } from '@kbn/data-plugin/common'; import { useAppToasts } from '../../../../../common/hooks/use_app_toasts'; import type { inputsModel } from '../../../../../common/store'; import { createFilter } from '../../../../../common/containers/helpers'; @@ -101,10 +101,6 @@ export const useNetworkKpiNetworkEvents = ({ refetch: refetch.current, })); searchSubscription$.current.unsubscribe(); - } else if (isErrorResponse(response)) { - setLoading(false); - addWarning(i18n.ERROR_NETWORK_KPI_NETWORK_EVENTS); - searchSubscription$.current.unsubscribe(); } }, error: (msg) => { diff --git a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/tls_handshakes/index.tsx b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/tls_handshakes/index.tsx index 63beacc2d297d..516b504b1cb5c 100644 --- a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/tls_handshakes/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/tls_handshakes/index.tsx @@ -10,7 +10,7 @@ import { noop } from 'lodash/fp'; import { useCallback, useEffect, useRef, useState } from 'react'; import { Subscription } from 'rxjs'; -import { isCompleteResponse, isErrorResponse } from '@kbn/data-plugin/common'; +import { isCompleteResponse } from '@kbn/data-plugin/common'; import { useAppToasts } from '../../../../../common/hooks/use_app_toasts'; import type { inputsModel } from '../../../../../common/store'; import { createFilter } from '../../../../../common/containers/helpers'; @@ -100,10 +100,6 @@ export const useNetworkKpiTlsHandshakes = ({ refetch: refetch.current, })); searchSubscription$.current.unsubscribe(); - } else if (isErrorResponse(response)) { - setLoading(false); - addWarning(i18n.ERROR_NETWORK_KPI_TLS_HANDSHAKES); - searchSubscription$.current.unsubscribe(); } }, error: (msg) => { diff --git a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_flows/index.tsx b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_flows/index.tsx index 0d62d4e286201..173d95c8b1897 100644 --- a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_flows/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_flows/index.tsx @@ -10,7 +10,7 @@ import { noop } from 'lodash/fp'; import { useCallback, useEffect, useRef, useState } from 'react'; import { Subscription } from 'rxjs'; -import { isCompleteResponse, isErrorResponse } from '@kbn/data-plugin/common'; +import { isCompleteResponse } from '@kbn/data-plugin/common'; import { useAppToasts } from '../../../../../common/hooks/use_app_toasts'; import type { inputsModel } from '../../../../../common/store'; import { createFilter } from '../../../../../common/containers/helpers'; @@ -100,10 +100,6 @@ export const useNetworkKpiUniqueFlows = ({ refetch: refetch.current, })); searchSubscription$.current.unsubscribe(); - } else if (isErrorResponse(response)) { - setLoading(false); - addWarning(i18n.ERROR_NETWORK_KPI_UNIQUE_FLOWS); - searchSubscription$.current.unsubscribe(); } }, error: (msg) => { diff --git a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_private_ips/index.tsx b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_private_ips/index.tsx index 2e73cb18ef52d..3b1aee64fee76 100644 --- a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_private_ips/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_private_ips/index.tsx @@ -10,7 +10,7 @@ import { noop } from 'lodash/fp'; import { useCallback, useEffect, useRef, useState } from 'react'; import { Subscription } from 'rxjs'; -import { isCompleteResponse, isErrorResponse } from '@kbn/data-plugin/common'; +import { isCompleteResponse } from '@kbn/data-plugin/common'; import { useAppToasts } from '../../../../../common/hooks/use_app_toasts'; import type { inputsModel } from '../../../../../common/store'; import { createFilter } from '../../../../../common/containers/helpers'; @@ -112,10 +112,6 @@ export const useNetworkKpiUniquePrivateIps = ({ refetch: refetch.current, })); searchSubscription$.current.unsubscribe(); - } else if (isErrorResponse(response)) { - setLoading(false); - addWarning(i18n.ERROR_NETWORK_KPI_UNIQUE_PRIVATE_IPS); - searchSubscription$.current.unsubscribe(); } }, error: (msg) => { diff --git a/x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/use_ti_data_sources.ts b/x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/use_ti_data_sources.ts index 43aff52970348..96a0c44327909 100644 --- a/x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/use_ti_data_sources.ts +++ b/x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/use_ti_data_sources.ts @@ -9,7 +9,7 @@ import { filter } from 'rxjs/operators'; import { useEffect, useState } from 'react'; import { useObservable, withOptionalSignal } from '@kbn/securitysolution-hook-utils'; import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; -import { isCompleteResponse, isErrorResponse } from '@kbn/data-plugin/public'; +import { isCompleteResponse } from '@kbn/data-plugin/public'; import { useKibana } from '../../../common/lib/kibana'; import type { Bucket, @@ -51,7 +51,7 @@ export const getTiDataSourcesComplete = ( ): Observable => { return getTiDataSources(props).pipe( filter((response) => { - return isErrorResponse(response) || isCompleteResponse(response); + return isCompleteResponse(response); }) ); }; diff --git a/x-pack/plugins/security_solution/public/timelines/containers/index.tsx b/x-pack/plugins/security_solution/public/timelines/containers/index.tsx index 6d2837db0eddc..6e324e6cb5fb1 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/containers/index.tsx @@ -12,7 +12,7 @@ import { useDispatch } from 'react-redux'; import { Subscription } from 'rxjs'; import type { DataView } from '@kbn/data-plugin/common'; -import { isCompleteResponse, isErrorResponse } from '@kbn/data-plugin/common'; +import { isCompleteResponse } from '@kbn/data-plugin/common'; import type { ESQuery } from '../../../common/typed_json'; import type { inputsModel } from '../../common/store'; @@ -275,11 +275,6 @@ export const useTimelineEventsHandler = ({ return newTimelineResponse; }); - searchSubscription$.current.unsubscribe(); - } else if (isErrorResponse(response)) { - endTracking('invalid'); - setLoading(false); - addWarning(i18n.ERROR_TIMELINE_EVENTS); searchSubscription$.current.unsubscribe(); } }, diff --git a/x-pack/plugins/security_solution/public/timelines/containers/kpis/index.tsx b/x-pack/plugins/security_solution/public/timelines/containers/kpis/index.tsx index 5bd71f4f7be94..7ea5a89f96441 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/kpis/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/containers/kpis/index.tsx @@ -10,7 +10,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'; import deepEqual from 'fast-deep-equal'; import { Subscription } from 'rxjs'; -import { isCompleteResponse, isErrorResponse } from '@kbn/data-plugin/public'; +import { isCompleteResponse } from '@kbn/data-plugin/public'; import type { inputsModel } from '../../../common/store'; import { useKibana } from '../../../common/lib/kibana'; import type { @@ -68,10 +68,6 @@ export const useTimelineKpis = ({ setLoading(false); setTimelineKpiResponse(response); searchSubscription$.current.unsubscribe(); - } else if (isErrorResponse(response)) { - setLoading(false); - addWarning(i18n.FAIL_TIMELINE_KPI_DETAILS); - searchSubscription$.current.unsubscribe(); } }, error: (msg) => { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx index d509c2dcf98f7..2758081a26820 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx @@ -12,7 +12,7 @@ import { noop } from 'lodash'; import { useCallback, useEffect, useReducer, useRef, useMemo } from 'react'; import { Subscription } from 'rxjs'; -import { isCompleteResponse, isErrorResponse } from '@kbn/data-plugin/common'; +import { isCompleteResponse } from '@kbn/data-plugin/common'; import type { RuleRegistrySearchRequest, RuleRegistrySearchRequestPagination, @@ -260,10 +260,6 @@ const useFetchAlerts = ({ totalAlerts, }); searchSubscription$.current.unsubscribe(); - } else if (isErrorResponse(response)) { - dispatch({ type: 'loading', loading: false }); - data.search.showError(new Error(i18n.ERROR_FETCH_ALERTS)); - searchSubscription$.current.unsubscribe(); } }, error: (msg) => { From 081e780f3ab6896d2e4260db25710ffb09e15be9 Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 23 Aug 2023 11:24:52 -0600 Subject: [PATCH 02/20] eslint --- .../common/components/events_viewer/use_timelines_events.tsx | 4 +--- .../public/common/containers/events/last_event_time/index.ts | 4 ++-- .../public/common/containers/matrix_histogram/index.ts | 4 ++-- .../public/common/containers/use_search_strategy/index.tsx | 3 +-- .../explore/network/containers/kpi_network/dns/index.tsx | 4 ++-- .../network/containers/kpi_network/network_events/index.tsx | 4 ++-- .../network/containers/kpi_network/tls_handshakes/index.tsx | 4 ++-- .../network/containers/kpi_network/unique_flows/index.tsx | 4 ++-- .../containers/kpi_network/unique_private_ips/index.tsx | 4 ++-- .../security_solution/public/timelines/containers/index.tsx | 4 ---- .../public/timelines/containers/kpis/index.tsx | 4 ++-- 11 files changed, 18 insertions(+), 25 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx index f72205b4c2158..73923ab1ba90e 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx @@ -32,7 +32,6 @@ import type { RunTimeMappings } from '../../store/sourcerer/model'; import { TimelineEventsQueries } from '../../../../common/search_strategy'; import type { KueryFilterQueryKind } from '../../../../common/types'; import type { ESQuery } from '../../../../common/typed_json'; -import { useAppToasts } from '../../hooks/use_app_toasts'; import { ERROR_TIMELINE_EVENTS } from './translations'; import type { AlertWorkflowStatus } from '../../types'; import { getSearchTransactionName, useStartTransaction } from '../../lib/apm/use_start_transaction'; @@ -220,7 +219,6 @@ export const useTimelineEventsHandler = ({ loadPage: wrappedLoadPage, updatedAt: 0, }); - const { addWarning } = useAppToasts(); const timelineSearch = useCallback( (request: TimelineRequest | null, onNextHandler?: OnNextResponseHandler) => { @@ -287,7 +285,7 @@ export const useTimelineEventsHandler = ({ asyncSearch(); refetch.current = asyncSearch; }, - [skip, data, entityType, dataViewId, addWarning, startTracking, dispatch, id, prevFilterStatus] + [skip, data, entityType, dataViewId, startTracking, dispatch, id, prevFilterStatus] ); useEffect(() => { diff --git a/x-pack/plugins/security_solution/public/common/containers/events/last_event_time/index.ts b/x-pack/plugins/security_solution/public/common/containers/events/last_event_time/index.ts index c908ad8f767af..8904ccd5ad8bb 100644 --- a/x-pack/plugins/security_solution/public/common/containers/events/last_event_time/index.ts +++ b/x-pack/plugins/security_solution/public/common/containers/events/last_event_time/index.ts @@ -59,7 +59,7 @@ export const useTimelineLastEventTime = ({ refetch: refetch.current, errorMessage: undefined, }); - const { addError, addWarning } = useAppToasts(); + const { addError } = useAppToasts(); const timelineLastEventTimeSearch = useCallback( (request: TimelineEventsLastEventTimeRequestOptions) => { @@ -104,7 +104,7 @@ export const useTimelineLastEventTime = ({ asyncSearch(); refetch.current = asyncSearch; }, - [data.search, addError, addWarning] + [data.search, addError] ); useEffect(() => { diff --git a/x-pack/plugins/security_solution/public/common/containers/matrix_histogram/index.ts b/x-pack/plugins/security_solution/public/common/containers/matrix_histogram/index.ts index c2393cb060c57..137acc4f1c9e7 100644 --- a/x-pack/plugins/security_solution/public/common/containers/matrix_histogram/index.ts +++ b/x-pack/plugins/security_solution/public/common/containers/matrix_histogram/index.ts @@ -92,7 +92,7 @@ export const useMatrixHistogram = ({ ...(isPtrIncluded != null ? { isPtrIncluded } : {}), ...(includeMissingData != null ? { includeMissingData } : {}), }); - const { addError, addWarning } = useAppToasts(); + const { addError } = useAppToasts(); const [matrixHistogramResponse, setMatrixHistogramResponse] = useState({ data: [], @@ -155,7 +155,7 @@ export const useMatrixHistogram = ({ asyncSearch(); refetch.current = asyncSearch; }, - [data.search, histogramType, addWarning, addError, errorMessage, startTracking] + [data.search, histogramType, addError, errorMessage, startTracking] ); useEffect(() => { diff --git a/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.tsx b/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.tsx index c41b3e847f40f..b9cd06e77e27e 100644 --- a/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.tsx +++ b/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.tsx @@ -47,7 +47,6 @@ export const useSearch = ( factoryQueryType: QueryType ): UseSearchFunction => { const { data } = useKibana().services; - const { addWarning } = useAppToasts(); const { startTracking } = useTrackHttpRequest(); const search = useCallback>( @@ -78,7 +77,7 @@ export const useSearch = ( return observable; }, - [addWarning, data.search, factoryQueryType, startTracking] + [data.search, factoryQueryType, startTracking] ); return search; diff --git a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx index 34722b8b2b99d..cf52d2b4ee0eb 100644 --- a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx @@ -69,7 +69,7 @@ export const useNetworkKpiDns = ({ isInspected: false, refetch: refetch.current, }); - const { addError, addWarning } = useAppToasts(); + const { addError } = useAppToasts(); const networkKpiDnsSearch = useCallback( (request: NetworkKpiDnsRequestOptions | null) => { @@ -113,7 +113,7 @@ export const useNetworkKpiDns = ({ asyncSearch(); refetch.current = asyncSearch; }, - [data.search, addError, addWarning, skip] + [data.search, addError, skip] ); useEffect(() => { diff --git a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx index 078cc211e4cf9..378120d155e16 100644 --- a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx @@ -70,7 +70,7 @@ export const useNetworkKpiNetworkEvents = ({ isInspected: false, refetch: refetch.current, }); - const { addError, addWarning } = useAppToasts(); + const { addError } = useAppToasts(); const networkKpiNetworkEventsSearch = useCallback( (request: NetworkKpiNetworkEventsRequestOptions | null) => { @@ -117,7 +117,7 @@ export const useNetworkKpiNetworkEvents = ({ asyncSearch(); refetch.current = asyncSearch; }, - [data.search, addError, addWarning, skip] + [data.search, addError, skip] ); useEffect(() => { diff --git a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/tls_handshakes/index.tsx b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/tls_handshakes/index.tsx index 516b504b1cb5c..b53c07640220e 100644 --- a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/tls_handshakes/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/tls_handshakes/index.tsx @@ -70,7 +70,7 @@ export const useNetworkKpiTlsHandshakes = ({ isInspected: false, refetch: refetch.current, }); - const { addError, addWarning } = useAppToasts(); + const { addError } = useAppToasts(); const networkKpiTlsHandshakesSearch = useCallback( (request: NetworkKpiTlsHandshakesRequestOptions | null) => { @@ -116,7 +116,7 @@ export const useNetworkKpiTlsHandshakes = ({ asyncSearch(); refetch.current = asyncSearch; }, - [data.search, addError, addWarning, skip] + [data.search, addError, skip] ); useEffect(() => { diff --git a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_flows/index.tsx b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_flows/index.tsx index 173d95c8b1897..6ff0eb5372a19 100644 --- a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_flows/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_flows/index.tsx @@ -70,7 +70,7 @@ export const useNetworkKpiUniqueFlows = ({ isInspected: false, refetch: refetch.current, }); - const { addError, addWarning } = useAppToasts(); + const { addError } = useAppToasts(); const networkKpiUniqueFlowsSearch = useCallback( (request: NetworkKpiUniqueFlowsRequestOptions | null) => { @@ -116,7 +116,7 @@ export const useNetworkKpiUniqueFlows = ({ asyncSearch(); refetch.current = asyncSearch; }, - [data.search, addError, addWarning, skip] + [data.search, addError, skip] ); useEffect(() => { diff --git a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_private_ips/index.tsx b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_private_ips/index.tsx index 3b1aee64fee76..45435665dba41 100644 --- a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_private_ips/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/unique_private_ips/index.tsx @@ -77,7 +77,7 @@ export const useNetworkKpiUniquePrivateIps = ({ isInspected: false, refetch: refetch.current, }); - const { addError, addWarning } = useAppToasts(); + const { addError } = useAppToasts(); const networkKpiUniquePrivateIpsSearch = useCallback( (request: NetworkKpiUniquePrivateIpsRequestOptions | null) => { @@ -128,7 +128,7 @@ export const useNetworkKpiUniquePrivateIps = ({ asyncSearch(); refetch.current = asyncSearch; }, - [data.search, addError, addWarning, skip] + [data.search, addError, skip] ); useEffect(() => { diff --git a/x-pack/plugins/security_solution/public/timelines/containers/index.tsx b/x-pack/plugins/security_solution/public/timelines/containers/index.tsx index 6e324e6cb5fb1..2ef25737b4e02 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/containers/index.tsx @@ -42,7 +42,6 @@ import type { TimelineEqlRequestOptions, TimelineEqlResponse, } from '../../../common/search_strategy/timeline/events/eql'; -import { useAppToasts } from '../../common/hooks/use_app_toasts'; import { useTrackHttpRequest } from '../../common/lib/apm/use_track_http_request'; import { APP_UI_ID } from '../../../common/constants'; @@ -221,8 +220,6 @@ export const useTimelineEventsHandler = ({ } }, [setUpdated, timelineResponse.updatedAt]); - const { addWarning } = useAppToasts(); - const timelineSearch = useCallback( async ( request: TimelineRequest | null, @@ -337,7 +334,6 @@ export const useTimelineEventsHandler = ({ startTracking, data.search, dataViewId, - addWarning, refetchGrid, wrappedLoadPage, ] diff --git a/x-pack/plugins/security_solution/public/timelines/containers/kpis/index.tsx b/x-pack/plugins/security_solution/public/timelines/containers/kpis/index.tsx index 7ea5a89f96441..f2a1d81ec0294 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/kpis/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/containers/kpis/index.tsx @@ -46,7 +46,7 @@ export const useTimelineKpis = ({ ); const [timelineKpiResponse, setTimelineKpiResponse] = useState(null); - const { addError, addWarning } = useAppToasts(); + const { addError } = useAppToasts(); const timelineKpiSearch = useCallback( (request: TimelineKpiStrategyRequest | null) => { @@ -82,7 +82,7 @@ export const useTimelineKpis = ({ asyncSearch(); refetch.current = asyncSearch; }, - [data.search, addError, addWarning] + [data.search, addError] ); useEffect(() => { From ceb771aa552281248ecd8c40080b0975f0362cc9 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 23 Aug 2023 17:30:24 +0000 Subject: [PATCH 03/20] [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' --- .../events_viewer/use_timelines_events.tsx | 1 - .../public/timelines/containers/index.tsx | 12 +----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx index 73923ab1ba90e..b3694bed85554 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx @@ -32,7 +32,6 @@ import type { RunTimeMappings } from '../../store/sourcerer/model'; import { TimelineEventsQueries } from '../../../../common/search_strategy'; import type { KueryFilterQueryKind } from '../../../../common/types'; import type { ESQuery } from '../../../../common/typed_json'; -import { ERROR_TIMELINE_EVENTS } from './translations'; import type { AlertWorkflowStatus } from '../../types'; import { getSearchTransactionName, useStartTransaction } from '../../lib/apm/use_start_transaction'; export type InspectResponse = Inspect & { response: string[] }; diff --git a/x-pack/plugins/security_solution/public/timelines/containers/index.tsx b/x-pack/plugins/security_solution/public/timelines/containers/index.tsx index 2ef25737b4e02..b65c7c7c51498 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/containers/index.tsx @@ -32,7 +32,6 @@ import type { } from '../../../common/search_strategy'; import { Direction, TimelineEventsQueries } from '../../../common/search_strategy'; import type { InspectResponse } from '../../types'; -import * as i18n from './translations'; import type { KueryFilterQueryKind } from '../../../common/types/timeline'; import { TimelineId } from '../../../common/types/timeline'; import { useRouteSpy } from '../../common/utils/route/use_route_spy'; @@ -327,16 +326,7 @@ export const useTimelineEventsHandler = ({ await asyncSearch(); refetch.current = asyncSearch; }, - [ - pageName, - skip, - id, - startTracking, - data.search, - dataViewId, - refetchGrid, - wrappedLoadPage, - ] + [pageName, skip, id, startTracking, data.search, dataViewId, refetchGrid, wrappedLoadPage] ); useEffect(() => { From 991d157579f95e9a00210351ecc3bf6d62dffb08 Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 23 Aug 2023 11:54:59 -0600 Subject: [PATCH 04/20] tslint --- examples/search_examples/public/search/app.tsx | 1 - .../application/sections/alerts_table/hooks/use_fetch_alerts.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/examples/search_examples/public/search/app.tsx b/examples/search_examples/public/search/app.tsx index 3b2a8634e6aa6..0fa13df35a4e9 100644 --- a/examples/search_examples/public/search/app.tsx +++ b/examples/search_examples/public/search/app.tsx @@ -30,7 +30,6 @@ import { DataPublicPluginStart, IKibanaSearchResponse, isCompleteResponse, - isErrorResponse, } from '@kbn/data-plugin/public'; import { SearchResponseWarning } from '@kbn/data-plugin/public/search/types'; import type { DataView, DataViewField } from '@kbn/data-views-plugin/public'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx index 2758081a26820..374e2883cc089 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx @@ -27,7 +27,6 @@ import type { import type { Alert, Alerts, GetInspectQuery, InspectQuery } from '../../../../types'; import { useKibana } from '../../../../common/lib/kibana'; import { DefaultSort } from './constants'; -import * as i18n from './translations'; export interface FetchAlertsArgs { featureIds: ValidFeatureId[]; From e9d40f00211572b3a1799157aa455c11b5a48a04 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 23 Aug 2023 18:26:54 +0000 Subject: [PATCH 05/20] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- x-pack/plugins/aiops/public/hooks/use_cancellable_search.ts | 5 +---- .../public/common/containers/cti/event_enrichment/api.ts | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/aiops/public/hooks/use_cancellable_search.ts b/x-pack/plugins/aiops/public/hooks/use_cancellable_search.ts index a0d716364f192..a44e176c1c073 100644 --- a/x-pack/plugins/aiops/public/hooks/use_cancellable_search.ts +++ b/x-pack/plugins/aiops/public/hooks/use_cancellable_search.ts @@ -6,10 +6,7 @@ */ import { useCallback, useRef, useState } from 'react'; -import { - type IKibanaSearchResponse, - isCompleteResponse, -} from '@kbn/data-plugin/common'; +import { type IKibanaSearchResponse, isCompleteResponse } from '@kbn/data-plugin/common'; import { tap } from 'rxjs/operators'; import { useAiopsAppContext } from './use_aiops_app_context'; diff --git a/x-pack/plugins/security_solution/public/common/containers/cti/event_enrichment/api.ts b/x-pack/plugins/security_solution/public/common/containers/cti/event_enrichment/api.ts index e120ce72d859b..0d08b9a93a5c4 100644 --- a/x-pack/plugins/security_solution/public/common/containers/cti/event_enrichment/api.ts +++ b/x-pack/plugins/security_solution/public/common/containers/cti/event_enrichment/api.ts @@ -46,6 +46,4 @@ export const getEventEnrichment = ({ export const getEventEnrichmentComplete = ( props: GetEventEnrichmentProps ): Observable => - getEventEnrichment(props).pipe( - filter((response) => isCompleteResponse(response)) - ); + getEventEnrichment(props).pipe(filter((response) => isCompleteResponse(response))); From c631e08512ab3a972d6ca88f4ebaa6420ea471cc Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 23 Aug 2023 13:03:10 -0600 Subject: [PATCH 06/20] tslint --- .../common/components/events_viewer/use_timelines_events.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx index b3694bed85554..c462b98ddf296 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx @@ -230,7 +230,6 @@ export const useTimelineEventsHandler = ({ abortCtrl.current = new AbortController(); setLoading(true); if (data && data.search) { - const { endTracking } = startTracking(); const abortSignal = abortCtrl.current.signal; searchSubscription$.current = data.search .search, TimelineResponse>( From 43e7774e8a8829a77d00bb2eeb86f8ea3409f1a4 Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 23 Aug 2023 13:39:53 -0600 Subject: [PATCH 07/20] lint --- .../common/components/events_viewer/use_timelines_events.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx index c462b98ddf296..490166cf114d7 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx @@ -283,7 +283,7 @@ export const useTimelineEventsHandler = ({ asyncSearch(); refetch.current = asyncSearch; }, - [skip, data, entityType, dataViewId, startTracking, dispatch, id, prevFilterStatus] + [skip, data, entityType, dataViewId, dispatch, id, prevFilterStatus] ); useEffect(() => { From d71119f030a7542d928b6d9bda1b8b9145c059c0 Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 23 Aug 2023 14:22:01 -0600 Subject: [PATCH 08/20] tslint and remove invalid test case --- .../events_viewer/use_timelines_events.tsx | 1 - .../containers/matrix_histogram/index.test.ts | 13 ------------- 2 files changed, 14 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx index 490166cf114d7..5eaa4517cb87c 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx @@ -155,7 +155,6 @@ export const useTimelineEventsHandler = ({ filterStatus, }: UseTimelineEventsProps): [boolean, TimelineArgs, TimelineEventsSearchHandler] => { const dispatch = useDispatch(); - const { startTracking } = useApmTracking(id); const refetch = useRef(noop); const abortCtrl = useRef(new AbortController()); const searchSubscription$ = useRef(new Subscription()); diff --git a/x-pack/plugins/security_solution/public/common/containers/matrix_histogram/index.test.ts b/x-pack/plugins/security_solution/public/common/containers/matrix_histogram/index.test.ts index dba14afd0ff2e..fab3766d2c5d0 100644 --- a/x-pack/plugins/security_solution/public/common/containers/matrix_histogram/index.test.ts +++ b/x-pack/plugins/security_solution/public/common/containers/matrix_histogram/index.test.ts @@ -190,19 +190,6 @@ describe('useMatrixHistogram', () => { expect(mockEndTracking).toHaveBeenCalledWith('success'); }); - it('should end tracking error when the partial request is invalid', () => { - (useKibana().services.data.search.search as jest.Mock).mockReturnValueOnce({ - subscribe: ({ next }: { next: Function }) => next(null), - }); - - renderHook(useMatrixHistogram, { - initialProps: props, - wrapper: TestProviders, - }); - - expect(mockEndTracking).toHaveBeenCalledWith('invalid'); - }); - it('should end tracking error when the request fails', () => { (useKibana().services.data.search.search as jest.Mock).mockReturnValueOnce({ subscribe: ({ error }: { error: Function }) => error('some error'), From acd70650bc5b61d54b73ce42f0e9a8788b0e7d59 Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 23 Aug 2023 15:29:04 -0600 Subject: [PATCH 09/20] keep call to useApmTracking --- .../common/components/events_viewer/use_timelines_events.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx index 5eaa4517cb87c..14b86886835dc 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx @@ -155,6 +155,7 @@ export const useTimelineEventsHandler = ({ filterStatus, }: UseTimelineEventsProps): [boolean, TimelineArgs, TimelineEventsSearchHandler] => { const dispatch = useDispatch(); + useApmTracking(id); const refetch = useRef(noop); const abortCtrl = useRef(new AbortController()); const searchSubscription$ = useRef(new Subscription()); From 48aece87a6091c76e47f9975ac72d763b2beff0c Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 23 Aug 2023 15:30:36 -0600 Subject: [PATCH 10/20] call startTracing --- .../common/components/events_viewer/use_timelines_events.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx index 14b86886835dc..72dfc90fc5d6d 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx @@ -155,7 +155,7 @@ export const useTimelineEventsHandler = ({ filterStatus, }: UseTimelineEventsProps): [boolean, TimelineArgs, TimelineEventsSearchHandler] => { const dispatch = useDispatch(); - useApmTracking(id); + const { startTracking } = useApmTracking(id); const refetch = useRef(noop); const abortCtrl = useRef(new AbortController()); const searchSubscription$ = useRef(new Subscription()); @@ -230,6 +230,7 @@ export const useTimelineEventsHandler = ({ abortCtrl.current = new AbortController(); setLoading(true); if (data && data.search) { + startTracking(); const abortSignal = abortCtrl.current.signal; searchSubscription$.current = data.search .search, TimelineResponse>( From 14c7d2a8b52dcdacb97bcf9a92f51293eea7eb50 Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 23 Aug 2023 15:31:37 -0600 Subject: [PATCH 11/20] put startTracking back in dependencies list --- .../common/components/events_viewer/use_timelines_events.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx index 72dfc90fc5d6d..2b234879ccc50 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx @@ -284,7 +284,7 @@ export const useTimelineEventsHandler = ({ asyncSearch(); refetch.current = asyncSearch; }, - [skip, data, entityType, dataViewId, dispatch, id, prevFilterStatus] + [skip, data, entityType, dataViewId, startTracking, dispatch, id, prevFilterStatus] ); useEffect(() => { From 952410a52558fba9f568305fcd39dc2e784d5b4a Mon Sep 17 00:00:00 2001 From: nreese Date: Thu, 24 Aug 2023 11:20:42 -0600 Subject: [PATCH 12/20] fix jest tests --- .../use_search_strategy/index.test.ts | 17 ++----- .../hooks/use_fetch_alerts.test.tsx | 49 ++----------------- .../alerts_table/hooks/use_fetch_alerts.tsx | 1 + 3 files changed, 10 insertions(+), 57 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.test.ts b/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.test.ts index 00dd75222cafb..f286d9faebc0c 100644 --- a/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.test.ts +++ b/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.test.ts @@ -273,14 +273,16 @@ describe('useSearchStrategy', () => { expect(mockEndTracking).toBeCalledWith('success'); }); - it('should track invalid search result', () => { - mockResponse.mockReturnValueOnce({}); // mock invalid empty response + it('should handle search error', () => { + mockResponse.mockImplementation(() => { + throw new Error('simulated search response error, which could be 1) undefined response, 2) response without rawResponse, or 3) partial response'); + }); const { result } = renderHook(() => useSearch(factoryQueryType)); result.current({ request, abortSignal: new AbortController().signal }); expect(mockStartTracking).toBeCalledTimes(1); - expect(mockEndTracking).toBeCalledWith('invalid'); + expect(mockEndTracking).toBeCalledWith('error'); }); it('should track error search result', () => { @@ -310,14 +312,5 @@ describe('useSearchStrategy', () => { expect(mockEndTracking).toBeCalledTimes(1); expect(mockEndTracking).toBeCalledWith('aborted'); }); - - it('should show toast warning when the API returns partial invalid response', () => { - mockResponse.mockReturnValueOnce({}); // mock invalid empty response - - const { result } = renderHook(() => useSearch(factoryQueryType)); - result.current({ request, abortSignal: new AbortController().signal }); - - expect(mockAddToastWarning).toBeCalled(); - }); }); }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.test.tsx index 06c712ef87e2b..f24f5f68c5b09 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.test.tsx @@ -6,7 +6,7 @@ */ import sinon from 'sinon'; -import { of } from 'rxjs'; +import { of, throwError } from 'rxjs'; import { act, renderHook } from '@testing-library/react-hooks'; import { useFetchAlerts, FetchAlertsArgs, FetchAlertResp } from './use_fetch_alerts'; import { useKibana } from '../../../../common/lib/kibana'; @@ -286,9 +286,9 @@ describe('useFetchAlerts', () => { ]); }); - it('returns the correct response if the request is undefined', () => { + it('handles search error', () => { // @ts-expect-error - const obs$ = of(undefined); + const obs$ = throwError('simulated search response error, which could be 1) undefined response, 2) response without rawResponse, or 3) partial response'); dataSearchMock.mockReturnValue(obs$); const { result } = renderHook(() => useFetchAlerts(args)); @@ -308,7 +308,7 @@ describe('useFetchAlerts', () => { expect(showErrorMock).toHaveBeenCalled(); }); - it('returns the correct response if the request is running', () => { + it('returns the correct response if the search response is running', () => { const obs$ = of({ ...searchResponse, isRunning: true }); dataSearchMock.mockReturnValue(obs$); const { result } = renderHook(() => useFetchAlerts(args)); @@ -327,47 +327,6 @@ describe('useFetchAlerts', () => { ]); }); - it('returns the correct response if the request is partial', () => { - const obs$ = of({ ...searchResponse, isPartial: true }); - dataSearchMock.mockReturnValue(obs$); - const { result } = renderHook(() => useFetchAlerts(args)); - - expect(result.current).toEqual([ - false, - { - ...expectedResponse, - alerts: [], - getInspectQuery: expect.anything(), - refetch: expect.anything(), - isInitializing: true, - totalAlerts: -1, - updatedAt: 0, - }, - ]); - expect(showErrorMock).toHaveBeenCalled(); - }); - - it('returns the correct response if there is no rawResponse', () => { - // @ts-expect-error - const obs$ = of({ id: '1', isRunning: true, isPartial: false }); - dataSearchMock.mockReturnValue(obs$); - const { result } = renderHook(() => useFetchAlerts(args)); - - expect(result.current).toEqual([ - false, - { - ...expectedResponse, - alerts: [], - getInspectQuery: expect.anything(), - refetch: expect.anything(), - isInitializing: true, - totalAlerts: -1, - updatedAt: 0, - }, - ]); - expect(showErrorMock).toHaveBeenCalled(); - }); - it('returns the correct total alerts if the total alerts in the response is an object', () => { const obs$ = of({ ...searchResponse, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx index 374e2883cc089..3a73b02a0a55d 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx @@ -262,6 +262,7 @@ const useFetchAlerts = ({ } }, error: (msg) => { + console.log('error thrown', msg); dispatch({ type: 'loading', loading: false }); data.search.showError(msg); searchSubscription$.current.unsubscribe(); From 9a0bc67c5f67c7a7a6d573b02429b19a08798b8a Mon Sep 17 00:00:00 2001 From: nreese Date: Thu, 24 Aug 2023 12:16:47 -0600 Subject: [PATCH 13/20] remove console log --- .../application/sections/alerts_table/hooks/use_fetch_alerts.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx index 3a73b02a0a55d..374e2883cc089 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.tsx @@ -262,7 +262,6 @@ const useFetchAlerts = ({ } }, error: (msg) => { - console.log('error thrown', msg); dispatch({ type: 'loading', loading: false }); data.search.showError(msg); searchSubscription$.current.unsubscribe(); From fda5d0629d18894c96fb2f05e4c3892446f54562 Mon Sep 17 00:00:00 2001 From: nreese Date: Thu, 24 Aug 2023 12:40:03 -0600 Subject: [PATCH 14/20] remove isErrorResponse for searchSource.search --- .../data/common/search/search_source/search_source.ts | 5 +---- .../public/timelines/containers/details/index.tsx | 6 +----- x-pack/plugins/threat_intelligence/public/utils/search.ts | 4 ---- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/plugins/data/common/search/search_source/search_source.ts b/src/plugins/data/common/search/search_source/search_source.ts index c11289439885b..91eea3e50f881 100644 --- a/src/plugins/data/common/search/search_source/search_source.ts +++ b/src/plugins/data/common/search/search_source/search_source.ts @@ -106,7 +106,6 @@ import { getRequestInspectorStats, getResponseInspectorStats } from './inspect'; import { getEsQueryConfig, IKibanaSearchResponse, - isErrorResponse, isPartialResponse, isCompleteResponse, UI_SETTINGS, @@ -547,9 +546,7 @@ export class SearchSource { // For testing timeout messages in UI, uncomment the next line // response.rawResponse.timed_out = true; return new Observable>((obs) => { - if (isErrorResponse(response)) { - obs.error(response); - } else if (isPartialResponse(response)) { + if (isPartialResponse(response)) { obs.next(this.postFlightTransform(response)); } else { if (!this.hasPostFlightRequests()) { diff --git a/x-pack/plugins/security_solution/public/timelines/containers/details/index.tsx b/x-pack/plugins/security_solution/public/timelines/containers/details/index.tsx index c07e52b09874f..c8c4653ae1cee 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/details/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/containers/details/index.tsx @@ -11,7 +11,7 @@ import ReactDOM from 'react-dom'; import deepEqual from 'fast-deep-equal'; import { Subscription } from 'rxjs'; -import { isCompleteResponse, isErrorResponse } from '@kbn/data-plugin/common'; +import { isCompleteResponse } from '@kbn/data-plugin/common'; import { EntityType } from '@kbn/timelines-plugin/common'; import type { EcsSecurityExtension as Ecs } from '@kbn/securitysolution-ecs'; import { useKibana } from '../../../common/lib/kibana'; @@ -99,10 +99,6 @@ export const useTimelineEventsDetails = ({ searchSubscription$.current.unsubscribe(); }); }); - } else if (isErrorResponse(response)) { - setLoading(false); - addWarning(i18n.FAIL_TIMELINE_DETAILS); - searchSubscription$.current.unsubscribe(); } }, error: (msg) => { diff --git a/x-pack/plugins/threat_intelligence/public/utils/search.ts b/x-pack/plugins/threat_intelligence/public/utils/search.ts index e54bd6ecef885..1dac39f74b230 100644 --- a/x-pack/plugins/threat_intelligence/public/utils/search.ts +++ b/x-pack/plugins/threat_intelligence/public/utils/search.ts @@ -9,7 +9,6 @@ import { IEsSearchRequest, IKibanaSearchResponse, isCompleteResponse, - isErrorResponse, } from '@kbn/data-plugin/common'; import { ISearchStart } from '@kbn/data-plugin/public'; import { RequestAdapter } from '@kbn/inspector-plugin/common'; @@ -97,9 +96,6 @@ export const search = async ( if (isCompleteResponse(response)) { inspect.recordRequestCompletion(searchRequest, response); resolve(response.rawResponse); - } else if (isErrorResponse(response)) { - inspect.recordRequestError(response); - reject(response); } }, error: (requestError) => { From 663a4dbfce92c853e54b7560228b85bfcbd265b3 Mon Sep 17 00:00:00 2001 From: nreese Date: Thu, 24 Aug 2023 12:47:04 -0600 Subject: [PATCH 15/20] tslint --- .../public/timelines/containers/details/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/security_solution/public/timelines/containers/details/index.tsx b/x-pack/plugins/security_solution/public/timelines/containers/details/index.tsx index c8c4653ae1cee..3b326e492d132 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/details/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/containers/details/index.tsx @@ -62,7 +62,7 @@ export const useTimelineEventsDetails = ({ const [loading, setLoading] = useState(true); const [timelineDetailsRequest, setTimelineDetailsRequest] = useState(null); - const { addError, addWarning } = useAppToasts(); + const { addError } = useAppToasts(); const [timelineDetailsResponse, setTimelineDetailsResponse] = useState(null); @@ -113,7 +113,7 @@ export const useTimelineEventsDetails = ({ asyncSearch(); refetch.current = asyncSearch; }, - [data.search, addError, addWarning, skip] + [data.search, addError, skip] ); useEffect(() => { From c3189d0a4b5ff7563acc64298e2d33925c7621b9 Mon Sep 17 00:00:00 2001 From: nreese Date: Thu, 24 Aug 2023 13:45:31 -0600 Subject: [PATCH 16/20] tslint --- .../sections/alerts_table/hooks/use_fetch_alerts.test.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.test.tsx index f24f5f68c5b09..93c498ca8b1b3 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.test.tsx @@ -287,7 +287,6 @@ describe('useFetchAlerts', () => { }); it('handles search error', () => { - // @ts-expect-error const obs$ = throwError('simulated search response error, which could be 1) undefined response, 2) response without rawResponse, or 3) partial response'); dataSearchMock.mockReturnValue(obs$); const { result } = renderHook(() => useFetchAlerts(args)); From 98402acaebb5621426d95b9fbb269d5b4cd22421 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 24 Aug 2023 19:51:13 +0000 Subject: [PATCH 17/20] [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' --- .../sections/alerts_table/hooks/use_fetch_alerts.test.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.test.tsx index 93c498ca8b1b3..ef515cf8ffdca 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/hooks/use_fetch_alerts.test.tsx @@ -287,7 +287,9 @@ describe('useFetchAlerts', () => { }); it('handles search error', () => { - const obs$ = throwError('simulated search response error, which could be 1) undefined response, 2) response without rawResponse, or 3) partial response'); + const obs$ = throwError( + 'simulated search response error, which could be 1) undefined response, 2) response without rawResponse, or 3) partial response' + ); dataSearchMock.mockReturnValue(obs$); const { result } = renderHook(() => useFetchAlerts(args)); From 91b41cae22d0d051ab55d1aaec10a30e0dbcfd0b Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 24 Aug 2023 20:25:34 +0000 Subject: [PATCH 18/20] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../common/containers/use_search_strategy/index.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.test.ts b/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.test.ts index f286d9faebc0c..6a3b48dce6615 100644 --- a/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.test.ts +++ b/x-pack/plugins/security_solution/public/common/containers/use_search_strategy/index.test.ts @@ -275,7 +275,9 @@ describe('useSearchStrategy', () => { it('should handle search error', () => { mockResponse.mockImplementation(() => { - throw new Error('simulated search response error, which could be 1) undefined response, 2) response without rawResponse, or 3) partial response'); + throw new Error( + 'simulated search response error, which could be 1) undefined response, 2) response without rawResponse, or 3) partial response' + ); }); const { result } = renderHook(() => useSearch(factoryQueryType)); From 251df102e339dbf71469bb0ae89bff0ba41a82f4 Mon Sep 17 00:00:00 2001 From: nreese Date: Thu, 24 Aug 2023 16:03:10 -0600 Subject: [PATCH 19/20] remove unused translation --- .../containers/events/last_event_time/translations.ts | 7 ------- x-pack/plugins/translations/translations/fr-FR.json | 1 - x-pack/plugins/translations/translations/ja-JP.json | 1 - x-pack/plugins/translations/translations/zh-CN.json | 1 - 4 files changed, 10 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/containers/events/last_event_time/translations.ts b/x-pack/plugins/security_solution/public/common/containers/events/last_event_time/translations.ts index c882029958934..840567d5c1f14 100644 --- a/x-pack/plugins/security_solution/public/common/containers/events/last_event_time/translations.ts +++ b/x-pack/plugins/security_solution/public/common/containers/events/last_event_time/translations.ts @@ -7,13 +7,6 @@ import { i18n } from '@kbn/i18n'; -export const ERROR_LAST_EVENT_TIME = i18n.translate( - 'xpack.securitySolution.lastEventTime.errorSearchDescription', - { - defaultMessage: `An error has occurred on last event time search`, - } -); - export const FAIL_LAST_EVENT_TIME = i18n.translate( 'xpack.securitySolution.lastEventTime.failSearchDescription', { diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index 147738ec2eda0..cc0123be57ab6 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -33579,7 +33579,6 @@ "xpack.securitySolution.kubernetes.columnPod": "Pod", "xpack.securitySolution.kubernetes.columnSessionStart": "Date de démarrage", "xpack.securitySolution.landing.threatHunting.hostsDescription": "Aperçu complet de tous les hôtes et événements de sécurité des hôtes.", - "xpack.securitySolution.lastEventTime.errorSearchDescription": "Une erreur s'est produite sur la recherche de dernière heure de l'événement", "xpack.securitySolution.lastEventTime.failSearchDescription": "Impossible de lancer une recherche sur la dernière heure de l'événement", "xpack.securitySolution.lensEmbeddable.NoDataToDisplay.title": "Aucune donnée à afficher", "xpack.securitySolution.licensing.unsupportedMachineLearningMessage": "Votre licence ne prend pas en charge le Machine Learning. Veuillez mettre votre licence à niveau.", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index ba3c415751725..85f5afaba68d1 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -33578,7 +33578,6 @@ "xpack.securitySolution.kubernetes.columnPod": "ポッド", "xpack.securitySolution.kubernetes.columnSessionStart": "開始日", "xpack.securitySolution.landing.threatHunting.hostsDescription": "すべてのホストとホスト関連のセキュリティイベントに関する包括的な概要。", - "xpack.securitySolution.lastEventTime.errorSearchDescription": "前回のイベント時刻検索でエラーが発生しました。", "xpack.securitySolution.lastEventTime.failSearchDescription": "前回のイベント時刻で検索を実行できませんでした", "xpack.securitySolution.lensEmbeddable.NoDataToDisplay.title": "表示するデータがありません", "xpack.securitySolution.licensing.unsupportedMachineLearningMessage": "ご使用のライセンスは機械翻訳をサポートしていません。ライセンスをアップグレードしてください。", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index be39a446a11a8..29fd5b6df43d3 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -33574,7 +33574,6 @@ "xpack.securitySolution.kubernetes.columnPod": "Pod", "xpack.securitySolution.kubernetes.columnSessionStart": "开始日期", "xpack.securitySolution.landing.threatHunting.hostsDescription": "所有主机和主机相关安全事件的全面概览。", - "xpack.securitySolution.lastEventTime.errorSearchDescription": "搜索上次事件时间时发生错误", "xpack.securitySolution.lastEventTime.failSearchDescription": "无法对上次事件时间执行搜索", "xpack.securitySolution.lensEmbeddable.NoDataToDisplay.title": "没有可显示的数据", "xpack.securitySolution.licensing.unsupportedMachineLearningMessage": "您的许可证不支持 Machine Learning。请升级您的许可证。", From 265f833a14aa1116c8ece5401f2d591fd2386703 Mon Sep 17 00:00:00 2001 From: nreese Date: Thu, 24 Aug 2023 17:15:12 -0600 Subject: [PATCH 20/20] remove invalid test case --- .../search_source/search_source.test.ts | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/src/plugins/data/common/search/search_source/search_source.test.ts b/src/plugins/data/common/search/search_source/search_source.test.ts index eeb4c5a972e3a..8ceaab7e12a18 100644 --- a/src/plugins/data/common/search/search_source/search_source.test.ts +++ b/src/plugins/data/common/search/search_source/search_source.test.ts @@ -1105,32 +1105,6 @@ describe('SearchSource', () => { expect(complete2).toBeCalledTimes(1); expect(searchSourceDependencies.search).toHaveBeenCalledTimes(1); }); - - test('should emit error on empty response', async () => { - searchSourceDependencies.search = mockSearchMethod = jest - .fn() - .mockReturnValue( - of({ rawResponse: { test: 1 }, isPartial: true, isRunning: true }, undefined) - ); - - searchSource = new SearchSource({ index: indexPattern }, searchSourceDependencies); - const options = {}; - - const next = jest.fn(); - const error = jest.fn(); - const complete = jest.fn(); - const res$ = searchSource.fetch$(options); - res$.subscribe({ next, error, complete }); - await firstValueFrom(res$).catch((_) => {}); - - expect(next).toBeCalledTimes(1); - expect(error).toBeCalledTimes(1); - expect(complete).toBeCalledTimes(0); - expect(next.mock.calls[0][0].rawResponse).toStrictEqual({ - test: 1, - }); - expect(error.mock.calls[0][0]).toBe(undefined); - }); }); describe('inspector', () => {