diff --git a/frontend/src/lib/components/neuron-detail/NnsNeuronRewardStatusAction.svelte b/frontend/src/lib/components/neuron-detail/NnsNeuronRewardStatusAction.svelte index f84dad3daa..73f5f4d094 100644 --- a/frontend/src/lib/components/neuron-detail/NnsNeuronRewardStatusAction.svelte +++ b/frontend/src/lib/components/neuron-detail/NnsNeuronRewardStatusAction.svelte @@ -10,6 +10,7 @@ isNeuronMissingReward, secondsUntilMissingReward, isNeuronMissingRewardsSoon, + hasEnoughDissolveDelayToVote, } from "$lib/utils/neuron.utils"; import { IconCheckCircleFill, @@ -96,7 +97,7 @@ }; -{#if nonNullish($startReducingVotingPowerAfterSecondsStore) && nonNullish($clearFollowingAfterSecondsStore)} +{#if hasEnoughDissolveDelayToVote(neuron) && nonNullish($startReducingVotingPowerAfterSecondsStore) && nonNullish($clearFollowingAfterSecondsStore)} { }); it("should render active neuron state", async () => { - const testNeuron = { + const testNeuron: NeuronInfo = { ...mockNeuron, + dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR), fullNeuron: { ...mockFullNeuron, votingPowerRefreshedTimestampSeconds: BigInt(nowInSeconds()), @@ -54,9 +55,24 @@ describe("NnsNeuronRewardStatusAction", () => { expect(await po.getFollowNeuronsButtonPo().isPresent()).toBe(false); }); + it("should not render active neuron state when neuron dissolve delay is too low for voting", async () => { + const testNeuron: NeuronInfo = { + ...mockNeuron, + dissolveDelaySeconds: 0n, + fullNeuron: { + ...mockFullNeuron, + votingPowerRefreshedTimestampSeconds: BigInt(nowInSeconds()), + }, + }; + const po = renderComponent(testNeuron); + + expect(await po.isPresent()).toBe(false); + }); + it("should not render active neuron state w/o voting power economics params", async () => { - const testNeuron = { + const testNeuron: NeuronInfo = { ...mockNeuron, + dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR), fullNeuron: { ...mockFullNeuron, votingPowerRefreshedTimestampSeconds: BigInt(nowInSeconds()), @@ -70,8 +86,9 @@ describe("NnsNeuronRewardStatusAction", () => { it("should render losing soon neuron state", async () => { const tenDays = 10; - const testNeuron = { + const testNeuron: NeuronInfo = { ...mockNeuron, + dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR), fullNeuron: { ...mockFullNeuron, votingPowerRefreshedTimestampSeconds: BigInt( @@ -90,8 +107,9 @@ describe("NnsNeuronRewardStatusAction", () => { }); it("should render inactive neuron reward state", async () => { - const testNeuron = { + const testNeuron: NeuronInfo = { ...mockNeuron, + dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR), fullNeuron: { ...mockFullNeuron, votingPowerRefreshedTimestampSeconds: BigInt( @@ -110,8 +128,9 @@ describe("NnsNeuronRewardStatusAction", () => { }); it("should render inactive/reset following neuron reward state", async () => { - const testNeuron = { + const testNeuron: NeuronInfo = { ...mockNeuron, + dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR), fullNeuron: { ...mockFullNeuron, votingPowerRefreshedTimestampSeconds: BigInt( 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 2b1cb14bdd..a076484c32 100644 --- a/frontend/src/tests/lib/components/neuron-detail/NnsNeuronVotingPowerSection.spec.ts +++ b/frontend/src/tests/lib/components/neuron-detail/NnsNeuronVotingPowerSection.spec.ts @@ -1,4 +1,5 @@ import NnsNeuronVotingPowerSection from "$lib/components/neuron-detail/NnsNeuronVotingPowerSection.svelte"; +import { SECONDS_IN_HALF_YEAR } from "$lib/constants/constants"; import { NNS_MINIMUM_DISSOLVE_DELAY_TO_VOTE } from "$lib/constants/neurons.constants"; import { overrideFeatureFlagsStore } from "$lib/stores/feature-flags.store"; import { networkEconomicsStore } from "$lib/stores/network-economics.store"; @@ -140,7 +141,10 @@ describe("NnsStakeItemAction", () => { }); it("should render item actions", async () => { - const po = renderComponent(mockNeuron); + const po = renderComponent({ + ...mockNeuron, + dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR), + }); expect(await po.hasStakeItemAction()).toBe(true); expect(await po.hasNeuronStateItemAction()).toBe(true); @@ -156,7 +160,10 @@ describe("NnsStakeItemAction", () => { parameters: mockNetworkEconomics, certified: true, }); - const po = renderComponent(mockNeuron); + const po = renderComponent({ + ...mockNeuron, + dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR), + }); expect(await po.getNnsNeuronRewardStatusActionPo().isPresent()).toBe(true); }); @@ -166,7 +173,10 @@ describe("NnsStakeItemAction", () => { "ENABLE_PERIODIC_FOLLOWING_CONFIRMATION", false ); - const po = renderComponent(mockNeuron); + const po = renderComponent({ + ...mockNeuron, + dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR), + }); expect(await po.getNnsNeuronRewardStatusActionPo().isPresent()).toBe(false); }); diff --git a/frontend/src/tests/lib/pages/NnsNeuronDetail.spec.ts b/frontend/src/tests/lib/pages/NnsNeuronDetail.spec.ts index 2753846527..40e3aa65fe 100644 --- a/frontend/src/tests/lib/pages/NnsNeuronDetail.spec.ts +++ b/frontend/src/tests/lib/pages/NnsNeuronDetail.spec.ts @@ -233,10 +233,10 @@ describe("NeuronDetail", () => { ); const testNeuron = fakeGovernanceApi.addNeuronWith({ neuronId, + dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR), votingPowerRefreshedTimestampSeconds: nowInSeconds() - SECONDS_IN_HALF_YEAR - SECONDS_IN_DAY, controller: mockIdentity.getPrincipal().toText(), - dissolveDelaySeconds, }); vi.spyOn(governanceApi, "queryNeurons").mockResolvedValue([testNeuron]);