diff --git a/src/pages/AnalyticsPage/Chart/Chart.jsx b/src/pages/AnalyticsPage/Chart/Chart.jsx index fa3b256473..142df28bae 100644 --- a/src/pages/AnalyticsPage/Chart/Chart.jsx +++ b/src/pages/AnalyticsPage/Chart/Chart.jsx @@ -6,7 +6,7 @@ import CoverageAreaChart from 'ui/CoverageAreaChart' import { useCoverage } from './useCoverage' const makeDesc = ({ data, first, last, repos }) => { - if (!data || data?.length === 0) return '' + if (!data || !first || !last) return '' const firstDateFormatted = format(new Date(first.date), 'MMM dd, yyy') const lastDateFormatted = format(new Date(last.date), 'MMM dd, yyy') const coverageDiff = Math.abs(first.coverage, last.coverage) diff --git a/src/pages/AnalyticsPage/Chart/Chart.spec.jsx b/src/pages/AnalyticsPage/Chart/Chart.spec.jsx index 87efabb190..6860714b8b 100644 --- a/src/pages/AnalyticsPage/Chart/Chart.spec.jsx +++ b/src/pages/AnalyticsPage/Chart/Chart.spec.jsx @@ -57,7 +57,7 @@ describe('Analytics coverage chart', () => { server.use( graphql.query('GetReposCoverageMeasurements', (req, res, ctx) => { if (hasNoData) { - return res(ctx.status(200), ctx.data({})) + return res(ctx.status(200), ctx.data({ owner: { measurements: [] } })) } if (hasSingleData) { diff --git a/src/pages/RepoPage/CoverageTab/subroute/CoverageChart/CoverageChart.jsx b/src/pages/RepoPage/CoverageTab/subroute/CoverageChart/CoverageChart.jsx index 097ca20d0a..115f3ea91c 100644 --- a/src/pages/RepoPage/CoverageTab/subroute/CoverageChart/CoverageChart.jsx +++ b/src/pages/RepoPage/CoverageTab/subroute/CoverageChart/CoverageChart.jsx @@ -8,7 +8,7 @@ import CoverageAreaChart from 'ui/CoverageAreaChart' import { useBranchSelector, useRepoCoverageTimeseries } from '../../hooks' function makeDesc({ first, last, repo, data }) { - if (!data) return '' + if (!data || !first || !last) return '' const firstDateFormatted = format(new Date(first.date), 'MMM dd, yyy') const lastDateFormatted = format(new Date(last.date), 'MMM dd, yyy') const coverageDiff = Math.abs(first.coverage, last.coverage)