Incorporated the feedback
Signed-off-by: bogdannechyporenko <bogdannechiporenko@gmail.com>
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -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 <PluginProvider plugin={plugin}>{children}</PluginProvider>;
|
||||
};
|
||||
@@ -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()],
|
||||
]}
|
||||
>
|
||||
<PluginProvider plugin={plugin}>{children}</PluginProvider>
|
||||
<MockPluginProvider>{children}</MockPluginProvider>
|
||||
</TestApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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 <PluginProvider plugin={plugin}>{children}</PluginProvider>;
|
||||
};
|
||||
|
||||
export const MockScrollProvider = ({ children }: MockScrollProviderProps) => {
|
||||
const defaultContext: ScrollContextProps = {
|
||||
scroll: null,
|
||||
|
||||
Reference in New Issue
Block a user