diff --git a/frontend/src/component/project/Project/ProjectInsights/ProjectHealth/ProjectHealthChart.test.tsx b/frontend/src/component/project/Project/ProjectInsights/ProjectHealth/ProjectHealthChart.test.tsx index d5b563cdd1..f5a5618ea5 100644 --- a/frontend/src/component/project/Project/ProjectInsights/ProjectHealth/ProjectHealthChart.test.tsx +++ b/frontend/src/component/project/Project/ProjectInsights/ProjectHealth/ProjectHealthChart.test.tsx @@ -109,4 +109,35 @@ describe('ProjectHealthChart', () => { expect(screen.queryByText('3 flags')).toBeInTheDocument(); expect(screen.queryByText('50%')).toBeInTheDocument(); }); + + test('renders small values without negative stroke dasharray', () => { + const { container } = render( + , + ); + + const activeCircle = container.querySelector( + 'circle[data-testid="active-circle"]', + ); + const staleCircle = container.querySelector( + 'circle[data-testid="stale-circle"]', + ); + const potentiallyStaleCircle = container.querySelector( + 'circle[data-testid="potentially-stale-circle"]', + ); + + expect( + activeCircle?.getAttribute('stroke-dasharray')?.charAt(0), + ).not.toBe('-'); + expect( + staleCircle?.getAttribute('stroke-dasharray')?.charAt(0), + ).not.toBe('-'); + expect( + potentiallyStaleCircle?.getAttribute('stroke-dasharray')?.charAt(0), + ).not.toBe('-'); + }); }); diff --git a/frontend/src/component/project/Project/ProjectInsights/ProjectHealth/ProjectHealthChart.tsx b/frontend/src/component/project/Project/ProjectInsights/ProjectHealth/ProjectHealthChart.tsx index 5d6fd82d37..3c4bf220aa 100644 --- a/frontend/src/component/project/Project/ProjectInsights/ProjectHealth/ProjectHealthChart.tsx +++ b/frontend/src/component/project/Project/ProjectInsights/ProjectHealth/ProjectHealthChart.tsx @@ -29,8 +29,14 @@ export const ProjectHealthChart: React.FC = ({ const potentiallyStalePercentage = active === 0 ? 0 : (potentiallyStale / active) * 100; - const activeLength = (activePercentage / 100) * circumference - gap; - const staleLength = (stalePercentage / 100) * circumference - gap; + const activeLength = Math.max( + (activePercentage / 100) * circumference - gap, + 1, + ); + const staleLength = Math.max( + (stalePercentage / 100) * circumference - gap, + 1, + ); const potentiallyStaleLength = (potentiallyStalePercentage / 100) * activeLength;