forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[data.search.autocomplete] Move autocomplete method to UI settings (e…
…lastic#106331) (elastic#106949) * [data.search.autocomplete] Move autocomplete method to UI settings * Use select rather than boolean * Add ftue tour * Make a select rather than text box * Only show when focused and first time page is loaded * Add docs link * Reverse order of sections * Update docs/concepts/index.asciidoc Co-authored-by: gchaps <33642766+gchaps@users.noreply.github.com> * Update docs/concepts/index.asciidoc Co-authored-by: gchaps <33642766+gchaps@users.noreply.github.com> * Docs updates * setting * telemetry * Add links to docs * Fix translations * Fix failing test * Fix test * Fix tests * Revert changes to querybar service * Fix discover query Co-authored-by: gchaps <33642766+gchaps@users.noreply.github.com> Co-authored-by: Liza K <liza.katz@elastic.co> Co-authored-by: Lukas Olson <olson.lukas@gmail.com> Co-authored-by: gchaps <33642766+gchaps@users.noreply.github.com> Co-authored-by: Liza K <liza.katz@elastic.co>
- Loading branch information
1 parent
456de5f
commit 4f86331
Showing
27 changed files
with
363 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
docs/development/core/public/kibana-plugin-core-public.doclinksstart.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/plugins/data/public/ui/query_string_input/autocomplete_ftue_popover.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* 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, { ReactElement } from 'react'; | ||
import { mountWithIntl as mount } from '@kbn/test/jest'; | ||
import { AutocompleteFtuePopover } from './autocomplete_ftue_popover'; | ||
import { EuiTourStep } from '@elastic/eui'; | ||
import { act } from 'react-dom/test-utils'; | ||
import { coreMock } from '../../../../../core/public/mocks'; | ||
import { KibanaContextProvider } from '../../../../kibana_react/public'; | ||
import { IStorageWrapper } from '../../../../kibana_utils/public'; | ||
const startMock = coreMock.createStart(); | ||
|
||
describe('AutocompleteFtuePopover', () => { | ||
function wrapInContext(props: { | ||
isVisible?: boolean; | ||
storage: IStorageWrapper; | ||
children: ReactElement; | ||
}) { | ||
const services = { docLinks: startMock.docLinks }; | ||
return ( | ||
<KibanaContextProvider services={services}> | ||
<AutocompleteFtuePopover {...props} /> | ||
</KibanaContextProvider> | ||
); | ||
} | ||
|
||
const createMockStorage = () => ({ | ||
get: jest.fn(), | ||
set: jest.fn(), | ||
remove: jest.fn(), | ||
clear: jest.fn(), | ||
}); | ||
|
||
it('should hide popover if local storage flag is set', () => { | ||
const children = <span />; | ||
const storage = createMockStorage(); | ||
storage.get.mockReturnValue(true); | ||
const instance = mount(wrapInContext({ storage, children })); | ||
expect(instance.find(EuiTourStep).prop('isStepOpen')).toBe(false); | ||
}); | ||
|
||
it('should render popover if local storage flag is not set', () => { | ||
const children = <span />; | ||
const instance = mount( | ||
wrapInContext({ | ||
storage: createMockStorage(), | ||
isVisible: true, | ||
children, | ||
}) | ||
); | ||
expect(instance.find(EuiTourStep).prop('isStepOpen')).toBe(true); | ||
}); | ||
|
||
it('should hide popover if it is closed', async () => { | ||
const props = { | ||
children: <span />, | ||
showAutocompleteFtuePopover: true, | ||
storage: createMockStorage(), | ||
}; | ||
const instance = mount(wrapInContext(props)); | ||
act(() => { | ||
instance.find(EuiTourStep).prop('closePopover')!(); | ||
}); | ||
expect(instance.find(EuiTourStep).prop('isStepOpen')).toBe(false); | ||
}); | ||
|
||
it('should set local storage flag and hide on closing with button', () => { | ||
const props = { | ||
children: <span />, | ||
showAutocompleteFtuePopover: true, | ||
storage: createMockStorage(), | ||
}; | ||
const instance = mount(wrapInContext(props)); | ||
act(() => { | ||
instance.find(EuiTourStep).prop('footerAction')!.props.onClick(); | ||
}); | ||
expect(props.storage.set).toHaveBeenCalledWith(expect.any(String), true); | ||
expect(instance.find(EuiTourStep).prop('isStepOpen')).toBe(false); | ||
}); | ||
}); |
Oops, something went wrong.