From 0e1dc10dc88216ad8f4d3f945ac32df0c0d31efd Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Fri, 6 Dec 2024 12:39:05 +0100 Subject: [PATCH 1/2] component to accountMenu --- .../lib/components/header/AccountMenu.svelte | 5 +++ .../lib/components/header/AccountMenu.spec.ts | 36 +++++++++++++++++++ .../page-objects/AccountMenu.page-object.ts | 5 +++ 3 files changed, 46 insertions(+) diff --git a/frontend/src/lib/components/header/AccountMenu.svelte b/frontend/src/lib/components/header/AccountMenu.svelte index d6f2244ea78..1d26d497ca4 100644 --- a/frontend/src/lib/components/header/AccountMenu.svelte +++ b/frontend/src/lib/components/header/AccountMenu.svelte @@ -11,6 +11,7 @@ import LoginIconOnly from "./LoginIconOnly.svelte"; import Logout from "./Logout.svelte"; import { IconUser, Popover } from "@dfinity/gix-components"; + import ExportIcpTransactionsButton from "$lib/components/header/ExportIcpTransactionsButton.svelte"; let visible = false; let button: HTMLButtonElement | undefined; @@ -43,6 +44,10 @@ {#if $ENABLE_EXPORT_NEURONS_REPORT} + + {/if} diff --git a/frontend/src/tests/lib/components/header/AccountMenu.spec.ts b/frontend/src/tests/lib/components/header/AccountMenu.spec.ts index 04b3c709608..00de749cd52 100644 --- a/frontend/src/tests/lib/components/header/AccountMenu.spec.ts +++ b/frontend/src/tests/lib/components/header/AccountMenu.spec.ts @@ -160,6 +160,42 @@ describe("AccountMenu", () => { expect(await accountMenuPo.isOpen()).toBe(false); }); }); + + it("should not show the Export ICP Transactions Report button if feature flag is off(by default)", async () => { + const { accountMenuPo } = renderComponent(); + + await accountMenuPo.openMenu(); + + expect( + await accountMenuPo.getExportIcpTransactionsButtonPo().isPresent() + ).toBe(false); + }); + + it("should show Export Icp Transactinos Report button if feature flag is on", async () => { + overrideFeatureFlagsStore.setFlag("ENABLE_EXPORT_NEURONS_REPORT", true); + const { accountMenuPo } = renderComponent(); + + await accountMenuPo.openMenu(); + + expect( + await accountMenuPo.getExportIcpTransactionsButtonPo().isPresent() + ).toBe(true); + }); + + it("should close the menu once the Export Icp Transactions Report button is clicked", async () => { + overrideFeatureFlagsStore.setFlag("ENABLE_EXPORT_NEURONS_REPORT", true); + const { accountMenuPo } = renderComponent(); + + expect(await accountMenuPo.isOpen()).toBe(false); + + await accountMenuPo.openMenu(); + expect(await accountMenuPo.isOpen()).toBe(true); + + await accountMenuPo.getExportIcpTransactionsButtonPo().click(); + await waitFor(async () => { + expect(await accountMenuPo.isOpen()).toBe(false); + }); + }); }); }); }); diff --git a/frontend/src/tests/page-objects/AccountMenu.page-object.ts b/frontend/src/tests/page-objects/AccountMenu.page-object.ts index ac600c7d77d..a2dd8696b08 100644 --- a/frontend/src/tests/page-objects/AccountMenu.page-object.ts +++ b/frontend/src/tests/page-objects/AccountMenu.page-object.ts @@ -1,5 +1,6 @@ import { BasePageObject } from "$tests/page-objects/base.page-object"; import { ButtonPo } from "$tests/page-objects/Button.page-object"; +import { ExportIcpTransactionsButtonPo } from "$tests/page-objects/ExportIcpTransactionsButton.page-object"; import { ExportNeuronsButtonPo } from "$tests/page-objects/ExportNeuronsButton.page-object"; import type { PageObjectElement } from "$tests/types/page-object.types"; import { AccountDetailsPo } from "./AccountDetails.page-object"; @@ -70,4 +71,8 @@ export class AccountMenuPo extends BasePageObject { getExportNeuronsButtonPo(): ExportNeuronsButtonPo { return ExportNeuronsButtonPo.under({ element: this.root }); } + + getExportIcpTransactionsButtonPo(): ExportIcpTransactionsButtonPo { + return ExportIcpTransactionsButtonPo.under({ element: this.root }); + } } From 04bcf925df09c0058628cd6f70fceb5b0fa32b00 Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Fri, 6 Dec 2024 14:50:35 +0100 Subject: [PATCH 2/2] typo --- frontend/src/tests/lib/components/header/AccountMenu.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/tests/lib/components/header/AccountMenu.spec.ts b/frontend/src/tests/lib/components/header/AccountMenu.spec.ts index 00de749cd52..e3c04460049 100644 --- a/frontend/src/tests/lib/components/header/AccountMenu.spec.ts +++ b/frontend/src/tests/lib/components/header/AccountMenu.spec.ts @@ -171,7 +171,7 @@ describe("AccountMenu", () => { ).toBe(false); }); - it("should show Export Icp Transactinos Report button if feature flag is on", async () => { + it("should show Export Icp Transactions Report button if feature flag is on", async () => { overrideFeatureFlagsStore.setFlag("ENABLE_EXPORT_NEURONS_REPORT", true); const { accountMenuPo } = renderComponent();