From 533ed519d5fb0adfb65740a5d3fccbb331830078 Mon Sep 17 00:00:00 2001 From: Max Strasinsky Date: Fri, 20 Dec 2024 17:04:07 +0100 Subject: [PATCH] test: LedgerNeuronHotkeyWarning visibility --- .../src/tests/lib/pages/NnsWallet.spec.ts | 24 +++++++++++++++++++ .../page-objects/NnsWallet.page-object.ts | 5 ++++ 2 files changed, 29 insertions(+) diff --git a/frontend/src/tests/lib/pages/NnsWallet.spec.ts b/frontend/src/tests/lib/pages/NnsWallet.spec.ts index e1e4c8795b8..70363c0cf10 100644 --- a/frontend/src/tests/lib/pages/NnsWallet.spec.ts +++ b/frontend/src/tests/lib/pages/NnsWallet.spec.ts @@ -59,6 +59,8 @@ import { Principal } from "@dfinity/principal"; import { get } from "svelte/store"; import type { MockInstance } from "vitest"; import AccountsTest from "./AccountsTest.svelte"; +import { overrideFeatureFlagsStore } from "../../../lib/stores/feature-flags.store"; +import { allowLoggingInOneTestForDebugging } from "../../utils/console.test-utils"; vi.mock("$lib/api/nns-dapp.api"); vi.mock("$lib/api/accounts.api"); @@ -408,6 +410,12 @@ describe("NnsWallet", () => { expect(await po.getWalletPageHeadingPo().getTitle()).toBe("4.32 ICP"); }); + it("should not render Ledger neuron hotkey warning for not HW wallet", async () => { + overrideFeatureFlagsStore.setFlag("ENABLE_PERIODIC_FOLLOWING_CONFIRMATION", true); + const po = await renderWallet(props); + expect(await po.getLedgerNeuronHotkeyWarningPo().isBannerVisible()).toBe(false); + }); + it("should reload balance on open", async () => { const oldBalance = 135_000_000n; const oldBalanceFormatted = "1.35 ICP"; @@ -1008,6 +1016,22 @@ describe("NnsWallet", () => { expect(await po.getShowHardwareWalletButtonPo().isPresent()).toBe(true); }); + it("should display Ledger neuron hotkey warning", async () => { + overrideFeatureFlagsStore.setFlag("ENABLE_PERIODIC_FOLLOWING_CONFIRMATION", true); + const po = await renderWallet(props); + allowLoggingInOneTestForDebugging(); + + expect(await po.getLedgerNeuronHotkeyWarningPo().isBannerVisible()).toBe(true); + }); + + it("should not display Ledger neuron hotkey warning when feature flag off", async () => { + overrideFeatureFlagsStore.setFlag("ENABLE_PERIODIC_FOLLOWING_CONFIRMATION", false); + const po = await renderWallet(props); + allowLoggingInOneTestForDebugging(); + + expect(await po.getLedgerNeuronHotkeyWarningPo().isBannerVisible()).toBe(false); + }); + describe("when there are staking transactions", () => { const neuronController = testHwPrincipal; const memo = 54321n; diff --git a/frontend/src/tests/page-objects/NnsWallet.page-object.ts b/frontend/src/tests/page-objects/NnsWallet.page-object.ts index 72f83015bf1..4747e37e625 100644 --- a/frontend/src/tests/page-objects/NnsWallet.page-object.ts +++ b/frontend/src/tests/page-objects/NnsWallet.page-object.ts @@ -6,6 +6,7 @@ import { WalletPageHeaderPo } from "$tests/page-objects/WalletPageHeader.page-ob import { WalletPageHeadingPo } from "$tests/page-objects/WalletPageHeading.page-object"; import { BasePageObject } from "$tests/page-objects/base.page-object"; import type { PageObjectElement } from "$tests/types/page-object.types"; +import { LedgerNeuronHotkeyWarningPo } from "./LedgerNeuronHotkeyWarning.page-object"; import { UiTransactionsListPo } from "./UiTransactionsList.page-object"; export class NnsWalletPo extends BasePageObject { @@ -51,6 +52,10 @@ export class NnsWalletPo extends BasePageObject { return this.getButton("ledger-list-button"); } + getLedgerNeuronHotkeyWarningPo(): LedgerNeuronHotkeyWarningPo { + return LedgerNeuronHotkeyWarningPo.under(this.root); + } + getShowHardwareWalletButtonPo(): ButtonPo { return this.getButton("ledger-show-button"); }