Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(APP-3461): Hide minParticipation details from token-voting breakdown when property is set to zero #257

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Fixed

- Hide minimum participation details on `ProposalVotingBreakdownToken` module component when minParticipation is set
to zero.

## [1.0.41] - 2024-07-30

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ describe('<ProposalVotingBreakdownToken /> component', () => {
expect(() => render(createTestComponent({ tokenTotalSupply }))).toThrow();
});

it('throws error when minParticipation is set to 0', () => {
testLogger.suppressErrors();
const minParticipation = 0;
expect(() => render(createTestComponent({ minParticipation }))).toThrow();
});

it('renders a progress and proper description for each option based on the current votes and total votes', () => {
const totalYes = 7000;
const totalNo = 2000;
Expand Down Expand Up @@ -122,4 +116,10 @@ describe('<ProposalVotingBreakdownToken /> component', () => {
expect(progressbarContainer.getByText(formattedTotal)).toBeInTheDocument();
expect(progressbarContainer.getByText(`of ${formattedMinParticipation} ${tokenSymbol}`)).toBeInTheDocument();
});

it('hides the minimum participation details when minParticipation prop is set to 0', () => {
const minParticipation = 0;
render(createTestComponent({ minParticipation }));
expect(screen.queryByText('Minimum participation')).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export const ProposalVotingBreakdownToken: React.FC<IProposalVotingBreakdownToke
const totalSupplyNumber = Number(tokenTotalSupply);

invariant(totalSupplyNumber > 0, 'ProposalVotingBreakdownToken: tokenTotalSupply must be a positive number');
invariant(minParticipation > 0, 'ProposalVotingBreakdownToken: minParticipation must be a positive number');

const totalVotes = optionValues.reduce((accumulator, option) => accumulator + option.value, 0);
const formattedTotalVotes = formatterUtils.formatNumber(totalVotes, { format: NumberFormat.GENERIC_SHORT });
Expand Down Expand Up @@ -114,19 +113,21 @@ export const ProposalVotingBreakdownToken: React.FC<IProposalVotingBreakdownToke
variant={supportReached ? 'primary' : 'neutral'}
thresholdIndicator={supportThreshold}
/>
<ProposalVotingProgress.Item
name={copy.proposalVotingBreakdownToken.minParticipation.name}
value={currentParticipationPercentage}
description={{
value: formattedTotalVotes,
text: copy.proposalVotingBreakdownToken.minParticipation.description(
`${formattedMinParticipationToken} ${tokenSymbol}`,
),
}}
showPercentage={true}
showStatusIcon={true}
variant={minParticipationReached ? 'primary' : 'neutral'}
/>
{minParticipation > 0 && (
<ProposalVotingProgress.Item
name={copy.proposalVotingBreakdownToken.minParticipation.name}
value={currentParticipationPercentage}
description={{
value: formattedTotalVotes,
text: copy.proposalVotingBreakdownToken.minParticipation.description(
`${formattedMinParticipationToken} ${tokenSymbol}`,
),
}}
showPercentage={true}
showStatusIcon={true}
variant={minParticipationReached ? 'primary' : 'neutral'}
/>
)}
</ProposalVotingProgress.Container>
{children}
</Tabs.Content>
Expand Down