diff --git a/x-pack/plugins/remote_clusters/public/sections/components/remote_cluster_form/__snapshots__/remote_cluster_form.test.js.snap b/x-pack/plugins/remote_clusters/public/sections/components/remote_cluster_form/__snapshots__/remote_cluster_form.test.js.snap new file mode 100644 index 0000000000000..8f600cbdcae40 --- /dev/null +++ b/x-pack/plugins/remote_clusters/public/sections/components/remote_cluster_form/__snapshots__/remote_cluster_form.test.js.snap @@ -0,0 +1,343 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`RemoteClusterForm renders untouched state 1`] = ` +Array [ +
+
+
+
+

+ Name +

+
+
+ A unique name for the remote cluster. +
+
+
+
+
+ +
+
+ +
+
+
+ Name can only contain letters, numbers, underscores, and dashes. +
+
+
+
+
+
+
+
+

+ Seed nodes for cluster discovery +

+
+
+

+ A list of remote cluster nodes to query for the cluster state. Specify multiple seed nodes so discovery doesn't fail if a node is unavailable. +

+
+
+
+
+
+ + +
+
+
+
+
+
+

+ Make remote cluster optional +

+
+
+

+ By default, a request fails if any of the queried remote clusters are unavailable. To continue sending a request to other remote clusters if this cluster is unavailable, enable + + Skip if unavailable + + . + + Learn more. + +

+
+
+
+
+
+
+ + + + + + + + + + + + + + + + +
+
+
+
+
+
, +
, +
+
+ +
+
+ +
+
, +] +`; diff --git a/x-pack/plugins/remote_clusters/public/sections/components/remote_cluster_form/remote_cluster_form.test.js b/x-pack/plugins/remote_clusters/public/sections/components/remote_cluster_form/remote_cluster_form.test.js new file mode 100644 index 0000000000000..85e79d3c7a225 --- /dev/null +++ b/x-pack/plugins/remote_clusters/public/sections/components/remote_cluster_form/remote_cluster_form.test.js @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { renderWithIntl } from 'test_utils/enzyme_helpers'; + +import { RemoteClusterForm } from './remote_cluster_form'; + +/** + * Make sure we have deterministic aria ID + */ +jest.mock('@elastic/eui/lib/components/form/form_row/make_id', () => () => 'my-id'); + +describe('RemoteClusterForm', () => { + test(`renders untouched state`, () => { + const component = renderWithIntl( + {}} + cancel={() => {}} + isSaving={false} + saveError={undefined} + /> + ); + expect(component).toMatchSnapshot(); + }); +}); diff --git a/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/__snapshots__/remote_cluster_list.test.js.snap b/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/__snapshots__/remote_cluster_list.test.js.snap new file mode 100644 index 0000000000000..65cd36de6ff75 --- /dev/null +++ b/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/__snapshots__/remote_cluster_list.test.js.snap @@ -0,0 +1,98 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`RemoteClusterList renders empty state when loading is complete and there are no clusters 1`] = ` +
+
+
+
+ + + + +
+ +

+ Add your first remote cluster +

+
+
+

+ Remote clusters create a uni-directional connection from your local cluster to other clusters. +

+
+ + +
+
+`; diff --git a/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/remote_cluster_list.js b/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/remote_cluster_list.js index e6e2c2e0a295f..eb22caf7fec49 100644 --- a/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/remote_cluster_list.js +++ b/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/remote_cluster_list.js @@ -57,7 +57,7 @@ export const RemoteClusterList = injectI18n( isRemovingCluster: PropTypes.bool, } - static getDerivedStateFromProps(props) { + componentDidUpdate() { const { openDetailPanel, closeDetailPanel, @@ -67,7 +67,7 @@ export const RemoteClusterList = injectI18n( search, }, }, - } = props; + } = this.props; const { cluster: clusterName } = extractQueryParams(search); @@ -77,12 +77,8 @@ export const RemoteClusterList = injectI18n( } else if (isDetailPanelOpen) { closeDetailPanel(); } - - return null; } - state = {}; - componentDidMount() { this.props.loadClusters(); this.interval = setInterval(this.props.refreshClusters, REFRESH_RATE_MS); diff --git a/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/remote_cluster_list.test.js b/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/remote_cluster_list.test.js new file mode 100644 index 0000000000000..2ab49c27f541f --- /dev/null +++ b/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/remote_cluster_list.test.js @@ -0,0 +1,37 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { renderWithIntl } from 'test_utils/enzyme_helpers'; + +import { RemoteClusterList } from './remote_cluster_list'; + +jest.mock('../../services', () => { + const services = require.requireActual('../../services'); + return { + ...services, + getRouterLinkProps: (link) => ({ href: link }), + }; +}); + +describe('RemoteClusterList', () => { + test(`renders empty state when loading is complete and there are no clusters`, () => { + const component = renderWithIntl( + {}} + refreshClusters={() => {}} + openDetailPanel={() => {}} + closeDetailPanel={() => {}} + isDetailPanelOpen={false} + clusters={[]} + isLoading={false} + isCopyingCluster={false} + isRemovingCluster={false} + /> + ); + expect(component).toMatchSnapshot(); + }); +}); diff --git a/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/remote_cluster_table/__snapshots__/remote_cluster_table.test.js.snap b/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/remote_cluster_table/__snapshots__/remote_cluster_table.test.js.snap new file mode 100644 index 0000000000000..0713393e46b1d --- /dev/null +++ b/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/remote_cluster_table/__snapshots__/remote_cluster_table.test.js.snap @@ -0,0 +1,418 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`RemoteClusterTable renders a row for a default remote cluster 1`] = ` + + +
+
+ +
+
+
+ + +
+ +
+ + +
+ seed, seed2 +
+ + +
+
+
+ + + + + + +
+
+
+ Not connected +
+
+
+
+ + +
+ +
+ + +
+
+ + + +
+ +
+ + +`; + +exports[`RemoteClusterTable renders a row for a remote cluster defined in elasticsearch.yml 1`] = ` + + +
+
+ +
+
+
+ + +
+
+
+ +
+
+ + + + + +
+
+
+ + +
+ seed, seed2 +
+ + +
+
+
+ + + + + + +
+
+
+ Not connected +
+
+
+
+ + +
+ +
+ + +
+
+ + + +
+
+ + + +
+
+ + +`; diff --git a/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/remote_cluster_table/remote_cluster_table.test.js b/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/remote_cluster_table/remote_cluster_table.test.js new file mode 100644 index 0000000000000..3931f8f7cd47e --- /dev/null +++ b/x-pack/plugins/remote_clusters/public/sections/remote_cluster_list/remote_cluster_table/remote_cluster_table.test.js @@ -0,0 +1,56 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { Provider } from 'react-redux'; +import { renderWithIntl } from 'test_utils/enzyme_helpers'; + +import { remoteClustersStore } from '../../../store'; +import { RemoteClusterTable } from './remote_cluster_table'; + +/** + * Make sure we have deterministic aria ID + */ +jest.mock('@elastic/eui/lib/components/form/form_row/make_id', () => () => 'my-id'); + +describe('RemoteClusterTable', () => { + test(`renders a row for a default remote cluster`, () => { + const clusters = [{ + name: 'Default remote cluster', + seeds: ['seed', 'seed2'], + }]; + + const component = renderWithIntl( + + {}} + /> + + ); + + expect(component.find('tbody > tr').first()).toMatchSnapshot(); + }); + + test(`renders a row for a remote cluster defined in elasticsearch.yml`, () => { + const clusters = [{ + name: 'Remote cluster in elasticsearch.yml', + seeds: ['seed', 'seed2'], + isConfiguredByNode: true, + }]; + + const component = renderWithIntl( + + {}} + /> + + ); + + expect(component.find('tbody > tr').first()).toMatchSnapshot(); + }); +});