diff --git a/.betterer.results b/.betterer.results
index 6f5a994bf67..bf88139ba07 100644
--- a/.betterer.results
+++ b/.betterer.results
@@ -1283,14 +1283,6 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings. Wrap text with ", "0"],
[0, 0, 0, "No untranslated strings. Wrap text with ", "1"]
],
- "public/app/core/navigation/testRoutes.tsx:5381": [
- [0, 0, 0, "No untranslated strings. Wrap text with ", "0"],
- [0, 0, 0, "No untranslated strings. Wrap text with ", "1"],
- [0, 0, 0, "No untranslated strings. Wrap text with ", "2"],
- [0, 0, 0, "No untranslated strings. Wrap text with ", "3"],
- [0, 0, 0, "No untranslated strings. Wrap text with ", "4"],
- [0, 0, 0, "No untranslated strings. Wrap text with ", "5"]
- ],
"public/app/core/navigation/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
diff --git a/public/app/core/components/AppChrome/MegaMenu/MegaMenu.test.tsx b/public/app/core/components/AppChrome/MegaMenu/MegaMenu.test.tsx
index f03f3907093..c91beb88ae0 100644
--- a/public/app/core/components/AppChrome/MegaMenu/MegaMenu.test.tsx
+++ b/public/app/core/components/AppChrome/MegaMenu/MegaMenu.test.tsx
@@ -1,12 +1,10 @@
-import { render, screen } from '@testing-library/react';
+import { screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
-import { Router } from 'react-router-dom';
-import { TestProvider } from 'test/helpers/TestProvider';
-import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock';
+import { render } from 'test/test-utils';
import { NavModelItem } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
-import { locationService } from '@grafana/runtime';
+import { configureStore } from 'app/store/configureStore';
import { MegaMenu } from './MegaMenu';
@@ -33,16 +31,8 @@ const setup = () => {
},
];
- const grafanaContext = getGrafanaContextMock();
- grafanaContext.chrome.setMegaMenuOpen(true);
-
- return render(
-
-
- {}} />
-
-
- );
+ const store = configureStore({ navBarTree });
+ return render( {}} />, { store });
};
describe('MegaMenu', () => {
diff --git a/public/app/core/navigation/GrafanaRoute.test.tsx b/public/app/core/navigation/GrafanaRoute.test.tsx
index 301ccdae935..a8623765080 100644
--- a/public/app/core/navigation/GrafanaRoute.test.tsx
+++ b/public/app/core/navigation/GrafanaRoute.test.tsx
@@ -1,8 +1,6 @@
-import { render, screen } from '@testing-library/react';
-import { History, Location } from 'history';
+import { screen } from '@testing-library/react';
import { lazy, ComponentType } from 'react';
-import { match } from 'react-router-dom';
-import { TestProvider } from 'test/helpers/TestProvider';
+import { render } from 'test/test-utils';
import { setEchoSrv } from '@grafana/runtime';
@@ -11,11 +9,34 @@ import { Echo } from '../services/echo/Echo';
import { GrafanaRoute, Props } from './GrafanaRoute';
import { GrafanaRouteComponentProps } from './types';
+const mockLocation = {
+ search: '?query=hello&test=asd',
+ pathname: '',
+ state: undefined,
+ hash: '',
+};
function setup(overrides: Partial) {
const props: Props = {
- location: { search: '?query=hello&test=asd' } as Location,
- history: {} as History,
- match: {} as match,
+ location: mockLocation,
+ history: {
+ length: 0,
+ action: 'PUSH',
+ location: mockLocation,
+ push: jest.fn(),
+ replace: jest.fn(),
+ go: jest.fn(),
+ goBack: jest.fn(),
+ goForward: jest.fn(),
+ block: jest.fn(),
+ listen: jest.fn(),
+ createHref: jest.fn(),
+ },
+ match: {
+ params: {},
+ isExact: false,
+ path: '',
+ url: '',
+ },
route: {
path: '/',
component: () => ,
@@ -23,11 +44,7 @@ function setup(overrides: Partial) {
...overrides,
};
- render(
-
-
-
- );
+ render();
}
describe('GrafanaRoute', () => {
diff --git a/public/app/core/navigation/testRoutes.tsx b/public/app/core/navigation/testRoutes.tsx
deleted file mode 100644
index 391d4dac3af..00000000000
--- a/public/app/core/navigation/testRoutes.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import { Link, NavLink } from 'react-router-dom';
-
-import { RouterDebugger } from './RouterDebugger';
-import { RouteDescriptor } from './types';
-
-export const testRoutes: RouteDescriptor[] = [
- {
- path: '/test1',
- component: () => (
- <>
- Test1
- Test2 link
- Test2 navlink
- >
- ),
- },
- {
- path: '/test2',
- component: () => (
- <>
- Test2
- Test1 link
- Test1 navlink
- >
- ),
- },
- {
- path: '/router-debug',
- component: RouterDebugger,
- },
-];
diff --git a/public/app/features/dashboard/containers/DashboardPage.test.tsx b/public/app/features/dashboard/containers/DashboardPage.test.tsx
index 4e178bfe8a6..7a1f01125f0 100644
--- a/public/app/features/dashboard/containers/DashboardPage.test.tsx
+++ b/public/app/features/dashboard/containers/DashboardPage.test.tsx
@@ -1,7 +1,6 @@
import { screen, waitFor } from '@testing-library/react';
import { KBarProvider } from 'kbar';
import { Component } from 'react';
-import { match } from 'react-router-dom';
import { useEffectOnce } from 'react-use';
import { mockToolkitActionCreator } from 'test/core/redux/mocks';
import { render } from 'test/test-utils';
@@ -101,7 +100,7 @@ function setup(propOverrides?: Partial) {
const props: Props = {
...getRouteComponentProps({
- match: { params: { slug: 'my-dash', uid: '11' } } as unknown as match,
+ match: { params: { slug: 'my-dash', uid: '11' }, isExact: false, path: '', url: '' },
route: { routeName: DashboardRoutes.Normal } as RouteDescriptor,
}),
navIndex: {
@@ -271,7 +270,7 @@ describe('DashboardPage', () => {
const { rerender } = setup();
rerender({ dashboard: getTestDashboard() });
rerender({
- match: { params: { uid: 'new-uid' } } as unknown as match,
+ match: { params: { uid: 'new-uid' }, isExact: false, path: '', url: '' },
dashboard: getTestDashboard({ title: 'Another dashboard' }),
});
await waitFor(() => {
diff --git a/public/app/features/dashboard/containers/SoloPanelPage.test.tsx b/public/app/features/dashboard/containers/SoloPanelPage.test.tsx
index 97932973433..29753f6275a 100644
--- a/public/app/features/dashboard/containers/SoloPanelPage.test.tsx
+++ b/public/app/features/dashboard/containers/SoloPanelPage.test.tsx
@@ -1,6 +1,5 @@
import { render, screen } from '@testing-library/react';
import { Component } from 'react';
-import { match } from 'react-router-dom';
import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock';
import { Dashboard } from '@grafana/schema';
@@ -75,7 +74,10 @@ function soloPanelPageScenario(description: string, scenarioFn: (ctx: ScenarioCo
...getRouteComponentProps({
match: {
params: { slug: 'my-dash', uid: '11' },
- } as unknown as match,
+ isExact: false,
+ path: '',
+ url: '',
+ },
queryParams: {
panelId: '1',
},
diff --git a/public/app/features/invites/SignupInvited.test.tsx b/public/app/features/invites/SignupInvited.test.tsx
index f352df4e701..295b0779a95 100644
--- a/public/app/features/invites/SignupInvited.test.tsx
+++ b/public/app/features/invites/SignupInvited.test.tsx
@@ -1,7 +1,6 @@
-import { render, screen, waitFor, within } from '@testing-library/react';
+import { screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
-import { match } from 'react-router-dom';
-import { TestProvider } from 'test/helpers/TestProvider';
+import { render } from 'test/test-utils';
import { getRouteComponentProps } from 'app/core/navigation/__mocks__/routeProps';
@@ -40,15 +39,14 @@ async function setupTestContext({ get = defaultGet }: { get?: typeof defaultGet
...getRouteComponentProps({
match: {
params: { code: 'some code' },
- } as unknown as match,
+ isExact: false,
+ path: '',
+ url: '',
+ },
}),
};
- render(
-
-
-
- );
+ render();
await waitFor(() => expect(getSpy).toHaveBeenCalled());
expect(getSpy).toHaveBeenCalledTimes(1);