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:
Torkel Ödegaard
2022-07-23 17:09:03 +02:00
committed by GitHub
parent 4eb0a8a98e
commit b782d9aa12
15 changed files with 165 additions and 101 deletions

View File

@ -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>
);
}