mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +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('3 flags')).toBeInTheDocument();
|
||||||
expect(screen.queryByText('50%')).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 =
|
const potentiallyStalePercentage =
|
||||||
active === 0 ? 0 : (potentiallyStale / active) * 100;
|
active === 0 ? 0 : (potentiallyStale / active) * 100;
|
||||||
|
|
||||||
const activeLength = (activePercentage / 100) * circumference - gap;
|
const activeLength = Math.max(
|
||||||
const staleLength = (stalePercentage / 100) * circumference - gap;
|
(activePercentage / 100) * circumference - gap,
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
const staleLength = Math.max(
|
||||||
|
(stalePercentage / 100) * circumference - gap,
|
||||||
|
1,
|
||||||
|
);
|
||||||
const potentiallyStaleLength =
|
const potentiallyStaleLength =
|
||||||
(potentiallyStalePercentage / 100) * activeLength;
|
(potentiallyStalePercentage / 100) * activeLength;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user