Skip to content

Commit

Permalink
Hide the banner behind the feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrasinskis committed Dec 23, 2024
1 parent fb3f8d5 commit 7f2cde4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frontend/src/lib/components/neurons/AddUserToHotkeys.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import type { NeuronId } from "@dfinity/nns";
import { createEventDispatcher } from "svelte";
import CalloutWarning from "$lib/components/common/CalloutWarning.svelte";
import { ENABLE_PERIODIC_FOLLOWING_CONFIRMATION } from "$lib/stores/feature-flags.store";
export let account: Account;
export let neuronId: NeuronId;
Expand All @@ -31,7 +32,9 @@
</script>

<div class="wrapper" data-tid="add-principal-to-hotkeys-modal">
<CalloutWarning htmlText={$i18n.losing_rewards.hw_create_neuron_warning} />
{#if $ENABLE_PERIODIC_FOLLOWING_CONFIRMATION}
<CalloutWarning htmlText={$i18n.losing_rewards.hw_create_neuron_warning} />
{/if}

<p class="description">{$i18n.neurons.add_user_as_hotkey_message}</p>

Expand Down
29 changes: 29 additions & 0 deletions frontend/src/tests/lib/modals/neurons/NnsStakeNeuronModal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
stakeNeuron,
updateDelay,
} from "$lib/services/neurons.services";
import { overrideFeatureFlagsStore } from "$lib/stores/feature-flags.store";
import { neuronsStore } from "$lib/stores/neurons.store";
import { mockIdentity, resetIdentity } from "$tests/mocks/auth.store.mock";
import {
Expand Down Expand Up @@ -443,6 +444,34 @@ describe("NnsStakeNeuronModal", () => {
expect(addHotkeyForHardwareWalletNeuron).not.toBeCalled();
});

it("should display missing rewards warning when feature flag on", async () => {
overrideFeatureFlagsStore.setFlag(
"ENABLE_PERIODIC_FOLLOWING_CONFIRMATION",
true
);
const po = await renderComponent({});
await createNeuron(po);

expect(await po.getAddUserToHotkeysPo().isPresent()).toBe(true);
expect(
await po.getAddUserToHotkeysPo().isMissingRewardsWarningVisible()
).toBe(true);
});

it("should not display missing rewards warning when feature flag off", async () => {
overrideFeatureFlagsStore.setFlag(
"ENABLE_PERIODIC_FOLLOWING_CONFIRMATION",
false
);
const po = await renderComponent({});
await createNeuron(po);

expect(await po.getAddUserToHotkeysPo().isPresent()).toBe(true);
expect(
await po.getAddUserToHotkeysPo().isMissingRewardsWarningVisible()
).toBe(false);
});

it("should create neuron for hardwareWallet and add dissolve delay", async () => {
neuronsStore.setNeurons({ neurons: [newNeuron], certified: true });
const po = await renderComponent({});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CalloutWarningPo } from "$tests/page-objects/CalloutWarning.page-object";
import { BasePageObject } from "$tests/page-objects/base.page-object";
import type { PageObjectElement } from "$tests/types/page-object.types";

Expand All @@ -8,6 +9,10 @@ export class AddUserToHotkeysPo extends BasePageObject {
return new AddUserToHotkeysPo(element.byTestId(AddUserToHotkeysPo.TID));
}

isMissingRewardsWarningVisible(): Promise<boolean> {
return CalloutWarningPo.under(this.root).isPresent();
}

clickSkip(): Promise<void> {
return this.click("skip-add-principal-to-hotkey-modal");
}
Expand Down

0 comments on commit 7f2cde4

Please sign in to comment.