From 8c460b88532738536319f56e4a33a7388828f07c Mon Sep 17 00:00:00 2001 From: Max Strasinsky Date: Tue, 14 Jan 2025 16:57:13 +0100 Subject: [PATCH] Update tests --- .../NnsNeuronVotingPowerSection.spec.ts | 42 +++++++++++++++++++ ...NnsNeuronVotingPowerSection.page-object.ts | 6 +++ 2 files changed, 48 insertions(+) diff --git a/frontend/src/tests/lib/components/neuron-detail/NnsNeuronVotingPowerSection.spec.ts b/frontend/src/tests/lib/components/neuron-detail/NnsNeuronVotingPowerSection.spec.ts index 840858f1b8..f9811a9b7e 100644 --- a/frontend/src/tests/lib/components/neuron-detail/NnsNeuronVotingPowerSection.spec.ts +++ b/frontend/src/tests/lib/components/neuron-detail/NnsNeuronVotingPowerSection.spec.ts @@ -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 () => { + 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); + }); }); diff --git a/frontend/src/tests/page-objects/NnsNeuronVotingPowerSection.page-object.ts b/frontend/src/tests/page-objects/NnsNeuronVotingPowerSection.page-object.ts index 611a9d7492..9f9c97f383 100644 --- a/frontend/src/tests/page-objects/NnsNeuronVotingPowerSection.page-object.ts +++ b/frontend/src/tests/page-objects/NnsNeuronVotingPowerSection.page-object.ts @@ -61,4 +61,10 @@ export class NnsNeuronVotingPowerSectionPo extends BasePageObject { clickDisburse(): Promise { return this.getNeuronStateItemActionPo().clickDisburse(); } + + async isReducedVotingPowerStyle(): Promise { + return (await this.root.byTestId("voting-power").getClasses()).includes( + "isReducedVotingPower" + ); + } }