Merge branch 'master' into mobile-sidebar

Signed-off-by: Philipp Hugenroth <philipph@spotify.com>
This commit is contained in:
Philipp Hugenroth
2021-12-28 18:39:03 +01:00
658 changed files with 11029 additions and 4156 deletions
+8
View File
@@ -1,5 +1,13 @@
# @backstage/plugin-cost-insights
## 0.11.14
### Patch Changes
- Updated dependencies
- @backstage/core-plugin-api@0.4.0
- @backstage/core-components@0.8.2
## 0.11.13
### Patch Changes
+7 -7
View File
@@ -1,7 +1,7 @@
{
"name": "@backstage/plugin-cost-insights",
"description": "A Backstage plugin that helps you keep track of your cloud spend",
"version": "0.11.13",
"version": "0.11.14",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
@@ -32,8 +32,8 @@
},
"dependencies": {
"@backstage/config": "^0.1.10",
"@backstage/core-components": "^0.8.1",
"@backstage/core-plugin-api": "^0.3.1",
"@backstage/core-components": "^0.8.2",
"@backstage/core-plugin-api": "^0.4.0",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
@@ -56,10 +56,10 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
"@backstage/cli": "^0.10.2",
"@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@backstage/cli": "^0.10.3",
"@backstage/core-app-api": "^0.3.0",
"@backstage/dev-utils": "^0.2.15",
"@backstage/test-utils": "^0.2.0",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^11.2.5",
"@testing-library/user-event": "^13.1.8",
@@ -148,5 +148,4 @@ export type CostInsightsApi = {
export const costInsightsApiRef = createApiRef<CostInsightsApi>({
id: 'plugin.costinsights.service',
description: 'Provides cost data and alerts for the cost-insights plugin',
});
@@ -15,13 +15,12 @@
*/
import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import { renderInTestApp, TestApiProvider } from '@backstage/test-utils';
import { ProductInsights } from './ProductInsights';
import { ProductInsightsOptions } from '../../api';
import { costInsightsApiRef, ProductInsightsOptions } from '../../api';
import {
mockDefaultLoadingState,
MockConfigProvider,
MockCostInsightsApiProvider,
MockCurrencyProvider,
MockFilterProvider,
MockBillingDateProvider,
@@ -139,7 +138,7 @@ const costInsightsApi = {
function renderInContext(children: JSX.Element) {
return renderInTestApp(
<MockCostInsightsApiProvider costInsightsApi={costInsightsApi}>
<TestApiProvider apis={[[costInsightsApiRef, costInsightsApi]]}>
<MockConfigProvider>
<MockFilterProvider>
<MockCurrencyProvider>
@@ -151,7 +150,7 @@ function renderInContext(children: JSX.Element) {
</MockCurrencyProvider>
</MockFilterProvider>
</MockConfigProvider>
</MockCostInsightsApiProvider>,
</TestApiProvider>,
);
}
@@ -15,15 +15,14 @@
*/
import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import { renderInTestApp, TestApiProvider } from '@backstage/test-utils';
import { ProductInsightsCard } from './ProductInsightsCard';
import { CostInsightsApi } from '../../api';
import { CostInsightsApi, costInsightsApiRef } from '../../api';
import {
createMockEntity,
mockDefaultLoadingState,
MockComputeEngine,
MockConfigProvider,
MockCostInsightsApiProvider,
MockCurrencyProvider,
MockBillingDateProvider,
MockScrollProvider,
@@ -55,7 +54,7 @@ const renderProductInsightsCardInTestApp = async (
onSelectAsync = jest.fn(() => Promise.resolve(mockProductCost)),
) =>
await renderInTestApp(
<MockCostInsightsApiProvider costInsightsApi={costInsightsApi(entity)}>
<TestApiProvider apis={[[costInsightsApiRef, costInsightsApi(entity)]]}>
<MockConfigProvider>
<MockCurrencyProvider>
<MockLoadingProvider state={mockDefaultLoadingState}>
@@ -71,7 +70,7 @@ const renderProductInsightsCardInTestApp = async (
</MockLoadingProvider>
</MockCurrencyProvider>
</MockConfigProvider>
</MockCostInsightsApiProvider>,
</TestApiProvider>,
);
describe('<ProductInsightsCard/>', () => {
@@ -15,7 +15,6 @@
*/
import React, { PropsWithChildren } from 'react';
import { costInsightsApiRef, CostInsightsApi } from '../api';
import { LoadingContext, LoadingContextProps } from '../hooks/useLoading';
import { GroupsContext, GroupsContextProps } from '../hooks/useGroups';
import { FilterContext, FilterContextProps } from '../hooks/useFilters';
@@ -28,12 +27,6 @@ import {
import { ScrollContext, ScrollContextProps } from '../hooks/useScroll';
import { Group, Duration } from '../types';
// TODO(Rugvip): Could be good to have a clear place to put test utils that is linted accordingly
// eslint-disable-next-line import/no-extraneous-dependencies
import { IdentityApi, identityApiRef } from '@backstage/core-plugin-api';
// eslint-disable-next-line import/no-extraneous-dependencies
import { TestApiProvider } from '@backstage/test-utils';
type PartialPropsWithChildren<T> = PropsWithChildren<Partial<T>>;
export const MockGroups: Group[] = [{ id: 'tech' }, { id: 'mock-group' }];
@@ -172,48 +165,3 @@ export const MockGroupsProvider = ({
</GroupsContext.Provider>
);
};
export type MockCostInsightsApiProviderProps = PartialPropsWithChildren<{
identityApi: Partial<IdentityApi>;
costInsightsApi: Partial<CostInsightsApi>;
}>;
export const MockCostInsightsApiProvider = ({
children,
...context
}: MockCostInsightsApiProviderProps) => {
const defaultIdentityApi: IdentityApi = {
getProfile: jest.fn(),
getIdToken: jest.fn(),
getUserId: jest.fn(),
signOut: jest.fn(),
getProfileInfo: jest.fn(),
getBackstageIdentity: jest.fn(),
getCredentials: jest.fn(),
};
const defaultCostInsightsApi: CostInsightsApi = {
getAlerts: jest.fn(),
getDailyMetricData: jest.fn(),
getGroupDailyCost: jest.fn(),
getGroupProjects: jest.fn(),
getLastCompleteBillingDate: jest.fn(),
getProductInsights: jest.fn(),
getProjectDailyCost: jest.fn(),
getUserGroups: jest.fn(),
};
return (
<TestApiProvider
apis={[
[identityApiRef, { ...defaultIdentityApi, ...context.identityApi }],
[
costInsightsApiRef,
{ ...defaultCostInsightsApi, ...context.costInsightsApi },
],
]}
>
{children}
</TestApiProvider>
);
};