mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 08:42:15 +08:00
GrafanaContext: Exploring a way to get rid of global scope singletons (#52128)
* Context start * More progress on more generic react context for services * Update * Update Page test * Fixing tests * Moving to core app
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
import { act, render, screen } from '@testing-library/react';
|
||||
import React, { Component } from 'react';
|
||||
import { Route, Router } from 'react-router-dom';
|
||||
import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock';
|
||||
|
||||
import { AppPlugin, PluginType, AppRootProps, NavModelItem } from '@grafana/data';
|
||||
import { locationService, setEchoSrv } from '@grafana/runtime';
|
||||
import { GrafanaContext } from 'app/core/context/GrafanaContext';
|
||||
import { GrafanaRoute } from 'app/core/navigation/GrafanaRoute';
|
||||
import { Echo } from 'app/core/services/echo/Echo';
|
||||
|
||||
@ -66,7 +68,9 @@ function renderUnderRouter() {
|
||||
|
||||
render(
|
||||
<Router history={locationService.getHistory()}>
|
||||
<Route path="/a/:pluginId" exact render={(props) => <GrafanaRoute {...props} route={route as any} />} />
|
||||
<GrafanaContext.Provider value={getGrafanaContextMock()}>
|
||||
<Route path="/a/:pluginId" exact render={(props) => <GrafanaRoute {...props} route={route as any} />} />
|
||||
</GrafanaContext.Provider>
|
||||
</Router>
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user