diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_client_instructions.test.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_client_instructions.test.tsx
new file mode 100644
index 0000000000000..b7fe9c459ee6d
--- /dev/null
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_client_instructions.test.tsx
@@ -0,0 +1,57 @@
+/*
+ * 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; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+import { setMockValues } from '../../../__mocks__/kea_logic';
+
+import React from 'react';
+
+import { shallow, ShallowWrapper } from 'enzyme';
+
+import * as Languages from './languages';
+
+import { ElasticsearchClientInstructions } from '.';
+
+describe('Elasticsearch Client Instructions', () => {
+ let wrapper: ShallowWrapper;
+
+ afterEach(() => {
+ jest.clearAllMocks();
+ });
+
+ const setup = (language: string) => {
+ setMockValues({
+ cloud: {
+ cloudId: 'example-cloud-id',
+ },
+ });
+ wrapper = shallow();
+ };
+
+ describe('Displaying the right language options', () => {
+ it.concurrent.each([
+ ['dotnet', Languages.ElasticsearchDotnet, false],
+ ['go', Languages.ElasticsearchGo, true],
+ ['java', Languages.ElasticsearchJava, false],
+ ['javascript', Languages.ElasticsearchJavascript, true],
+ ['php', Languages.ElasticsearchPhp, true],
+ ['python', Languages.ElasticsearchPython, true],
+ ['ruby', Languages.ElasticsearchRuby, true],
+ ['rust', Languages.ElasticsearchRust, false],
+ ])('%s', (language, Component, hasCloudIdProp) => {
+ setup(language);
+ expect(wrapper.find(Component)).toHaveLength(1);
+ expect(wrapper.find(Component).prop('cloudId')).toEqual(
+ hasCloudIdProp ? 'example-cloud-id' : undefined
+ );
+ });
+ });
+
+ it('does not display language for unrecognised language', () => {
+ setup('coffeescript');
+ expect(wrapper.isEmptyRender()).toEqual(true);
+ });
+});
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_client_instructions.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_client_instructions.tsx
index de387b01e994d..92c28e8f23336 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_client_instructions.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_client_instructions.tsx
@@ -11,14 +11,16 @@ import { useValues } from 'kea';
import { KibanaLogic } from '../../../shared/kibana';
-import { ElasticsearchDotnet } from './elasticsearch_dotnet';
-import { ElasticsearchGo } from './elasticsearch_go';
-import { ElasticsearchJava } from './elasticsearch_java';
-import { ElasticsearchJavascript } from './elasticsearch_javascript';
-import { ElasticsearchPhp } from './elasticsearch_php';
-import { ElasticsearchPython } from './elasticsearch_python';
-import { ElasticsearchRuby } from './elasticsearch_ruby';
-import { ElasticsearchRust } from './elasticsearch_rust';
+import {
+ ElasticsearchDotnet,
+ ElasticsearchGo,
+ ElasticsearchJava,
+ ElasticsearchJavascript,
+ ElasticsearchPhp,
+ ElasticsearchPython,
+ ElasticsearchRuby,
+ ElasticsearchRust,
+} from './languages';
const useCloudId = (): string | undefined => {
const { cloud } = useValues(KibanaLogic);
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_dotnet.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_dotnet.tsx
similarity index 98%
rename from x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_dotnet.tsx
rename to x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_dotnet.tsx
index 66f59673d925f..ee739a459c774 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_dotnet.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_dotnet.tsx
@@ -11,7 +11,7 @@ import dedent from 'dedent';
import { EuiCodeBlock, EuiLink, EuiText, EuiSpacer } from '@elastic/eui';
-import { docLinks } from '../../../shared/doc_links';
+import { docLinks } from '../../../../shared/doc_links';
export const ElasticsearchDotnet: React.FC<{ cloudId?: string }> = ({ cloudId }) => {
return (
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_go.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_go.tsx
similarity index 98%
rename from x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_go.tsx
rename to x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_go.tsx
index 54d6dd7a0f333..cca6fe484fb3c 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_go.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_go.tsx
@@ -11,7 +11,7 @@ import dedent from 'dedent';
import { EuiCodeBlock, EuiLink, EuiText, EuiSpacer } from '@elastic/eui';
-import { docLinks } from '../../../shared/doc_links';
+import { docLinks } from '../../../../shared/doc_links';
export const ElasticsearchGo: React.FC<{ cloudId?: string }> = ({ cloudId }) => {
return (
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_java.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_java.tsx
similarity index 98%
rename from x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_java.tsx
rename to x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_java.tsx
index d10deac35c96b..573d447c25e03 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_java.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_java.tsx
@@ -11,7 +11,7 @@ import dedent from 'dedent';
import { EuiCodeBlock, EuiLink, EuiText, EuiSpacer } from '@elastic/eui';
-import { docLinks } from '../../../shared/doc_links';
+import { docLinks } from '../../../../shared/doc_links';
export const ElasticsearchJava: React.FC = () => {
return (
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_javascript.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_javascript.tsx
similarity index 98%
rename from x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_javascript.tsx
rename to x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_javascript.tsx
index 5f94eed342883..587ecb09e1198 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_javascript.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_javascript.tsx
@@ -11,7 +11,7 @@ import dedent from 'dedent';
import { EuiCodeBlock, EuiLink, EuiText, EuiSpacer } from '@elastic/eui';
-import { docLinks } from '../../../shared/doc_links';
+import { docLinks } from '../../../../shared/doc_links';
export const ElasticsearchJavascript: React.FC<{ cloudId?: string }> = ({ cloudId }) => {
return (
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_php.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_php.tsx
similarity index 98%
rename from x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_php.tsx
rename to x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_php.tsx
index 6a724e508c39e..229d36d487469 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_php.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_php.tsx
@@ -11,7 +11,7 @@ import dedent from 'dedent';
import { EuiCodeBlock, EuiLink, EuiText, EuiSpacer } from '@elastic/eui';
-import { docLinks } from '../../../shared/doc_links';
+import { docLinks } from '../../../../shared/doc_links';
export const ElasticsearchPhp: React.FC<{ cloudId?: string }> = ({ cloudId }) => {
return (
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_python.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_python.tsx
similarity index 99%
rename from x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_python.tsx
rename to x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_python.tsx
index 7a2183051feb2..54c7aca9b610a 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_python.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_python.tsx
@@ -11,7 +11,7 @@ import dedent from 'dedent';
import { EuiCodeBlock, EuiLink, EuiText, EuiSpacer } from '@elastic/eui';
-import { docLinks } from '../../../shared/doc_links';
+import { docLinks } from '../../../../shared/doc_links';
export const ElasticsearchPython: React.FC<{ cloudId?: string }> = ({ cloudId }) => {
return (
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_ruby.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_ruby.tsx
similarity index 98%
rename from x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_ruby.tsx
rename to x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_ruby.tsx
index 4dc80eb026871..0592037311900 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_ruby.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_ruby.tsx
@@ -11,7 +11,7 @@ import dedent from 'dedent';
import { EuiCodeBlock, EuiLink, EuiText, EuiSpacer } from '@elastic/eui';
-import { docLinks } from '../../../shared/doc_links';
+import { docLinks } from '../../../../shared/doc_links';
export const ElasticsearchRuby: React.FC<{ cloudId?: string }> = ({ cloudId }) => {
return (
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_rust.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_rust.tsx
similarity index 97%
rename from x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_rust.tsx
rename to x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_rust.tsx
index 5b1eecfe7a846..208fffca35a52 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/elasticsearch_rust.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/elasticsearch_rust.tsx
@@ -11,7 +11,7 @@ import dedent from 'dedent';
import { EuiCodeBlock, EuiLink, EuiText, EuiSpacer } from '@elastic/eui';
-import { docLinks } from '../../../shared/doc_links';
+import { docLinks } from '../../../../shared/doc_links';
export const ElasticsearchRust: React.FC = () => {
return (
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/index.ts b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/index.ts
new file mode 100644
index 0000000000000..8a2accf80142f
--- /dev/null
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_client_instructions/languages/index.ts
@@ -0,0 +1,26 @@
+/*
+ * 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; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+import { ElasticsearchDotnet } from './elasticsearch_dotnet';
+import { ElasticsearchGo } from './elasticsearch_go';
+import { ElasticsearchJava } from './elasticsearch_java';
+import { ElasticsearchJavascript } from './elasticsearch_javascript';
+import { ElasticsearchPhp } from './elasticsearch_php';
+import { ElasticsearchPython } from './elasticsearch_python';
+import { ElasticsearchRuby } from './elasticsearch_ruby';
+import { ElasticsearchRust } from './elasticsearch_rust';
+
+export {
+ ElasticsearchDotnet,
+ ElasticsearchGo,
+ ElasticsearchJava,
+ ElasticsearchJavascript,
+ ElasticsearchPhp,
+ ElasticsearchPython,
+ ElasticsearchRuby,
+ ElasticsearchRust,
+};
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_guide/elasticsearch_guide.test.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_guide/elasticsearch_guide.test.tsx
new file mode 100644
index 0000000000000..7dce063701072
--- /dev/null
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_guide/elasticsearch_guide.test.tsx
@@ -0,0 +1,73 @@
+/*
+ * 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; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+import React from 'react';
+
+import { shallow, ShallowWrapper } from 'enzyme';
+
+import { EuiSteps, EuiSelect } from '@elastic/eui';
+
+import { ElasticsearchClientInstructions } from '../elasticsearch_client_instructions';
+
+import { ElasticsearchGuide } from './';
+
+describe('Elasticsearch Guide Component', () => {
+ let wrapper: ShallowWrapper;
+
+ const setup = (param: string) => {
+ Object.defineProperty(window, 'location', {
+ value: { search: param },
+ writable: true,
+ });
+ wrapper = shallow();
+ };
+
+ describe('Rendering Language option ', () => {
+ it('should use default language (java)', () => {
+ setup('');
+ const clientInstructionsElement = wrapper
+ .find(EuiSteps)
+ .dive()
+ .find(ElasticsearchClientInstructions);
+ expect(clientInstructionsElement.prop('language')).toBe('java');
+ });
+
+ it('should use language from param (ruby)', () => {
+ setup('?client=ruby');
+ const clientInstructionsElement = wrapper
+ .find(EuiSteps)
+ .dive()
+ .find(ElasticsearchClientInstructions);
+ expect(clientInstructionsElement.prop('language')).toBe('ruby');
+ });
+
+ it('should fallback to java if client not recognised', () => {
+ setup('?client=coffeescript');
+ const clientInstructionsElement = wrapper
+ .find(EuiSteps)
+ .dive()
+ .find(ElasticsearchClientInstructions);
+ expect(clientInstructionsElement.prop('language')).toBe('java');
+ });
+ });
+
+ describe('Changing Language option', () => {
+ it('should change the client instructions language prop when choosing another option', () => {
+ setup('');
+ const languageSelectElement = wrapper.find(EuiSteps).dive().find(EuiSelect);
+ languageSelectElement.simulate('change', { target: { value: 'ruby' } });
+
+ wrapper.update();
+
+ const clientInstructionsElement = wrapper
+ .find(EuiSteps)
+ .dive()
+ .find(ElasticsearchClientInstructions);
+ expect(clientInstructionsElement.prop('language')).toBe('ruby');
+ });
+ });
+});
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_guide/elasticsearch_guide.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_guide/elasticsearch_guide.tsx
index 8a5fb8037bb8d..fb1bc7a2820e2 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_guide/elasticsearch_guide.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/elasticsearch_guide/elasticsearch_guide.tsx
@@ -43,11 +43,9 @@ export const ElasticsearchGuide: React.FC = () => {
{ value: 'rust', text: 'Rust' },
];
- const client = queryString.parse(window.location.search).client;
+ const client = queryString.parse(window.location.search).client as string;
const languageExists = languages.some((language) => language.value === client);
- const [selectedLanguage, setSelectedLanguage] = useState(
- languageExists ? (client as string) : 'java'
- );
+ const [selectedLanguage, setSelectedLanguage] = useState(languageExists ? client : 'java');
const basicSelectId = useGeneratedHtmlId({ prefix: 'languageSelect' });
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/product_selector/product_selector.test.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/product_selector/product_selector.test.tsx
index ff2ea86bb3911..0af49e71880ab 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/product_selector/product_selector.test.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/product_selector/product_selector.test.tsx
@@ -15,6 +15,7 @@ import { EuiEmptyPrompt } from '@elastic/eui';
import { WORKPLACE_SEARCH_PLUGIN } from '../../../../../common/constants';
+import { ElasticsearchCard } from '../elasticsearch_card';
import { LicenseCallout } from '../license_callout';
import { ProductCard } from '../product_card';
import { SetupGuideCta } from '../setup_guide';
@@ -35,6 +36,7 @@ describe('ProductSelector', () => {
expect(wrapper.find(ProductCard)).toHaveLength(2);
expect(wrapper.find(SetupGuideCta)).toHaveLength(1);
expect(wrapper.find(LicenseCallout)).toHaveLength(0);
+ expect(wrapper.find(ElasticsearchCard)).toHaveLength(1);
});
it('renders the trial callout', () => {
@@ -97,6 +99,7 @@ describe('ProductSelector', () => {
expect(wrapper.find(EuiEmptyPrompt)).toHaveLength(1);
expect(wrapper.find(ProductCard)).toHaveLength(0);
expect(wrapper.find(LicenseCallout)).toHaveLength(0);
+ expect(wrapper.find(ElasticsearchCard)).toHaveLength(0);
});
});
});