1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-19 17:52:45 +02:00

fix: quick project filters total calculation (#10658)

This commit is contained in:
Tymoteusz Czech 2025-09-11 16:29:04 +02:00 committed by GitHub
parent 4b42435590
commit e79fa33647
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -66,6 +66,10 @@ export const LifecycleFilters = ({
countData,
}: ILifecycleFiltersBaseProps) => {
const current = state.lifecycle?.values ?? [];
const allFlagsCount = Object.entries(countData ?? {}).reduce(
(acc, [key, count]) => (key !== 'archived' ? acc + count : acc),
0,
);
return (
<Wrapper>
@ -75,7 +79,9 @@ export const LifecycleFilters = ({
value === null
? !state.lifecycle
: current.includes(value);
const count = value ? countData?.[value] : total;
const count = value
? countData?.[value]
: allFlagsCount || undefined;
const dynamicLabel =
isActive && Number.isInteger(total)
? `${label} (${total === count ? total : `${total} of ${count}`})`

View File

@ -47,7 +47,7 @@ describe('LifecycleFilters', () => {
<FeaturesOverviewLifecycleFilters state={{}} onChange={vi.fn()} />,
);
expect(getByText('All flags')).toBeInTheDocument();
expect(getByText('All flags (10)')).toBeInTheDocument();
expect(getByText('Develop (2)')).toBeInTheDocument();
expect(getByText('Rollout production (3)')).toBeInTheDocument();
expect(getByText('Cleanup (4)')).toBeInTheDocument();
@ -98,7 +98,7 @@ describe('LifecycleFilters', () => {
lifecycle: { operator: 'IS', values: ['completed'] },
});
await userEvent.click(getByText('All flags'));
await userEvent.click(getByText('All flags (10)'));
expect(onChange).toHaveBeenCalledWith({ lifecycle: null });
});
});