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

Display voting power in red when rewards are reduced #6161

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,21 @@
let canVote: boolean;
$: canVote =
neuron.dissolveDelaySeconds >= BigInt(NNS_MINIMUM_DISSOLVE_DELAY_TO_VOTE);

let isReducedVotingPower = false;
$: isReducedVotingPower =
(neuron.decidingVotingPower ?? 0n) < (neuron.potentialVotingPower ?? 0n);
</script>

<Section testId="nns-neuron-voting-power-section-component">
<KeyValuePairInfo slot="description">
<h3 slot="key">{$i18n.neurons.voting_power}</h3>
<p slot="value" class="title-value" data-tid="voting-power">
<p
mstrasinskis marked this conversation as resolved.
Show resolved Hide resolved
slot="value"
class="title-value"
class:isReducedVotingPower
data-tid="voting-power"
>
{#if canVote}
{formatVotingPower(neuron.decidingVotingPower ?? 0n)}
{:else}
Expand Down Expand Up @@ -111,6 +120,10 @@

.title-value {
font-size: var(--font-size-h3);

&.isReducedVotingPower {
color: var(--negative-emphasis);
}
}

.content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,46 @@ describe("NnsStakeItemAction", () => {

expect(await po.getNnsNeuronRewardStatusActionPo().isPresent()).toBe(false);
});

it("should render voting power w/o extra styling when not reduced voting power", async () => {
overrideFeatureFlagsStore.setFlag(
"ENABLE_PERIODIC_FOLLOWING_CONFIRMATION",
true
);
const neuron: NeuronInfo = {
...mockNeuron,
dissolveDelaySeconds: BigInt(NNS_MINIMUM_DISSOLVE_DELAY_TO_VOTE),
decidingVotingPower: 614000000n,
potentialVotingPower: 614000000n,
fullNeuron: {
...mockFullNeuron,
decidingVotingPower: 614000000n,
potentialVotingPower: 614000000n,
},
};
const po = renderComponent(neuron);

expect(await po.isReducedVotingPowerStyle()).toBe(false);
});

it("should render voting power in red when reduced voting power", async () => {
mstrasinskis marked this conversation as resolved.
Show resolved Hide resolved
overrideFeatureFlagsStore.setFlag(
"ENABLE_PERIODIC_FOLLOWING_CONFIRMATION",
true
);
const neuron: NeuronInfo = {
...mockNeuron,
dissolveDelaySeconds: BigInt(NNS_MINIMUM_DISSOLVE_DELAY_TO_VOTE),
decidingVotingPower: 307000000n,
potentialVotingPower: 614000000n,
fullNeuron: {
...mockFullNeuron,
decidingVotingPower: 307000000n,
potentialVotingPower: 614000000n,
},
};
const po = renderComponent(neuron);

expect(await po.isReducedVotingPowerStyle()).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,10 @@ export class NnsNeuronVotingPowerSectionPo extends BasePageObject {
clickDisburse(): Promise<void> {
return this.getNeuronStateItemActionPo().clickDisburse();
}

async isReducedVotingPowerStyle(): Promise<boolean> {
return (await this.root.byTestId("voting-power").getClasses()).includes(
"isReducedVotingPower"
);
}
}
Loading