diff --git a/packages/test-utils/src/testUtils/index.tsx b/packages/test-utils/src/testUtils/index.tsx
index bfd870e2ad..1df236d92c 100644
--- a/packages/test-utils/src/testUtils/index.tsx
+++ b/packages/test-utils/src/testUtils/index.tsx
@@ -24,6 +24,7 @@ export {
export type { TestAppOptions } from './appWrappers';
export * from './msw';
export * from './logCollector';
+export * from './providers';
export * from './testingLibrary';
export { TestApiProvider, TestApiRegistry } from './TestApiProvider';
export type { TestApiProviderProps } from './TestApiProvider';
diff --git a/packages/test-utils/src/testUtils/providers.tsx b/packages/test-utils/src/testUtils/providers.tsx
new file mode 100644
index 0000000000..cf4787099b
--- /dev/null
+++ b/packages/test-utils/src/testUtils/providers.tsx
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2020 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import React, { PropsWithChildren } from 'react';
+import { createPlugin, PluginProvider } from '@backstage/core-plugin-api';
+
+export const MockPluginProvider = ({ children }: PropsWithChildren<{}>) => {
+ type TestInputPluginOptions = {};
+ type TestPluginOptions = {};
+ const plugin = createPlugin({
+ id: 'my-plugin',
+ __experimentalConfigure(_: TestInputPluginOptions): TestPluginOptions {
+ return {};
+ },
+ });
+
+ return {children};
+};
diff --git a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx
index cc00a57314..4636db5576 100644
--- a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx
+++ b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx
@@ -23,21 +23,20 @@ import {
} from '@backstage/catalog-model';
import { TableColumn, TableProps } from '@backstage/core-components';
import {
- createPlugin,
IdentityApi,
identityApiRef,
- PluginProvider,
ProfileInfo,
storageApiRef,
} from '@backstage/core-plugin-api';
import {
catalogApiRef,
entityRouteRef,
- starredEntitiesApiRef,
MockStarredEntitiesApi,
+ starredEntitiesApiRef,
} from '@backstage/plugin-catalog-react';
import {
mockBreakpoint,
+ MockPluginProvider,
MockStorageApi,
renderWithEffects,
TestApiProvider,
@@ -135,22 +134,6 @@ describe('DefaultCatalogPage', () => {
};
const storageApi = MockStorageApi.create();
- type TestInputPluginOptions = {
- 'key-1': string;
- };
-
- type TestPluginOptions = {
- 'key-1': string;
- 'key-2': string;
- };
-
- const plugin = createPlugin({
- id: 'my-plugin',
- __experimentalConfigure(_: TestInputPluginOptions): TestPluginOptions {
- return { 'key-1': 'value-1', 'key-2': 'value-2' };
- },
- });
-
const renderWrapped = (children: React.ReactNode) =>
renderWithEffects(
wrapInTestApp(
@@ -162,7 +145,7 @@ describe('DefaultCatalogPage', () => {
[starredEntitiesApiRef, new MockStarredEntitiesApi()],
]}
>
- {children}
+ {children}
,
{
mountedRoutes: {
diff --git a/plugins/cost-insights/package.json b/plugins/cost-insights/package.json
index 3ef57bf70b..8f383b5d47 100644
--- a/plugins/cost-insights/package.json
+++ b/plugins/cost-insights/package.json
@@ -38,6 +38,7 @@
"@backstage/core-plugin-api": "workspace:^",
"@backstage/plugin-catalog-react": "workspace:^",
"@backstage/plugin-cost-insights-common": "workspace:^",
+ "@backstage/test-utils": "workspace:^",
"@backstage/theme": "workspace:^",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
diff --git a/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewCard.test.tsx b/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewCard.test.tsx
index 074c3a64bd..e8fbb7abcb 100644
--- a/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewCard.test.tsx
+++ b/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewCard.test.tsx
@@ -15,7 +15,7 @@
*/
import React from 'react';
import { fireEvent } from '@testing-library/react';
-import { renderInTestApp } from '@backstage/test-utils';
+import { MockPluginProvider, renderInTestApp } from '@backstage/test-utils';
import { CostOverviewCard } from './CostOverviewCard';
import { Cost } from '../../types';
import {
@@ -23,12 +23,11 @@ import {
getGroupedProducts,
getGroupedProjects,
MockAggregatedDailyCosts,
- trendlineOf,
MockBillingDateProvider,
MockConfigProvider,
MockFilterProvider,
MockScrollProvider,
- MockPluginProvider,
+ trendlineOf,
} from '../../testUtils';
import { CostInsightsThemeProvider } from '../CostInsightsPage/CostInsightsThemeProvider';
diff --git a/plugins/cost-insights/src/components/EntityCosts/EntityCost.test.tsx b/plugins/cost-insights/src/components/EntityCosts/EntityCost.test.tsx
index da3f4300bb..f288f54e9b 100644
--- a/plugins/cost-insights/src/components/EntityCosts/EntityCost.test.tsx
+++ b/plugins/cost-insights/src/components/EntityCosts/EntityCost.test.tsx
@@ -14,20 +14,22 @@
* limitations under the License.
*/
import React from 'react';
-import { renderInTestApp } from '@backstage/test-utils';
+import {
+ MockPluginProvider,
+ renderInTestApp,
+ TestApiProvider,
+} from '@backstage/test-utils';
import {
changeOf,
MockAggregatedDailyCosts,
MockBillingDateProvider,
MockConfigProvider,
MockFilterProvider,
- MockPluginProvider,
MockScrollProvider,
trendlineOf,
} from '../../testUtils';
import { CostInsightsThemeProvider } from '../CostInsightsPage/CostInsightsThemeProvider';
import { EntityCostsCard } from './EntityCosts';
-import { TestApiProvider } from '@backstage/test-utils';
import { CostInsightsApi, costInsightsApiRef } from '../../api';
import { EntityProvider } from '@backstage/plugin-catalog-react';
import { Entity } from '@backstage/catalog-model';
diff --git a/plugins/cost-insights/src/testUtils/providers.tsx b/plugins/cost-insights/src/testUtils/providers.tsx
index f8d23dda3c..a8610c44ba 100644
--- a/plugins/cost-insights/src/testUtils/providers.tsx
+++ b/plugins/cost-insights/src/testUtils/providers.tsx
@@ -15,18 +15,23 @@
*/
import React, { PropsWithChildren } from 'react';
-import { LoadingContext, LoadingContextProps } from '../hooks/useLoading';
-import { GroupsContext, GroupsContextProps } from '../hooks/useGroups';
-import { FilterContext, FilterContextProps } from '../hooks/useFilters';
-import { ConfigContext, ConfigContextProps } from '../hooks/useConfig';
-import { CurrencyContext, CurrencyContextProps } from '../hooks/useCurrency';
import {
+ LoadingContext,
+ LoadingContextProps,
+ GroupsContext,
+ GroupsContextProps,
+ FilterContext,
+ FilterContextProps,
+ ConfigContext,
+ ConfigContextProps,
+ CurrencyContext,
+ CurrencyContextProps,
BillingDateContext,
BillingDateContextProps,
-} from '../hooks/useLastCompleteBillingDate';
-import { ScrollContext, ScrollContextProps } from '../hooks/useScroll';
+ ScrollContext,
+ ScrollContextProps,
+} from '../hooks';
import { Group, Duration } from '../types';
-import { createPlugin, PluginProvider } from '@backstage/core-plugin-api';
export const MockGroups: Group[] = [{ id: 'tech' }, { id: 'mock-group' }];
@@ -145,19 +150,6 @@ export const MockBillingDateProvider = ({
export type MockScrollProviderProps = PropsWithChildren<{}>;
-export const MockPluginProvider = ({ children }: PropsWithChildren<{}>) => {
- type TestInputPluginOptions = {};
- type TestPluginOptions = {};
- const plugin = createPlugin({
- id: 'my-plugin',
- __experimentalConfigure(_: TestInputPluginOptions): TestPluginOptions {
- return {};
- },
- });
-
- return {children};
-};
-
export const MockScrollProvider = ({ children }: MockScrollProviderProps) => {
const defaultContext: ScrollContextProps = {
scroll: null,