Skip to content

Commit

Permalink
test: LedgerNeuronHotkeyWarning visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrasinskis committed Dec 20, 2024
1 parent dd321bb commit 533ed51
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
24 changes: 24 additions & 0 deletions frontend/src/tests/lib/pages/NnsWallet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/tests/page-objects/NnsWallet.page-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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");
}
Expand Down

0 comments on commit 533ed51

Please sign in to comment.