From c5028f804a7ee349b4191650364b66317f53f363 Mon Sep 17 00:00:00 2001 From: Sean Li Date: Tue, 22 Nov 2022 16:06:01 -0800 Subject: [PATCH] Updating tests Signed-off-by: Sean Li --- .../__snapshots__/searchbar.test.tsx.snap | 484 ++++++++--------- .../__snapshots__/sidebar.test.tsx.snap | 499 +++++++++--------- .../sidebar/__tests__/searchbar.test.tsx | 20 +- .../sidebar/__tests__/sidebar.test.tsx | 3 +- .../__snapshots__/top_menu.test.tsx.snap | 111 ++-- 5 files changed, 544 insertions(+), 573 deletions(-) diff --git a/dashboards-observability/public/components/metrics/sidebar/__tests__/__snapshots__/searchbar.test.tsx.snap b/dashboards-observability/public/components/metrics/sidebar/__tests__/__snapshots__/searchbar.test.tsx.snap index 0dd14e663..1a271b63c 100644 --- a/dashboards-observability/public/components/metrics/sidebar/__tests__/__snapshots__/searchbar.test.tsx.snap +++ b/dashboards-observability/public/components/metrics/sidebar/__tests__/__snapshots__/searchbar.test.tsx.snap @@ -1,323 +1,295 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Search Bar Component Search Side Bar Component with available metrics 1`] = ` - -
- - +
+ -
- -
- - - -
- - - - -
- + + +
- - - - -
-
+ + + + + + +
+
+
+
-
- - - -
- -
-
-
- -
- -
- + + + +
+ + + + + +
+ `; exports[`Search Bar Component Search Side Bar Component with no available metrics 1`] = ` - -
- - +
+ -
- -
- - - -
- - - - -
- + + +
- - - - -
-
+ > + + + + +
+
+
+
-
- - - -
- -
-
-
- -
- -
- + + + +
+ + + + + +
+ `; diff --git a/dashboards-observability/public/components/metrics/sidebar/__tests__/__snapshots__/sidebar.test.tsx.snap b/dashboards-observability/public/components/metrics/sidebar/__tests__/__snapshots__/sidebar.test.tsx.snap index b7f4adfcd..b4ba2e2b7 100644 --- a/dashboards-observability/public/components/metrics/sidebar/__tests__/__snapshots__/sidebar.test.tsx.snap +++ b/dashboards-observability/public/components/metrics/sidebar/__tests__/__snapshots__/sidebar.test.tsx.snap @@ -20,6 +20,7 @@ exports[`Side Bar Component renders Side Bar Component 1`] = ` "http": [MockFunction], } } + search={false} > - - - Recently Created Metrics - - - } - id="recentlyCreatedMetricsSelector" - initialIsOpen={true} - isLoading={false} - isLoadingMessage={false} - paddingSize="none" + -
+ + Recently Created Metrics + + + } + id="Recently Created MetricsSelector" + initialIsOpen={true} + isLoading={false} + isLoadingMessage={false} + paddingSize="none" >
- -
-
- + Recently Created Metrics + + + + +
+
-
-
-
    + +
    +
    +
      +
    -
- + +
-
-
+ + @@ -215,104 +222,110 @@ exports[`Side Bar Component renders Side Bar Component 1`] = ` className="euiSpacer euiSpacer--s" /> - - - Selected Metrics - - - } - id="selectedMetricsSelector" - initialIsOpen={true} - isLoading={false} - isLoadingMessage={false} - paddingSize="none" + -
+ + Selected Metrics + + + } + id="Selected MetricsSelector" + initialIsOpen={true} + isLoading={false} + isLoadingMessage={false} + paddingSize="none" >
- -
-
- + Selected Metrics + + + + +
+
-
-
-
    + +
    +
    +
      +
    -
- + +
-
-
+ + @@ -320,104 +333,110 @@ exports[`Side Bar Component renders Side Bar Component 1`] = ` className="euiSpacer euiSpacer--s" /> - - - Available Metrics - - - } - id="availableMetricsSelector" - initialIsOpen={true} - isLoading={false} - isLoadingMessage={false} - paddingSize="none" + -
+ + Available Metrics + + + } + id="Available MetricsSelector" + initialIsOpen={true} + isLoading={false} + isLoadingMessage={false} + paddingSize="none" >
- -
-
- + Available Metrics + + + + +
+
-
-
-
    + +
    +
    +
      +
    -
