mirror of
https://github.com/Unleash/unleash.git
synced 2024-10-28 19:06:12 +01:00
fix: render small values in project health (#6663)
This commit is contained in:
parent
9be15d4976
commit
7ca95295bc
@ -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(
|
||||
<ProjectHealthChart
|
||||
active={1000}
|
||||
stale={1}
|
||||
potentiallyStale={1}
|
||||
health={50}
|
||||
/>,
|
||||
);
|
||||
|
||||
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('-');
|
||||
});
|
||||
});
|
||||
|
@ -29,8 +29,14 @@ export const ProjectHealthChart: React.FC<ProgressComponentProps> = ({
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user