Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discover] Update unified histogram to use Lens #143117

Merged
Merged
Show file tree
Hide file tree
Changes from 100 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
fe306b0
[Discover] Start updating unified histogram to use Lens
davismcphee Oct 13, 2022
4f09f75
[Discover] Add filters and query support to unified histogram
davismcphee Oct 13, 2022
5847970
[Discover] Update indexpattern to formBased in Lens config
davismcphee Oct 14, 2022
ea02b13
[Discover] Fix histogram time interval
davismcphee Oct 15, 2022
54fc5e1
[Discover] Continue adding support for histogram breakdown
davismcphee Oct 17, 2022
16d2824
[Discover] Removing Discover dependency from Lens
davismcphee Oct 17, 2022
6ea0ade
[Discover] Finish removing Discover dependencies from Lens
davismcphee Oct 18, 2022
954ba1c
[Discover] Add support for breakdown field selector to unifiedHistogram
davismcphee Oct 24, 2022
9084844
[Discover] Fix Lens histogram loading indicator position
davismcphee Oct 24, 2022
5578336
[Discover] Fix Lens histogram not reacting to query/filter change
davismcphee Oct 24, 2022
9cccac2
[Discover] Add support for total hits
davismcphee Oct 25, 2022
db92baa
[Discover] Removed chart data fetching from Discover and Unified Hist…
davismcphee Oct 26, 2022
838445c
[Discover] Update unfiied histogram to make total hits request
davismcphee Oct 29, 2022
017a7cb
[Discover] Moved breakdown field to URL app state instead of local st…
davismcphee Nov 2, 2022
f38547e
[Discover] Updating histogram labels and settings
davismcphee Nov 3, 2022
7d00ff8
[Discover] fix functionals
dimaanj Nov 3, 2022
d362441
Merge pull request #1 from dimaanj/fix-functionals-of-histogram-as-le…
davismcphee Nov 3, 2022
4c68c1b
[Discover] Add support for inspecting Lens requests in Discover
davismcphee Nov 3, 2022
1543ff6
[Discover] Clear Lens request adapter on chart hidden
davismcphee Nov 3, 2022
8c5a9fb
[Discover] Field unified histogram breakdown fields
davismcphee Nov 4, 2022
8482445
[Discover] Fix Lens services breaking from merge
davismcphee Nov 4, 2022
f19c72a
[Discover] Fix grid rendering when chart visibility changes
davismcphee Nov 4, 2022
f7384af
[Discover] Fix issue where time range in total hits request was not b…
davismcphee Nov 4, 2022
af9a681
[Discover] Improve time range text loading state
davismcphee Nov 4, 2022
3186657
[Discover] fix dashboard tests
dimaanj Nov 4, 2022
3e4418b
[Discover] fix jest tests
dimaanj Nov 4, 2022
e45eef3
[Discover] fix some jest tests
dimaanj Nov 4, 2022
191c1ac
Merge pull request #2 from dimaanj/fix-ci-unified-histogram-pr
davismcphee Nov 5, 2022
b100682
[Discover] Clean up doc table force rerender code
davismcphee Nov 7, 2022
e047d7c
[Discover] Make lastReloadRequestTime a top level prop
davismcphee Nov 7, 2022
2848897
[Discover] Update queryStateContainer to be a ref
davismcphee Nov 7, 2022
ee84cf8
[Discover] Add documentation for useTotalHits
davismcphee Nov 7, 2022
b07d286
[Discover] Change UnifiedHistogramFetchStatus to an enum
davismcphee Nov 7, 2022
633db2c
[Discover] Fix issue where unified histogram doesn't start fetching u…
davismcphee Nov 8, 2022
d646cb3
Implement saved search breakdownField persistence
kertal Nov 8, 2022
5315030
Merge branch 'enhancement-unified-histogram-lens' of github.com:davis…
kertal Nov 8, 2022
fff2b03
[Discover] improve tests
dimaanj Nov 8, 2022
16b7c4e
Merge pull request #3 from dimaanj/improve-tests
davismcphee Nov 8, 2022
042c700
[Discover] Make fetchAll wait on unified histogram to finish loading …
davismcphee Nov 8, 2022
43c00f6
[Discover] Include 'other' bucket in unified histogram
davismcphee Nov 8, 2022
ef02c44
[Discover] Skip first lastReloadRequestTime effect
davismcphee Nov 8, 2022
801e6a3
[Discover] Hide breakdown if undefined
davismcphee Nov 9, 2022
bfb7b24
[Discover] Use search session to determine when to fetch unified hist…
davismcphee Nov 9, 2022
0e6de80
[Discover] Prevent hits.total changes triggering a Lens refetch
davismcphee Nov 9, 2022
4ca75e3
[Discover] Use refetchId to determine when unified histogram should r…
davismcphee Nov 9, 2022
ff69195
[Discover] fix some tests
dimaanj Nov 9, 2022
192fcec
[Discover] cleanup
davismcphee Nov 9, 2022
c40eda8
[Discover] Refetch data when chart visibility is toggled or breakdown…
davismcphee Nov 9, 2022
8efb7a4
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Nov 10, 2022
b94bcc7
Merge remote-tracking branch 'davis-remote/enhancement-unified-histog…
dimaanj Nov 11, 2022
6bce46e
[Discover] fix include typings
dimaanj Nov 11, 2022
b582bc7
[Discover] try to fix type check failure
dimaanj Nov 11, 2022
26b2feb
[Discover] fix discover layout test
dimaanj Nov 11, 2022
b59058d
[Discover] fix ts config
dimaanj Nov 11, 2022
4a992b1
[Discover] fix tests
dimaanj Nov 14, 2022
6121d61
[Discover] fix ci
dimaanj Nov 14, 2022
b0bff11
[Discover] add navigation to Lens using breakdown by field
dimaanj Nov 15, 2022
76d8e35
[Discover] fix tests
dimaanj Nov 15, 2022
274f0df
[Discover] fix remaining tests
dimaanj Nov 15, 2022
28827a7
Merge pull request #4 from dimaanj/fix-some-tests
davismcphee Nov 16, 2022
c76c8f9
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Nov 16, 2022
a2b6221
[Discover] enable navigation from Lens with breakdown field
dimaanj Nov 16, 2022
dc3097d
Merge branch 'main' into enhancement-unified-histogram-lens
kibanamachine Nov 16, 2022
f3f3f88
[Discover] Cleaning up some component and prop names, and fixing dupl…
davismcphee Nov 16, 2022
1ddef16
[Discover] Fix use_discover_histogram.test.ts types
davismcphee Nov 16, 2022
f2eda4a
[Discover] Show current time marker
davismcphee Nov 16, 2022
6c660d0
[Discover] Fixed issue with total hits loading flicker on refetch
davismcphee Nov 16, 2022
e66de99
[Discover] Fix and add new tests for use_discover_histogram.test.tsx
davismcphee Nov 16, 2022
c3b315a
[Discover] Make sure the breakdown field is accounted for when saving…
davismcphee Nov 16, 2022
932d276
[Discover] Fix broken types from Jest test fix
davismcphee Nov 16, 2022
9fd9c5b
[Discover] Updating and fixing Jest tests
davismcphee Nov 17, 2022
b302478
[Discover] Add Discover loading spinner back in
davismcphee Nov 17, 2022
963ae17
[Discover] Upating comments in use_discover_histogram
davismcphee Nov 17, 2022
b53cf5b
[Discover] Add Jest tests for new files
davismcphee Nov 18, 2022
d057d9f
[Discover] Updating existing Jest tests for new functionality
davismcphee Nov 18, 2022
dc2ea16
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Nov 18, 2022
d9f71f9
[Discover] Fix flaky histogram shown/hidden functional tests
davismcphee Nov 18, 2022
8835af0
[Discover] Added Jest tests for histogram.tsx
davismcphee Nov 18, 2022
c86627f
Merge branch 'main' into enhancement-unified-histogram-lens
kibanamachine Nov 21, 2022
4754d20
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Nov 21, 2022
27922b3
[Discover] Add placeholder text to breakdown_field_selector
davismcphee Nov 21, 2022
900877d
[Discover] do not bring breakdown field on Lens to Discover navigation
dimaanj Nov 22, 2022
dd49efe
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Nov 22, 2022
395f570
[Discover] Rollback Lens visualize button changes and update Discover…
davismcphee Nov 22, 2022
6ace558
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Nov 23, 2022
6cc4f6c
Merge branch 'main' into enhancement-unified-histogram-lens
kibanamachine Nov 24, 2022
5c8e0f9
[Discover] Added tooltip to breakdown field selector
davismcphee Nov 25, 2022
84c0d74
[Discover] Remove dscPageContent__inner class, add Lens input title s…
davismcphee Nov 28, 2022
bbd0ce0
[Discover] Add default unified histogram Lens input title
davismcphee Nov 28, 2022
46ef36a
[Discover] Remove duplicate .dscPageContent selector from discover_la…
davismcphee Nov 29, 2022
2352b8c
[Discover] Add breakdown selector aria label
davismcphee Nov 30, 2022
e4b6a0d
[Discover] Fix elements overflowing the histogram container at small …
davismcphee Nov 30, 2022
58e8949
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Nov 30, 2022
b69f071
[Discover] Update check_registered_types test
davismcphee Nov 30, 2022
b5742b6
[Discover] Update time range 'loading...' to 'Loading'
davismcphee Nov 30, 2022
59be2b0
[Discover] Emit an error when Lens fails so that Discover doesn't dis…
davismcphee Nov 30, 2022
0aa75a3
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Dec 1, 2022
467eab6
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Dec 1, 2022
7a126b0
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Dec 1, 2022
7f291a8
[Discover] Update breakdownField to be text type
davismcphee Dec 1, 2022
34d925c
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Dec 1, 2022
194796e
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Dec 2, 2022
2a9d568
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Dec 3, 2022
5ce0423
[Discover] Fix false positives when setting chartDisplayChanged, caus…
davismcphee Dec 3, 2022
25f23d6
[Discover] Fix flaky autorefresh test
davismcphee Dec 3, 2022
26ecfad
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Dec 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"osquery-saved-query": "7b213b4b7a3e59350e99c50e8df9948662ed493a",
"query": "4640ef356321500a678869f24117b7091a911cb6",
"sample-data-telemetry": "8b10336d9efae6f3d5593c4cc89fb4abcdf84e04",
"search": "d26771bcf7cd271162aab3a610b75249631ef6b1",
"search": "c48f5ab5d94545780ea98de1bff9e39f17f3606b",
"search-session": "ba383309da68a15be3765977f7a44c84f0ec7964",
"search-telemetry": "beb3fc25488c753f2a6dcff1845d667558712b66",
"security-rule": "e0dfdba5d66139d0300723b2e6672993cd4a11f3",
Expand Down
1 change: 0 additions & 1 deletion src/plugins/dashboard/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
{ "path": "../screenshot_mode/tsconfig.json" },
{ "path": "../ui_actions/tsconfig.json" },
{ "path": "../charts/tsconfig.json" },
{ "path": "../discover/tsconfig.json" },
{ "path": "../visualizations/tsconfig.json" },
{ "path": "../../../x-pack/plugins/spaces/tsconfig.json" }
]
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/discover/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"usageCollection",
"spaces",
"triggersActionsUi",
"savedObjectsTaggingOss"
"savedObjectsTaggingOss",
"lens"
],
"requiredBundles": ["kibanaUtils", "kibanaReact", "unifiedSearch", "savedSearch"],
"extraPublicDirs": ["common"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const fields = [
},
{
name: 'timestamp',
displayName: 'timestamp',
type: 'date',
scripted: false,
filterable: true,
Expand All @@ -26,26 +27,30 @@ const fields = [
},
{
name: 'message',
displayName: 'message',
type: 'string',
scripted: false,
filterable: false,
},
{
name: 'extension',
displayName: 'extension',
type: 'string',
scripted: false,
filterable: true,
aggregatable: true,
},
{
name: 'bytes',
displayName: 'bytes',
type: 'number',
scripted: false,
filterable: true,
aggregatable: true,
},
{
name: 'scripted',
displayName: 'scripted',
type: 'number',
scripted: true,
filterable: false,
Expand Down
9 changes: 5 additions & 4 deletions src/plugins/discover/public/__mocks__/search_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
import { DataPublicPluginStart } from '@kbn/data-plugin/public';
import { DiscoverSearchSessionManager } from '../application/main/services/discover_search_session';

export function createSearchSessionMock() {
const history = createMemoryHistory();
const session = dataPluginMock.createStartContract().search.session as jest.Mocked<
export function createSearchSessionMock(
session = dataPluginMock.createStartContract().search.session as jest.Mocked<
DataPublicPluginStart['search']['session']
>;
>
) {
const history = createMemoryHistory();
const searchSessionManager = new DiscoverSearchSessionManager({
history,
session,
Expand Down
1 change: 1 addition & 0 deletions src/plugins/discover/public/__mocks__/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export function createDiscoverServicesMock(): DiscoverServices {
savedObjectsTagging: {},
dataViews: dataPlugin.dataViews,
timefilter: dataPlugin.query.timefilter.timefilter,
lens: { EmbeddableComponent: jest.fn(() => null) },
locator: {
useUrl: jest.fn(() => ''),
navigate: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import { SearchSource } from '@kbn/data-plugin/common';
import { BehaviorSubject, Subject } from 'rxjs';
import { RequestAdapter } from '@kbn/inspector-plugin/common';
import { action } from '@storybook/addon-actions';
import type { SearchResponse } from '@elastic/elasticsearch/lib/api/types';
import { FetchStatus } from '../../../../types';
import {
AvailableFields$,
DataCharts$,
DataDocuments$,
DataMain$,
DataTotalHits$,
Expand Down Expand Up @@ -47,11 +45,6 @@ const documentObservables = {
fetchStatus: FetchStatus.COMPLETE,
result: Number(esHits.length),
}) as DataTotalHits$,

charts$: new BehaviorSubject({
fetchStatus: FetchStatus.COMPLETE,
response: {} as unknown as SearchResponse,
}) as DataCharts$,
};

const plainRecordObservables = {
Expand All @@ -77,11 +70,6 @@ const plainRecordObservables = {
fetchStatus: FetchStatus.COMPLETE,
recordRawType: RecordRawType.PLAIN,
}) as DataTotalHits$,

charts$: new BehaviorSubject({
fetchStatus: FetchStatus.COMPLETE,
recordRawType: RecordRawType.PLAIN,
}) as DataCharts$,
};

const getCommonProps = (dataView: DataView) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import { Subject, BehaviorSubject, of } from 'rxjs';
import { mountWithIntl } from '@kbn/test-jest-helpers';
import { esHits } from '../../../../__mocks__/es_hits';
import { dataViewMock } from '../../../../__mocks__/data_view';
import { savedSearchMock } from '../../../../__mocks__/saved_search';
import { GetStateReturn } from '../../services/discover_state';
import {
AvailableFields$,
DataDocuments$,
DataMain$,
DataTotalHits$,
RecordRawType,
} from '../../hooks/use_saved_search';
import { discoverServiceMock } from '../../../../__mocks__/services';
import { FetchStatus } from '../../../types';
import { KibanaContextProvider, KibanaThemeProvider } from '@kbn/kibana-react-plugin/public';
import { buildDataTableRecord } from '../../../../utils/build_data_record';
import { DiscoverHistogramLayout, DiscoverHistogramLayoutProps } from './discover_histogram_layout';
import { SavedSearch, VIEW_MODE } from '@kbn/saved-search-plugin/public';
import { CoreTheme } from '@kbn/core/public';
import { act } from 'react-dom/test-utils';
import { setTimeout } from 'timers/promises';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import { LocalStorageMock } from '../../../../__mocks__/local_storage_mock';
import { HISTOGRAM_HEIGHT_KEY } from './use_discover_histogram';
import { createSearchSessionMock } from '../../../../__mocks__/search_session';
import { RequestAdapter } from '@kbn/inspector-plugin/public';
import { searchSourceInstanceMock } from '@kbn/data-plugin/common/search/search_source/mocks';
import { UnifiedHistogramLayout } from '@kbn/unified-histogram-plugin/public';
import { getSessionServiceMock } from '@kbn/data-plugin/public/search/session/mocks';
import { ResetSearchButton } from './reset_search_button';

const mountComponent = async ({
isPlainRecord = false,
hideChart = false,
isTimeBased = true,
storage,
savedSearch = savedSearchMock,
resetSavedSearch = jest.fn(),
}: {
isPlainRecord?: boolean;
hideChart?: boolean;
isTimeBased?: boolean;
storage?: Storage;
savedSearch?: SavedSearch;
resetSavedSearch?(): void;
} = {}) => {
let services = discoverServiceMock;
services.data.query.timefilter.timefilter.getAbsoluteTime = () => {
return { from: '2020-05-14T11:05:13.590', to: '2020-05-14T11:20:13.590' };
};

(services.data.query.queryString.getDefaultQuery as jest.Mock).mockReturnValue({
language: 'kuery',
query: '',
});
(searchSourceInstanceMock.fetch$ as jest.Mock).mockImplementation(
jest.fn().mockReturnValue(of({ rawResponse: { hits: { total: 2 } } }))
);

if (storage) {
services = { ...services, storage };
}

const main$ = new BehaviorSubject({
fetchStatus: FetchStatus.COMPLETE,
recordRawType: isPlainRecord ? RecordRawType.PLAIN : RecordRawType.DOCUMENT,
foundDocuments: true,
}) as DataMain$;

const documents$ = new BehaviorSubject({
fetchStatus: FetchStatus.COMPLETE,
result: esHits.map((esHit) => buildDataTableRecord(esHit, dataViewMock)),
}) as DataDocuments$;

const availableFields$ = new BehaviorSubject({
fetchStatus: FetchStatus.COMPLETE,
fields: [] as string[],
}) as AvailableFields$;

const totalHits$ = new BehaviorSubject({
fetchStatus: FetchStatus.COMPLETE,
result: Number(esHits.length),
}) as DataTotalHits$;

const savedSearchData$ = {
main$,
documents$,
totalHits$,
availableFields$,
};

const session = getSessionServiceMock();

session.getSession$.mockReturnValue(new BehaviorSubject('123'));

const props: DiscoverHistogramLayoutProps = {
isPlainRecord,
dataView: dataViewMock,
navigateTo: jest.fn(),
setExpandedDoc: jest.fn(),
savedSearch,
savedSearchData$,
savedSearchRefetch$: new Subject(),
state: { columns: [], hideChart },
stateContainer: {
setAppState: () => {},
appStateContainer: {
getState: () => ({
interval: 'auto',
}),
},
} as unknown as GetStateReturn,
onFieldEdited: jest.fn(),
columns: [],
viewMode: VIEW_MODE.DOCUMENT_LEVEL,
onAddFilter: jest.fn(),
resetSavedSearch,
isTimeBased,
resizeRef: { current: null },
searchSessionManager: createSearchSessionMock(session).searchSessionManager,
inspectorAdapters: { requests: new RequestAdapter() },
};

const coreTheme$ = new BehaviorSubject<CoreTheme>({ darkMode: false });

const component = mountWithIntl(
<KibanaContextProvider services={services}>
<KibanaThemeProvider theme$={coreTheme$}>
<DiscoverHistogramLayout {...props} />
</KibanaThemeProvider>
</KibanaContextProvider>
);

// DiscoverMainContent uses UnifiedHistogramLayout which
// is lazy loaded, so we need to wait for it to be loaded
await act(() => setTimeout(0));
component.update();

return component;
};

describe('Discover histogram layout component', () => {
describe('topPanelHeight persistence', () => {
it('should try to get the initial topPanelHeight for UnifiedHistogramLayout from storage', async () => {
const storage = new LocalStorageMock({}) as unknown as Storage;
const originalGet = storage.get;
storage.get = jest.fn().mockImplementation(originalGet);
await mountComponent({ storage });
expect(storage.get).toHaveBeenCalledWith(HISTOGRAM_HEIGHT_KEY);
});

it('should pass undefined to UnifiedHistogramLayout if no value is found in storage', async () => {
const storage = new LocalStorageMock({}) as unknown as Storage;
const originalGet = storage.get;
storage.get = jest.fn().mockImplementation(originalGet);
const component = await mountComponent({ storage });
expect(storage.get).toHaveBeenCalledWith(HISTOGRAM_HEIGHT_KEY);
expect(storage.get).toHaveReturnedWith(null);
expect(component.find(UnifiedHistogramLayout).prop('topPanelHeight')).toBe(undefined);
});

it('should pass the stored topPanelHeight to UnifiedHistogramLayout if a value is found in storage', async () => {
const storage = new LocalStorageMock({}) as unknown as Storage;
const topPanelHeight = 123;
storage.get = jest.fn().mockImplementation(() => topPanelHeight);
const component = await mountComponent({ storage });
expect(storage.get).toHaveBeenCalledWith(HISTOGRAM_HEIGHT_KEY);
expect(storage.get).toHaveReturnedWith(topPanelHeight);
expect(component.find(UnifiedHistogramLayout).prop('topPanelHeight')).toBe(topPanelHeight);
});

it('should update the topPanelHeight in storage and pass the new value to UnifiedHistogramLayout when the topPanelHeight changes', async () => {
const storage = new LocalStorageMock({}) as unknown as Storage;
const originalSet = storage.set;
storage.set = jest.fn().mockImplementation(originalSet);
const component = await mountComponent({ storage });
const newTopPanelHeight = 123;
expect(component.find(UnifiedHistogramLayout).prop('topPanelHeight')).not.toBe(
newTopPanelHeight
);
act(() => {
component.find(UnifiedHistogramLayout).prop('onTopPanelHeightChange')!(newTopPanelHeight);
});
component.update();
expect(storage.set).toHaveBeenCalledWith(HISTOGRAM_HEIGHT_KEY, newTopPanelHeight);
expect(component.find(UnifiedHistogramLayout).prop('topPanelHeight')).toBe(newTopPanelHeight);
});
});

describe('reset search button', () => {
it('renders the button when there is a saved search', async () => {
const component = await mountComponent();
expect(component.find(ResetSearchButton).exists()).toBe(true);
});

it('does not render the button when there is no saved search', async () => {
const component = await mountComponent({
savedSearch: { ...savedSearchMock, id: undefined },
});
expect(component.find(ResetSearchButton).exists()).toBe(false);
});

it('should call resetSavedSearch when clicked', async () => {
const resetSavedSearch = jest.fn();
const component = await mountComponent({ resetSavedSearch });
component.find(ResetSearchButton).find('button').simulate('click');
expect(resetSavedSearch).toHaveBeenCalled();
});
});
});
Loading