- + +
-
-
+ +
diff --git a/dashboards-observability/public/components/metrics/sidebar/__tests__/searchbar.test.tsx b/dashboards-observability/public/components/metrics/sidebar/__tests__/searchbar.test.tsx index de824be1a..cc84dc0eb 100644 --- a/dashboards-observability/public/components/metrics/sidebar/__tests__/searchbar.test.tsx +++ b/dashboards-observability/public/components/metrics/sidebar/__tests__/searchbar.test.tsx @@ -8,17 +8,22 @@ import Adapter from 'enzyme-adapter-react-16'; import React from 'react'; import { waitFor } from '@testing-library/react'; import { SearchBar } from '../search_bar'; -import { sampleAllAvailableMetrics } from '../../../../../test/metrics_contants'; +import { Provider } from 'react-redux'; +import { applyMiddleware, createStore } from 'redux'; +import thunk from 'redux-thunk'; +import rootReducer from '../../../../framework/redux/reducers'; describe('Search Bar Component', () => { configure({ adapter: new Adapter() }); + const store = createStore(rootReducer, applyMiddleware(thunk)); it('Search Side Bar Component with no available metrics', async () => { - const allAvailableMetrics: any = []; - const handleAddMetric = jest.fn(); + const setSearch = jest.fn(); const wrapper = mount( - + + + ); wrapper.update(); @@ -29,11 +34,12 @@ describe('Search Bar Component', () => { }); it('Search Side Bar Component with available metrics', async () => { - const allAvailableMetrics = sampleAllAvailableMetrics; - const handleAddMetric = jest.fn(); + const setSearch = jest.fn(); const wrapper = mount( - + + + ); wrapper.update(); diff --git a/dashboards-observability/public/components/metrics/sidebar/__tests__/sidebar.test.tsx b/dashboards-observability/public/components/metrics/sidebar/__tests__/sidebar.test.tsx index 1cf39ca1b..747201fa7 100644 --- a/dashboards-observability/public/components/metrics/sidebar/__tests__/sidebar.test.tsx +++ b/dashboards-observability/public/components/metrics/sidebar/__tests__/sidebar.test.tsx @@ -24,10 +24,11 @@ describe('Side Bar Component', () => { const http = httpClientMock; const pplService = new PPLService(httpClientMock); + const search = false; const wrapper = mount( - + ); diff --git a/dashboards-observability/public/components/metrics/top_menu/__tests__/__snapshots__/top_menu.test.tsx.snap b/dashboards-observability/public/components/metrics/top_menu/__tests__/__snapshots__/top_menu.test.tsx.snap index 274f4b2f0..edf4f4490 100644 --- a/dashboards-observability/public/components/metrics/top_menu/__tests__/__snapshots__/top_menu.test.tsx.snap +++ b/dashboards-observability/public/components/metrics/top_menu/__tests__/__snapshots__/top_menu.test.tsx.snap @@ -84,12 +84,15 @@ exports[`Metrics Top Menu Component renders Top Menu Component when disabled in
- +
@@ -109,24 +112,24 @@ exports[`Metrics Top Menu Component renders Top Menu Component when disabled in className="euiFlexItem euiSearchBar__searchHolder" > @@ -211,18 +214,6 @@ exports[`Metrics Top Menu Component renders Top Menu Component when disabled in
- -
-
@@ -1405,12 +1396,15 @@ exports[`Metrics Top Menu Component renders Top Menu Component when disabled wit
- +
@@ -1430,24 +1424,24 @@ exports[`Metrics Top Menu Component renders Top Menu Component when disabled wit className="euiFlexItem euiSearchBar__searchHolder" > @@ -1532,18 +1526,6 @@ exports[`Metrics Top Menu Component renders Top Menu Component when disabled wit
- -
-
@@ -2676,12 +2658,15 @@ exports[`Metrics Top Menu Component renders Top Menu Component when enabled 1`]
- +
@@ -2701,24 +2686,24 @@ exports[`Metrics Top Menu Component renders Top Menu Component when enabled 1`] className="euiFlexItem euiSearchBar__searchHolder" > @@ -2799,18 +2784,6 @@ exports[`Metrics Top Menu Component renders Top Menu Component when enabled 1`]
- -
-