diff --git a/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataAlertingTab.test.tsx b/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataAlertingTab.test.tsx index 7a3ccdd4f4c..68aa0bd5f5d 100644 --- a/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataAlertingTab.test.tsx +++ b/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataAlertingTab.test.tsx @@ -1,3 +1,4 @@ +import 'whatwg-fetch'; import { act, render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; @@ -7,6 +8,7 @@ import { byTestId } from 'testing-library-selector'; import { DataSourceApi } from '@grafana/data'; import { PromOptions, PrometheusDatasource } from '@grafana/prometheus'; import { locationService, setDataSourceSrv } from '@grafana/runtime'; +import { backendSrv } from 'app/core/services/backend_srv'; import { fetchRules } from 'app/features/alerting/unified/api/prometheus'; import { fetchRulerRules } from 'app/features/alerting/unified/api/ruler'; import * as ruleActionButtons from 'app/features/alerting/unified/components/rules/RuleActionsButtons'; @@ -14,6 +16,7 @@ import { MockDataSourceSrv, grantUserPermissions, mockDataSource, + mockFolder, mockPromAlertingRule, mockPromRuleGroup, mockPromRuleNamespace, @@ -192,6 +195,9 @@ describe('PanelAlertTabContent', () => { AccessControlAction.AlertingRuleExternalRead, AccessControlAction.AlertingRuleExternalWrite, ]); + + jest.spyOn(backendSrv, 'getFolderByUid').mockResolvedValue(mockFolder()); + mocks.getAllDataSources.mockReturnValue(Object.values(dataSources)); const dsService = new MockDataSourceSrv(dataSources); dsService.datasources[dataSources.prometheus.uid] = new PrometheusDatasource( diff --git a/public/app/features/dashboard/containers/PublicDashboardPageProxy.test.tsx b/public/app/features/dashboard/containers/PublicDashboardPageProxy.test.tsx index 897c5df9678..132093c139a 100644 --- a/public/app/features/dashboard/containers/PublicDashboardPageProxy.test.tsx +++ b/public/app/features/dashboard/containers/PublicDashboardPageProxy.test.tsx @@ -1,3 +1,4 @@ +import 'whatwg-fetch'; import { render, screen, waitFor } from '@testing-library/react'; import React from 'react'; import { Provider } from 'react-redux'; @@ -7,6 +8,7 @@ import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock'; import { selectors as e2eSelectors } from '@grafana/e2e-selectors'; import { config, locationService } from '@grafana/runtime'; import { GrafanaContext } from 'app/core/context/GrafanaContext'; +import { backendSrv } from 'app/core/services/backend_srv'; import { configureStore } from 'app/store/configureStore'; import { DashboardRoutes } from '../../../types'; @@ -50,6 +52,11 @@ function setup(props: Partial) { describe('PublicDashboardPageProxy', () => { beforeEach(() => { config.featureToggles.publicDashboardsScene = false; + + // Mock the dashboard UID response so we don't get any refused connection errors + // from this test (as the fetch polyfill means this logic would actually try and call the API) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + jest.spyOn(backendSrv, 'getPublicDashboardByUid').mockResolvedValue({ dashboard: {}, meta: {} } as any); }); describe('when scene feature enabled', () => { diff --git a/public/app/features/explore/extensions/AddToDashboard/index.test.tsx b/public/app/features/explore/extensions/AddToDashboard/index.test.tsx index 4780b59492d..42bcf6d4e9a 100644 --- a/public/app/features/explore/extensions/AddToDashboard/index.test.tsx +++ b/public/app/features/explore/extensions/AddToDashboard/index.test.tsx @@ -1,3 +1,4 @@ +import 'whatwg-fetch'; import { act, render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React, { ReactNode } from 'react'; @@ -56,6 +57,12 @@ describe('AddToDashboardButton', () => { setEchoSrv(new Echo()); }); + beforeEach(() => { + // Mock the search response so we don't get any refused connection errors + // from this test (as the fetch polyfill means this logic would actually try and call the API) + jest.spyOn(backendSrv, 'search').mockResolvedValue([]); + }); + it('Is disabled if explore pane has no queries', async () => { setup(, []);