From 4e5dffc11280ec142c0bb5c4e52b4a18e91977e6 Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Tue, 18 Apr 2023 11:57:51 -0700 Subject: [PATCH 1/4] update links in notebooks cypress Signed-off-by: Shenoy Pratik --- .cypress/integration/2_notebooks.spec.js | 127 ++++++++++++----------- 1 file changed, 68 insertions(+), 59 deletions(-) diff --git a/.cypress/integration/2_notebooks.spec.js b/.cypress/integration/2_notebooks.spec.js index 3ba071215e..409b4a0a2b 100644 --- a/.cypress/integration/2_notebooks.spec.js +++ b/.cypress/integration/2_notebooks.spec.js @@ -21,17 +21,26 @@ import { SAMPLE_PANEL } from '../utils/panel_constants'; import { skipOn } from '@cypress/skip-test'; const moveToEventsHome = () => { - cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/event_analytics/`); + cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-logs#/`); cy.wait(delay * 3); }; const moveToPanelHome = () => { - cy.visit( - `${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/operational_panels/` - ); + cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/`); cy.wait(delay * 3); }; +const moveToTestNotebook = () => { + cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-notebooks#/`, { + timeout: 6000, + }); + cy.get('.euiTableCellContent') + .contains(TEST_NOTEBOOK, { + timeout: 6000, + }) + .click(); +}; + describe('Adding sample data and visualization', () => { it('Adds sample flights data for visualization paragraph', () => { cy.visit(`${Cypress.env('opensearchDashboards')}/app/home#/tutorial_directory/sampleData`); @@ -41,20 +50,21 @@ describe('Adding sample data and visualization', () => { }); it('Add sample observability data', () => { - moveToPanelHome(); - cy.get('.euiButton__text').contains('Actions').trigger('mouseover').click(); + moveToEventsHome(); + cy.get('button[data-test-subj="eventHomeAction"]').trigger('mouseover').click(); cy.wait(100); - cy.get('.euiContextMenuItem__text').contains('Add samples').trigger('mouseover').click(); + cy.get('button[data-test-subj="eventHomeAction__addSamples"]').trigger('mouseover').click(); cy.wait(100 * 3); cy.get('.euiModalHeader__title[data-test-subj="confirmModalTitleText"]') .contains('Add samples') .should('exist'); cy.wait(100); - cy.get('.euiButton__text').contains('Yes').trigger('mouseover').click(); + cy.get('button[data-test-subj="confirmModalConfirmButton"]').trigger('mouseover').click(); cy.wait(100 * 5); cy.route2('POST', '/addSamplePanels').as('addSamples'); cy.wait('@addSamples').then(() => { - cy.get('.euiTableCellContent').contains(SAMPLE_PANEL).should('exist'); + // cy.get('.euiTableCellContent').contains(SAMPLE_PANEL).should('exist'); + cy.get('.euiToastHeader__title').should('contain', 'successfully'); }); cy.wait(100); }); @@ -62,7 +72,8 @@ describe('Adding sample data and visualization', () => { describe('Testing notebooks table', () => { beforeEach(() => { - cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/notebooks`); + cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-notebooks#/`); + cy.wait(delay); }); it('Notebooks table empty state', () => { @@ -176,57 +187,53 @@ describe('Testing notebooks table', () => { }); }); -describe('Test reporting integration if plugin installed', () => { - beforeEach(() => { - cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/notebooks`); - cy.get('.euiTableCellContent').contains(TEST_NOTEBOOK).click(); - cy.wait(delay * 3); - cy.get('body').then(($body) => { - skipOn($body.find('#reportingActionsButton').length <= 0); - }); - }); - - it('Create in-context PDF report from notebook', () => { - cy.get('#reportingActionsButton').click(); - cy.wait(delay); - cy.get('button.euiContextMenuItem:nth-child(1)').contains('Download PDF').click(); - cy.get('#downloadInProgressLoadingModal').should('exist'); - }); - - it('Create in-context PNG report from notebook', () => { - cy.get('#reportingActionsButton').click(); - cy.wait(delay); - cy.get('button.euiContextMenuItem:nth-child(2)').contains('Download PNG').click(); - cy.get('#downloadInProgressLoadingModal').should('exist'); - }); - - it('Create on-demand report definition from context menu', () => { - cy.get('#reportingActionsButton').click(); - cy.wait(delay); - cy.get('button.euiContextMenuItem:nth-child(3)').contains('Create report definition').click(); - cy.wait(delay); - cy.location('pathname', { timeout: 60000 }).should('include', '/reports-dashboards'); - cy.wait(delay); - cy.get('#reportSettingsName').type('Create notebook on-demand report'); - cy.get('#createNewReportDefinition').click({ force: true }); - }); - - it('View reports homepage from context menu', () => { - cy.get('#reportingActionsButton').click(); - cy.wait(delay); - cy.get('button.euiContextMenuItem:nth-child(4)').contains('View reports').click(); - cy.wait(delay); - cy.location('pathname', { timeout: 60000 }).should('include', '/reports-dashboards'); - }); -}); +// describe('Test reporting integration if plugin installed', () => { +// beforeEach(() => { +// cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/notebooks`); +// cy.get('.euiTableCellContent').contains(TEST_NOTEBOOK).click(); +// cy.wait(delay * 3); +// cy.get('body').then(($body) => { +// skipOn($body.find('#reportingActionsButton').length <= 0); +// }); +// }); + +// it('Create in-context PDF report from notebook', () => { +// cy.get('#reportingActionsButton').click(); +// cy.wait(delay); +// cy.get('button.euiContextMenuItem:nth-child(1)').contains('Download PDF').click(); +// cy.get('#downloadInProgressLoadingModal').should('exist'); +// }); + +// it('Create in-context PNG report from notebook', () => { +// cy.get('#reportingActionsButton').click(); +// cy.wait(delay); +// cy.get('button.euiContextMenuItem:nth-child(2)').contains('Download PNG').click(); +// cy.get('#downloadInProgressLoadingModal').should('exist'); +// }); + +// it('Create on-demand report definition from context menu', () => { +// cy.get('#reportingActionsButton').click(); +// cy.wait(delay); +// cy.get('button.euiContextMenuItem:nth-child(3)').contains('Create report definition').click(); +// cy.wait(delay); +// cy.location('pathname', { timeout: 60000 }).should('include', '/reports-dashboards'); +// cy.wait(delay); +// cy.get('#reportSettingsName').type('Create notebook on-demand report'); +// cy.get('#createNewReportDefinition').click({ force: true }); +// }); + +// it('View reports homepage from context menu', () => { +// cy.get('#reportingActionsButton').click(); +// cy.wait(delay); +// cy.get('button.euiContextMenuItem:nth-child(4)').contains('View reports').click(); +// cy.wait(delay); +// cy.location('pathname', { timeout: 60000 }).should('include', '/reports-dashboards'); +// }); +// }); describe('Testing paragraphs', () => { - beforeEach(() => { - cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/notebooks`); - cy.get('.euiTableCellContent').contains(TEST_NOTEBOOK).click(); - }); - it('Goes into a notebook and creates paragraphs', () => { + moveToTestNotebook(); cy.get('.euiButton__text').contains('Add').click(); cy.wait(delay); @@ -256,6 +263,7 @@ describe('Testing paragraphs', () => { }); it('Paragraph actions layout', () => { + moveToTestNotebook(); cy.get('button[data-test-subj="notebook-paragraph-actions-button"]').should('exist').click(); cy.get('.euiContextMenuPanelTitle').contains('Actions'); cy.get('.euiContextMenuItem__text').eq(0).contains('Add paragraph to top'); @@ -308,6 +316,7 @@ describe('Testing paragraphs', () => { }); it('Duplicates paragraphs', () => { + moveToTestNotebook(); cy.get('.euiButtonIcon[aria-label="Open paragraph menu"]').eq(0).click(); cy.wait(delay); cy.get('.euiContextMenuItem__text').contains('Duplicate').eq(0).click(); @@ -497,7 +506,7 @@ describe('Testing paragraphs', () => { cy.get('.euiButton__text').contains('Create notebook').should('exist'); }); - + it('Cleans up test notebooks', () => { cy.get('[data-test-subj="notebook-notebook-actions-button"]').click(); cy.wait(delay); From d70e3828ecb31e6740c2414d1d554ee0faea5d6f Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Tue, 18 Apr 2023 15:23:08 -0700 Subject: [PATCH 2/4] metrics analytics support SOpanels Signed-off-by: Shenoy Pratik --- .cypress/integration/2_notebooks.spec.js | 125 ++++++++---------- public/components/metrics/helpers/utils.tsx | 1 - .../metrics/top_menu/metrics_export_panel.tsx | 29 ++-- .../components/metrics/top_menu/top_menu.tsx | 12 +- 4 files changed, 86 insertions(+), 81 deletions(-) diff --git a/.cypress/integration/2_notebooks.spec.js b/.cypress/integration/2_notebooks.spec.js index 409b4a0a2b..5743cd07af 100644 --- a/.cypress/integration/2_notebooks.spec.js +++ b/.cypress/integration/2_notebooks.spec.js @@ -21,26 +21,17 @@ import { SAMPLE_PANEL } from '../utils/panel_constants'; import { skipOn } from '@cypress/skip-test'; const moveToEventsHome = () => { - cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-logs#/`); + cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/event_analytics/`); cy.wait(delay * 3); }; const moveToPanelHome = () => { - cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/`); + cy.visit( + `${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/operational_panels/` + ); cy.wait(delay * 3); }; -const moveToTestNotebook = () => { - cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-notebooks#/`, { - timeout: 6000, - }); - cy.get('.euiTableCellContent') - .contains(TEST_NOTEBOOK, { - timeout: 6000, - }) - .click(); -}; - describe('Adding sample data and visualization', () => { it('Adds sample flights data for visualization paragraph', () => { cy.visit(`${Cypress.env('opensearchDashboards')}/app/home#/tutorial_directory/sampleData`); @@ -50,21 +41,20 @@ describe('Adding sample data and visualization', () => { }); it('Add sample observability data', () => { - moveToEventsHome(); - cy.get('button[data-test-subj="eventHomeAction"]').trigger('mouseover').click(); + moveToPanelHome(); + cy.get('.euiButton__text').contains('Actions').trigger('mouseover').click(); cy.wait(100); - cy.get('button[data-test-subj="eventHomeAction__addSamples"]').trigger('mouseover').click(); + cy.get('.euiContextMenuItem__text').contains('Add samples').trigger('mouseover').click(); cy.wait(100 * 3); cy.get('.euiModalHeader__title[data-test-subj="confirmModalTitleText"]') .contains('Add samples') .should('exist'); cy.wait(100); - cy.get('button[data-test-subj="confirmModalConfirmButton"]').trigger('mouseover').click(); + cy.get('.euiButton__text').contains('Yes').trigger('mouseover').click(); cy.wait(100 * 5); cy.route2('POST', '/addSamplePanels').as('addSamples'); cy.wait('@addSamples').then(() => { - // cy.get('.euiTableCellContent').contains(SAMPLE_PANEL).should('exist'); - cy.get('.euiToastHeader__title').should('contain', 'successfully'); + cy.get('.euiTableCellContent').contains(SAMPLE_PANEL).should('exist'); }); cy.wait(100); }); @@ -72,8 +62,7 @@ describe('Adding sample data and visualization', () => { describe('Testing notebooks table', () => { beforeEach(() => { - cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-notebooks#/`); - cy.wait(delay); + cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/notebooks`); }); it('Notebooks table empty state', () => { @@ -187,53 +176,57 @@ describe('Testing notebooks table', () => { }); }); -// describe('Test reporting integration if plugin installed', () => { -// beforeEach(() => { -// cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/notebooks`); -// cy.get('.euiTableCellContent').contains(TEST_NOTEBOOK).click(); -// cy.wait(delay * 3); -// cy.get('body').then(($body) => { -// skipOn($body.find('#reportingActionsButton').length <= 0); -// }); -// }); - -// it('Create in-context PDF report from notebook', () => { -// cy.get('#reportingActionsButton').click(); -// cy.wait(delay); -// cy.get('button.euiContextMenuItem:nth-child(1)').contains('Download PDF').click(); -// cy.get('#downloadInProgressLoadingModal').should('exist'); -// }); - -// it('Create in-context PNG report from notebook', () => { -// cy.get('#reportingActionsButton').click(); -// cy.wait(delay); -// cy.get('button.euiContextMenuItem:nth-child(2)').contains('Download PNG').click(); -// cy.get('#downloadInProgressLoadingModal').should('exist'); -// }); - -// it('Create on-demand report definition from context menu', () => { -// cy.get('#reportingActionsButton').click(); -// cy.wait(delay); -// cy.get('button.euiContextMenuItem:nth-child(3)').contains('Create report definition').click(); -// cy.wait(delay); -// cy.location('pathname', { timeout: 60000 }).should('include', '/reports-dashboards'); -// cy.wait(delay); -// cy.get('#reportSettingsName').type('Create notebook on-demand report'); -// cy.get('#createNewReportDefinition').click({ force: true }); -// }); - -// it('View reports homepage from context menu', () => { -// cy.get('#reportingActionsButton').click(); -// cy.wait(delay); -// cy.get('button.euiContextMenuItem:nth-child(4)').contains('View reports').click(); -// cy.wait(delay); -// cy.location('pathname', { timeout: 60000 }).should('include', '/reports-dashboards'); -// }); -// }); +describe('Test reporting integration if plugin installed', () => { + beforeEach(() => { + cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/notebooks`); + cy.get('.euiTableCellContent').contains(TEST_NOTEBOOK).click(); + cy.wait(delay * 3); + cy.get('body').then(($body) => { + skipOn($body.find('#reportingActionsButton').length <= 0); + }); + }); + + it('Create in-context PDF report from notebook', () => { + cy.get('#reportingActionsButton').click(); + cy.wait(delay); + cy.get('button.euiContextMenuItem:nth-child(1)').contains('Download PDF').click(); + cy.get('#downloadInProgressLoadingModal').should('exist'); + }); + + it('Create in-context PNG report from notebook', () => { + cy.get('#reportingActionsButton').click(); + cy.wait(delay); + cy.get('button.euiContextMenuItem:nth-child(2)').contains('Download PNG').click(); + cy.get('#downloadInProgressLoadingModal').should('exist'); + }); + + it('Create on-demand report definition from context menu', () => { + cy.get('#reportingActionsButton').click(); + cy.wait(delay); + cy.get('button.euiContextMenuItem:nth-child(3)').contains('Create report definition').click(); + cy.wait(delay); + cy.location('pathname', { timeout: 60000 }).should('include', '/reports-dashboards'); + cy.wait(delay); + cy.get('#reportSettingsName').type('Create notebook on-demand report'); + cy.get('#createNewReportDefinition').click({ force: true }); + }); + + it('View reports homepage from context menu', () => { + cy.get('#reportingActionsButton').click(); + cy.wait(delay); + cy.get('button.euiContextMenuItem:nth-child(4)').contains('View reports').click(); + cy.wait(delay); + cy.location('pathname', { timeout: 60000 }).should('include', '/reports-dashboards'); + }); +}); describe('Testing paragraphs', () => { + beforeEach(() => { + cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/notebooks`); + cy.get('.euiTableCellContent').contains(TEST_NOTEBOOK).click(); + }); + it('Goes into a notebook and creates paragraphs', () => { - moveToTestNotebook(); cy.get('.euiButton__text').contains('Add').click(); cy.wait(delay); @@ -263,7 +256,6 @@ describe('Testing paragraphs', () => { }); it('Paragraph actions layout', () => { - moveToTestNotebook(); cy.get('button[data-test-subj="notebook-paragraph-actions-button"]').should('exist').click(); cy.get('.euiContextMenuPanelTitle').contains('Actions'); cy.get('.euiContextMenuItem__text').eq(0).contains('Add paragraph to top'); @@ -316,7 +308,6 @@ describe('Testing paragraphs', () => { }); it('Duplicates paragraphs', () => { - moveToTestNotebook(); cy.get('.euiButtonIcon[aria-label="Open paragraph menu"]').eq(0).click(); cy.wait(delay); cy.get('.euiContextMenuItem__text').contains('Duplicate').eq(0).click(); diff --git a/public/components/metrics/helpers/utils.tsx b/public/components/metrics/helpers/utils.tsx index dd7524bd3c..96f7fe4772 100644 --- a/public/components/metrics/helpers/utils.tsx +++ b/public/components/metrics/helpers/utils.tsx @@ -20,7 +20,6 @@ import { CoreStart } from '../../../../../../src/core/public'; import { MetricType } from '../../../../common/types/metrics'; import { VisualizationType } from '../../../../common/types/custom_panels'; import { DEFAULT_METRIC_HEIGHT, DEFAULT_METRIC_WIDTH } from '../../../../common/constants/metrics'; -import { UNITS_OF_MEASURE } from '../../../../common/constants/explorer'; import { updateQuerySpanInterval } from '../../custom_panels/helpers/utils'; export const onTimeChange = ( diff --git a/public/components/metrics/top_menu/metrics_export_panel.tsx b/public/components/metrics/top_menu/metrics_export_panel.tsx index 9a26d4630c..2060f67796 100644 --- a/public/components/metrics/top_menu/metrics_export_panel.tsx +++ b/public/components/metrics/top_menu/metrics_export_panel.tsx @@ -18,6 +18,11 @@ import { import { createPrometheusMetricById } from '../helpers/utils'; import { MetricType } from '../../../../common/types/metrics'; import { fetchVisualizationById } from '../../custom_panels/helpers/utils'; +import { useDispatch, useSelector } from 'react-redux'; +import { + fetchPanels, + selectPanelList, +} from '../../../../public/components/custom_panels/redux/panel_slice'; interface MetricsExportPanelProps { http: CoreStart['http']; @@ -49,14 +54,17 @@ export const MetricsExportPanel = ({ const [errorResponse, setErrorResponse] = useState(''); - const getCustomPanelList = async () => { - http - .get(`${CUSTOM_PANELS_API_PREFIX}/panels`) - .then((res: any) => { - setOptions(res.panels || []); - }) - .catch((error: any) => console.error(error)); - }; + const customPanels = useSelector(selectPanelList); + + const dispatch = useDispatch(); + + useEffect(() => { + dispatch(fetchPanels()); + }, []); + + // useEffect(() => { + // setOptions(customPanels || []); + // }, [customPanels]); const fetchAllvisualizationsById = async () => { let tempVisualizationsMetaData = await Promise.all( @@ -70,7 +78,6 @@ export const MetricsExportPanel = ({ }; useEffect(() => { - getCustomPanelList(); fetchAllvisualizationsById(); }, []); @@ -92,10 +99,10 @@ export const MetricsExportPanel = ({ setSelectedPanelOptions(options); }} selectedOptions={selectedPanelOptions} - options={options.map((option: CustomPanelOptions) => { + options={customPanels.map((option: any) => { return { panel: option, - label: option.name, + label: option.title, }; })} isClearable={true} diff --git a/public/components/metrics/top_menu/top_menu.tsx b/public/components/metrics/top_menu/top_menu.tsx index cd3d17e3b3..295e8d28c8 100644 --- a/public/components/metrics/top_menu/top_menu.tsx +++ b/public/components/metrics/top_menu/top_menu.tsx @@ -37,6 +37,7 @@ import SavedObjects from '../../../services/saved_objects/event_analytics/saved_ import { sortMetricLayout, updateMetricsWithSelections } from '../helpers/utils'; import { CUSTOM_PANELS_API_PREFIX } from '../../../../common/constants/custom_panels'; import { MetricsExportPanel } from './metrics_export_panel'; +import { addVizToPanels, uuidRx } from '../../custom_panels/redux/panel_slice'; interface TopMenuProps { http: CoreStart['http']; @@ -191,8 +192,11 @@ export const TopMenu = ({ if (selectedPanelOptions.length > 0) { try { const allMetricIds = savedMetricIds.map((metric) => metric.objectId); - savedMetricsInPanels = await Promise.all( - selectedPanelOptions.map((panel) => { + const soPanels = selectedPanelOptions.filter((panel) => uuidRx.test(panel.panel.id)); + const opsPanels = selectedPanelOptions.filter((panel) => !uuidRx.test(panel.panel.id)); + + const savedMetricsInOpsPanels = await Promise.all( + opsPanels.map((panel) => { return http.post(`${CUSTOM_PANELS_API_PREFIX}/visualizations/multiple`, { body: JSON.stringify({ panelId: panel.panel.id, @@ -201,6 +205,10 @@ export const TopMenu = ({ }); }) ); + + allMetricIds.forEach((metricId) => { + dispatch(addVizToPanels(soPanels, metricId)); + }); } catch (e) { const message = 'Issue in saving metrics to panels'; console.error(message, e); From d37151781a780298105bac8ca22ed120d4aea083 Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Tue, 18 Apr 2023 15:26:18 -0700 Subject: [PATCH 3/4] remove commented code Signed-off-by: Shenoy Pratik --- public/components/metrics/top_menu/metrics_export_panel.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/public/components/metrics/top_menu/metrics_export_panel.tsx b/public/components/metrics/top_menu/metrics_export_panel.tsx index 2060f67796..50819bcf65 100644 --- a/public/components/metrics/top_menu/metrics_export_panel.tsx +++ b/public/components/metrics/top_menu/metrics_export_panel.tsx @@ -62,10 +62,6 @@ export const MetricsExportPanel = ({ dispatch(fetchPanels()); }, []); - // useEffect(() => { - // setOptions(customPanels || []); - // }, [customPanels]); - const fetchAllvisualizationsById = async () => { let tempVisualizationsMetaData = await Promise.all( sortedMetricsLayout.map(async (metricLayout) => { From ce5c9dbd9c4f518e1fd9fb270cd85ef7f3955102 Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Tue, 18 Apr 2023 15:57:47 -0700 Subject: [PATCH 4/4] fixed metrics export tests Signed-off-by: Shenoy Pratik --- .../top_menu/__tests__/metrics_export_panel.test.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/public/components/metrics/top_menu/__tests__/metrics_export_panel.test.tsx b/public/components/metrics/top_menu/__tests__/metrics_export_panel.test.tsx index c6d30fdc32..df95065e1e 100644 --- a/public/components/metrics/top_menu/__tests__/metrics_export_panel.test.tsx +++ b/public/components/metrics/top_menu/__tests__/metrics_export_panel.test.tsx @@ -13,16 +13,24 @@ import { sampleSortedMetricsLayout, sampleVisualizationById, } from '../../../../../test/metrics_contants'; -import { createStore } from '@reduxjs/toolkit'; +import { applyMiddleware, createStore } from '@reduxjs/toolkit'; import { rootReducer } from '../../../../framework/redux/reducers'; import { Provider } from 'react-redux'; import { HttpResponse } from '../../../../../../../src/core/public'; import { MetricsExportPanel } from '../metrics_export_panel'; import { EuiComboBoxOptionOption } from '@elastic/eui'; +import thunk from 'redux-thunk'; +import { coreRefs } from '../../../../framework/core_refs'; describe('Export Metrics Panel Component', () => { configure({ adapter: new Adapter() }); - const store = createStore(rootReducer); + const store = createStore(rootReducer, applyMiddleware(thunk)); + coreRefs.savedObjectsClient.find = jest.fn(() => + Promise.resolve({ + savedObjects: [], + then: () => Promise.resolve(), + }) + ); it('renders Export Metrics Panel Component', async () => { let httpFlag = 1;