diff --git a/plugins/cost-insights/src/components/CostInsightsPage/CostInsightsPage.tsx b/plugins/cost-insights/src/components/CostInsightsPage/CostInsightsPage.tsx index e1e5a73358..8e96a6f5a4 100644 --- a/plugins/cost-insights/src/components/CostInsightsPage/CostInsightsPage.tsx +++ b/plugins/cost-insights/src/components/CostInsightsPage/CostInsightsPage.tsx @@ -73,6 +73,7 @@ const CostInsightsPage = () => { const { loadingActions, loadingGroups, + loadingBillingDate, loadingInitial, dispatchInitial, dispatchInsights, @@ -140,8 +141,8 @@ const CostInsightsPage = () => { } } - // Wait for user groups to finish loading - if (!loadingGroups) { + // Wait for metadata to finish loading + if (!(loadingGroups && loadingBillingDate)) { getInsights(); } }, [ @@ -149,6 +150,7 @@ const CostInsightsPage = () => { pageFilters, loadingActions, loadingGroups, + loadingBillingDate, dispatchLoadingInsights, dispatchLoadingInitial, dispatchLoadingNone, diff --git a/plugins/cost-insights/src/components/CostInsightsPage/selector.tsx b/plugins/cost-insights/src/components/CostInsightsPage/selector.tsx index 8a9cf021c9..a73c0ff975 100644 --- a/plugins/cost-insights/src/components/CostInsightsPage/selector.tsx +++ b/plugins/cost-insights/src/components/CostInsightsPage/selector.tsx @@ -23,6 +23,7 @@ import { type CostInsightsPageLoadingProps = { loadingActions: Array; loadingGroups: boolean; + loadingBillingDate: boolean; loadingInitial: boolean; dispatchInitial: (isLoading: boolean) => void; dispatchInsights: (isLoading: boolean) => void; @@ -37,6 +38,7 @@ export const mapLoadingToProps: MapLoadingToProps }) => ({ loadingActions: actions, loadingGroups: state[DefaultLoadingAction.UserGroups], + loadingBillingDate: state[DefaultLoadingAction.LastCompleteBillingDate], loadingInitial: state[DefaultLoadingAction.CostInsightsInitial], dispatchInitial: (isLoading: boolean) => dispatch({ [DefaultLoadingAction.CostInsightsInitial]: isLoading }), diff --git a/plugins/cost-insights/src/components/ProjectGrowthAlertCard/ProjectGrowthAlertCard.test.tsx b/plugins/cost-insights/src/components/ProjectGrowthAlertCard/ProjectGrowthAlertCard.test.tsx index b3af1a49cd..49bcf4d465 100644 --- a/plugins/cost-insights/src/components/ProjectGrowthAlertCard/ProjectGrowthAlertCard.test.tsx +++ b/plugins/cost-insights/src/components/ProjectGrowthAlertCard/ProjectGrowthAlertCard.test.tsx @@ -62,6 +62,12 @@ describe('', () => { ); expect(rendered.getByText(title)).toBeInTheDocument(); expect(rendered.getByText(subheader)).toBeInTheDocument(); + expect( + rendered.getByText(MockProjectGrowthAlert.periodStart), + ).toBeInTheDocument(); + expect( + rendered.getByText(MockProjectGrowthAlert.periodEnd), + ).toBeInTheDocument(); }); it('renders the correct title and subheader for a single service', async () => { diff --git a/plugins/cost-insights/src/components/ProjectGrowthAlertCard/ProjectGrowthAlertCard.tsx b/plugins/cost-insights/src/components/ProjectGrowthAlertCard/ProjectGrowthAlertCard.tsx index e87f538a82..ed9450837f 100644 --- a/plugins/cost-insights/src/components/ProjectGrowthAlertCard/ProjectGrowthAlertCard.tsx +++ b/plugins/cost-insights/src/components/ProjectGrowthAlertCard/ProjectGrowthAlertCard.tsx @@ -21,7 +21,6 @@ import ResourceGrowthBarChart from '../ResourceGrowthBarChart'; import ResourceGrowthBarChartLegend from '../ResourceGrowthBarChartLegend'; import { Duration, ProjectGrowthData } from '../../types'; import { pluralOf } from '../../utils/grammar'; -import { formatPeriod } from '../../utils/formatters'; type ProjectGrowthAlertProps = { alert: ProjectGrowthData; @@ -34,8 +33,6 @@ const ProjectGrowthAlertCard = ({ alert }: ProjectGrowthAlertProps) => { ${alert.products.length} ${pluralOf(alert.products.length, 'product')}${ alert.products.length > 1 ? ', sorted by cost' : '' }`; - const previousName = formatPeriod(Duration.P3M, alert.periodStart, false); - const currentName = formatPeriod(Duration.P3M, alert.periodEnd, true); return ( { diff --git a/plugins/cost-insights/src/utils/mockData.ts b/plugins/cost-insights/src/utils/mockData.ts index 83dcd0d77d..b97815289b 100644 --- a/plugins/cost-insights/src/utils/mockData.ts +++ b/plugins/cost-insights/src/utils/mockData.ts @@ -78,8 +78,8 @@ export const createMockProjectGrowthData = ( ): ProjectGrowthData => { const data: ProjectGrowthData = { project: 'test-project-growth-alert', - periodStart: '2019-10-01', - periodEnd: '2020-03-31', + periodStart: 'Q4 2019', + periodEnd: 'Q1 2020', aggregation: [670532.1, 970502.8], change: { ratio: 0.5,