diff --git a/public/components/query_compare/__test__/__snapshots__/create_index.test.tsx.snap b/public/components/query_compare/__test__/__snapshots__/create_index.test.tsx.snap
index aa3312c..31fe605 100644
--- a/public/components/query_compare/__test__/__snapshots__/create_index.test.tsx.snap
+++ b/public/components/query_compare/__test__/__snapshots__/create_index.test.tsx.snap
@@ -1,7 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Create index component Renders create index component 1`] = `
-
+
Learn how to index your data
- , or
+ , or
+
- add sample data
+ add sample data
+
to OpenSearch Dashboards.
}
@@ -209,7 +234,8 @@ exports[`Create index component Renders create index component 1`] = `
- , or
+ , or
+
@@ -218,9 +244,10 @@ exports[`Create index component Renders create index component 1`] = `
href="/app/home#/tutorial_directory"
rel="noreferrer"
>
- add sample data
+ add sample data
+
to OpenSearch Dashboards.
diff --git a/public/components/query_compare/__test__/create_index.test.tsx b/public/components/query_compare/__test__/create_index.test.tsx
index 02d5d5d..e1ed0db 100644
--- a/public/components/query_compare/__test__/create_index.test.tsx
+++ b/public/components/query_compare/__test__/create_index.test.tsx
@@ -6,14 +6,31 @@
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import React from 'react';
-import { waitFor } from '@testing-library/react';
+import { fireEvent, render, waitFor } from '@testing-library/react';
import { CreateIndex } from '../create_index';
+const coreMockStart = {
+ chrome: {
+ navGroup: {
+ getNavGroupEnabled: jest.fn(() => false),
+ },
+ },
+ application: {
+ navigateToApp: jest.fn(),
+ },
+};
+
describe('Create index component', () => {
configure({ adapter: new Adapter() });
+ beforeEach(() => {
+ jest.clearAllMocks();
+ });
+
it('Renders create index component', async () => {
- const wrapper = mount();
+ const wrapper = mount(
+
+ );
wrapper.update();
@@ -21,4 +38,14 @@ describe('Create index component', () => {
expect(wrapper).toMatchSnapshot();
});
});
+
+ it('should call application.navigateToApp', async () => {
+ coreMockStart.chrome.navGroup.getNavGroupEnabled.mockReturnValue(true);
+ const { getByText } = render(
+
+ );
+
+ fireEvent.click(getByText('add sample data'));
+ expect(coreMockStart.application.navigateToApp).toHaveBeenLastCalledWith('import_sample_data');
+ });
});
diff --git a/public/components/query_compare/create_index.tsx b/public/components/query_compare/create_index.tsx
index afc5470..610fcc4 100644
--- a/public/components/query_compare/create_index.tsx
+++ b/public/components/query_compare/create_index.tsx
@@ -7,8 +7,15 @@ import React from 'react';
import { EuiPageBody, EuiEmptyPrompt, EuiLink } from '@elastic/eui';
import { Header } from '../common/header';
+import { CoreStart } from '../../../../../src/core/public';
-export const CreateIndex = () => {
+interface CreateIndexProps {
+ chrome: CoreStart['chrome'];
+ application: CoreStart['application'];
+}
+
+export const CreateIndex = ({ chrome, application }: CreateIndexProps) => {
+ const navGroupEnabled = chrome.navGroup.getNavGroupEnabled();
return (
<>
@@ -24,8 +31,19 @@ export const CreateIndex = () => {
>
Learn how to index your data
- , or add sample data to
- OpenSearch Dashboards.
+ , or{' '}
+ {
+ application.navigateToApp('import_sample_data');
+ },
+ }
+ : { href: '/app/home#/tutorial_directory' })}
+ >
+ add sample data
+ {' '}
+ to OpenSearch Dashboards.
}
/>
diff --git a/public/components/query_compare/home.tsx b/public/components/query_compare/home.tsx
index 9d04aaa..7c1e482 100644
--- a/public/components/query_compare/home.tsx
+++ b/public/components/query_compare/home.tsx
@@ -32,7 +32,6 @@ import {
} from '../../../../../src/plugins/data_source_management/public/components/data_source_menu/types';
import * as pluginManifest from '../../../opensearch_dashboards.json';
import './home.scss';
-import { uiSettingsService } from '../common/utils';
interface QueryExplorerProps {
parentBreadCrumbs: ChromeBreadcrumb[];
@@ -155,7 +154,7 @@ export const Home = ({
<>
{shouldShowCreateIndex ? (
-
+
) : (