diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/empty_states/error_state.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/empty_states/error_state.tsx
index 0725d3650054e8..039e645a271268 100644
--- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/empty_states/error_state.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/empty_states/error_state.tsx
@@ -25,7 +25,7 @@ export const ErrorState: ReactFC<> = () => {
-
+
({ sendTelemetry: jest.fn() }));
@@ -15,48 +15,27 @@ import { sendTelemetry } from '../../../shared/telemetry';
import { EngineOverviewHeader } from '../engine_overview_header';
describe('EngineOverviewHeader', () => {
- describe('when enterpriseSearchUrl is set', () => {
- let button;
-
- beforeAll(() => {
- useContext.mockImplementationOnce(() => ({ enterpriseSearchUrl: 'http://localhost:3002' }));
- const wrapper = shallow();
- button = wrapper.find('[data-test-subj="launchButton"]');
- });
-
- describe('the Launch App Search button', () => {
- it('should not be disabled', () => {
- expect(button.props().isDisabled).toBeFalsy();
- });
-
- it('should use the enterpriseSearchUrl as the base path for its href', () => {
- expect(button.props().href).toBe('http://localhost:3002/as');
- });
-
- it('should send telemetry when clicked', () => {
- button.simulate('click');
- expect(sendTelemetry).toHaveBeenCalled();
- });
- });
+ it('renders', () => {
+ const wrapper = shallow();
+ expect(wrapper.find('h1')).toHaveLength(1);
});
- describe('when enterpriseSearchUrl is not set', () => {
- let button;
+ it('renders a launch app search button that sends telemetry on click', () => {
+ const wrapper = shallow();
+ const button = wrapper.find('[data-test-subj="launchButton"]');
- beforeAll(() => {
- useContext.mockImplementationOnce(() => ({ enterpriseSearchUrl: undefined }));
- const wrapper = shallow();
- button = wrapper.find('[data-test-subj="launchButton"]');
- });
+ expect(button.props().href).toBe('http://localhost:3002/as');
+ expect(button.props().isDisabled).toBeFalsy();
- describe('the Launch App Search button', () => {
- it('should be disabled', () => {
- expect(button.props().isDisabled).toBe(true);
- });
+ button.simulate('click');
+ expect(sendTelemetry).toHaveBeenCalled();
+ });
+
+ it('renders a disabled button when isButtonDisabled is true', () => {
+ const wrapper = shallow();
+ const button = wrapper.find('[data-test-subj="launchButton"]');
- it('should not have an href', () => {
- expect(button.props().href).toBeUndefined();
- });
- });
+ expect(button.props().isDisabled).toBe(true);
+ expect(button.props().href).toBeUndefined();
});
});
diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview_header/engine_overview_header.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview_header/engine_overview_header.tsx
index 20ad3ce5ad2727..650a864f5e615e 100644
--- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview_header/engine_overview_header.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview_header/engine_overview_header.tsx
@@ -11,15 +11,23 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { sendTelemetry } from '../../../shared/telemetry';
import { KibanaContext, IKibanaContext } from '../../../index';
-export const EngineOverviewHeader: React.FC<> = () => {
+interface IEngineOverviewHeaderProps {
+ isButtonDisabled?: boolean;
+}
+
+export const EngineOverviewHeader: React.FC = ({
+ isButtonDisabled,
+}) => {
const { enterpriseSearchUrl, http } = useContext(KibanaContext) as IKibanaContext;
const buttonProps = {
fill: true,
iconType: 'popout',
- ['data-test-subj']: 'launchButton',
+ 'data-test-subj': 'launchButton',
};
- if (enterpriseSearchUrl) {
+ if (isButtonDisabled) {
+ buttonProps.isDisabled = true;
+ } else {
buttonProps.href = `${enterpriseSearchUrl}/as`;
buttonProps.target = '_blank';
buttonProps.onClick = () =>
@@ -29,8 +37,6 @@ export const EngineOverviewHeader: React.FC<> = () => {
action: 'clicked',
metric: 'header_launch_button',
});
- } else {
- buttonProps.isDisabled = true;
}
return (