Test fixes

Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2022-11-16 12:39:56 +01:00
parent a5ecdb99f0
commit c860237e31
2 changed files with 38 additions and 2 deletions
@@ -30,6 +30,7 @@ import {
MockScrollProvider,
} from '../../testUtils';
import { CostInsightsThemeProvider } from '../CostInsightsPage/CostInsightsThemeProvider';
import { createPlugin, PluginProvider } from '@backstage/core-plugin-api';
const mockGroupDailyCost: Cost = {
id: 'test-group',
@@ -38,13 +39,30 @@ const mockGroupDailyCost: Cost = {
trendline: trendlineOf(MockAggregatedDailyCosts),
};
type TestInputPluginOptions = {
showTrendLine: boolean;
};
type TestPluginOptions = {
showTrendLine: boolean;
};
const plugin = createPlugin({
id: 'my-plugin',
__experimentalConfigure(_: TestInputPluginOptions): TestPluginOptions {
return { showTrendLine: false };
},
});
function renderInContext(children: JSX.Element) {
return renderInTestApp(
<CostInsightsThemeProvider>
<MockConfigProvider>
<MockFilterProvider>
<MockBillingDateProvider>
<MockScrollProvider>{children}</MockScrollProvider>
<MockScrollProvider>
<PluginProvider plugin={plugin}>{children}</PluginProvider>
</MockScrollProvider>
</MockBillingDateProvider>
</MockFilterProvider>
</MockConfigProvider>
@@ -32,6 +32,7 @@ import { EntityProvider } from '@backstage/plugin-catalog-react';
import { Entity } from '@backstage/catalog-model';
import { LoadingProvider } from '../../hooks';
import { Cost } from '@backstage/plugin-cost-insights-common';
import { createPlugin, PluginProvider } from '@backstage/core-plugin-api';
function renderInContext(children: JSX.Element) {
const mockEntity = {
@@ -56,6 +57,21 @@ function renderInContext(children: JSX.Element) {
getAlerts: jest.fn().mockResolvedValue({}),
};
type TestInputPluginOptions = {
showTrendLine: boolean;
};
type TestPluginOptions = {
showTrendLine: boolean;
};
const plugin = createPlugin({
id: 'my-plugin',
__experimentalConfigure(_: TestInputPluginOptions): TestPluginOptions {
return { showTrendLine: false };
},
});
return renderInTestApp(
<TestApiProvider apis={[[costInsightsApiRef, mockApi]]}>
<EntityProvider entity={mockEntity}>
@@ -64,7 +80,9 @@ function renderInContext(children: JSX.Element) {
<LoadingProvider>
<MockFilterProvider>
<MockBillingDateProvider>
<MockScrollProvider>{children}</MockScrollProvider>
<MockScrollProvider>
<PluginProvider plugin={plugin}>{children}</PluginProvider>
</MockScrollProvider>
</MockBillingDateProvider>
</MockFilterProvider>
</LoadingProvider>