mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: fix EmptyStateNoDatasource flaky test (#64520)
Chore: fix EmptyStateNoDatasourceflaky test
This commit is contained in:
parent
53186c14a4
commit
bda1a91e80
@ -7,7 +7,6 @@ import { TestProvider } from 'test/helpers/TestProvider';
|
||||
|
||||
import { DataSourcePluginMeta } from '@grafana/data';
|
||||
import * as runtime from '@grafana/runtime';
|
||||
import { backendSrv } from 'app/core/services/backend_srv';
|
||||
import { contextSrv } from 'app/core/services/context_srv';
|
||||
import 'whatwg-fetch';
|
||||
|
||||
@ -27,8 +26,6 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
beforeAll(() => {
|
||||
runtime.setBackendSrv(backendSrv);
|
||||
|
||||
server.listen({ onUnhandledRequest: 'bypass' });
|
||||
});
|
||||
|
||||
|
@ -3,9 +3,10 @@ import React, { ComponentProps } from 'react';
|
||||
import { useAsync } from 'react-use';
|
||||
|
||||
import { DataSourcePluginMeta, GrafanaTheme2, PageLayoutType } from '@grafana/data';
|
||||
import { getBackendSrv, reportInteraction } from '@grafana/runtime';
|
||||
import { reportInteraction } from '@grafana/runtime';
|
||||
import { Icon, useStyles2 } from '@grafana/ui';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
import { useGrafana } from 'app/core/context/GrafanaContext';
|
||||
import { contextSrv } from 'app/core/core';
|
||||
import { t } from 'app/core/internationalization';
|
||||
import { useAddDatasource } from 'app/features/datasources/state';
|
||||
@ -30,8 +31,9 @@ interface Props extends Pick<ComponentProps<typeof Page>, 'navId' | 'pageNav'> {
|
||||
|
||||
export function EmptyStateNoDatasource({ onCTAClick, loading = false, title, CTAText, navId, pageNav }: Props) {
|
||||
const styles = useStyles2(getStyles);
|
||||
const { backend } = useGrafana();
|
||||
const { value: datasources, loading: loadingDatasources } = useAsync(async () => {
|
||||
const datasourceMeta: DataSourcePluginMeta[] = await getBackendSrv().get('/api/plugins', {
|
||||
const datasourceMeta: DataSourcePluginMeta[] = await backend.get('/api/plugins', {
|
||||
enabled: 1,
|
||||
type: 'datasource',
|
||||
});
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { GrafanaConfig } from '@grafana/data';
|
||||
import { BackendSrv, LocationService } from '@grafana/runtime';
|
||||
import { LocationService } from '@grafana/runtime';
|
||||
import { AppChromeService } from 'app/core/components/AppChrome/AppChromeService';
|
||||
import { GrafanaContextType } from 'app/core/context/GrafanaContext';
|
||||
import { backendSrv } from 'app/core/services/backend_srv';
|
||||
import { KeybindingSrv } from 'app/core/services/keybindingSrv';
|
||||
|
||||
/** Not sure what this should evolve into, just a starting point */
|
||||
export function getGrafanaContextMock(overrides: Partial<GrafanaContextType> = {}): GrafanaContextType {
|
||||
return {
|
||||
chrome: new AppChromeService(),
|
||||
// eslint-disable-next-line
|
||||
backend: {} as BackendSrv,
|
||||
backend: backendSrv,
|
||||
// eslint-disable-next-line
|
||||
location: {} as LocationService,
|
||||
// eslint-disable-next-line
|
||||
|
Loading…
Reference in New Issue
Block a user