Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NNS1-3480: adds ExportIcpTransactionsButton to AccountMenu #5926

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frontend/src/lib/components/header/AccountMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -43,6 +44,10 @@

{#if $ENABLE_EXPORT_NEURONS_REPORT}
yhabib marked this conversation as resolved.
Show resolved Hide resolved
<ExportNeuronsButton on:nnsExportNeuronsCsvTriggered={toggle} />

<ExportIcpTransactionsButton
on:nnsExportIcpTransactionsCsvTriggered={toggle}
/>
{/if}

<Logout on:nnsLogoutTriggered={toggle} />
Expand Down
36 changes: 36 additions & 0 deletions frontend/src/tests/lib/components/header/AccountMenu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
yhabib marked this conversation as resolved.
Show resolved Hide resolved
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);
});
});
});
});
});
5 changes: 5 additions & 0 deletions frontend/src/tests/page-objects/AccountMenu.page-object.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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 });
}
}
Loading