diff --git a/frontend/src/routes/(app)/(nns)/portfolio/+page.svelte b/frontend/src/routes/(app)/(nns)/portfolio/+page.svelte index 746442d6b7..e0883f5546 100644 --- a/frontend/src/routes/(app)/(nns)/portfolio/+page.svelte +++ b/frontend/src/routes/(app)/(nns)/portfolio/+page.svelte @@ -13,7 +13,6 @@ loadSnsAccountsBalances, resetBalanceLoading, } from "$lib/services/accounts-balances.services"; - import { loadCkBTCTokens } from "$lib/services/ckbtc-tokens.services"; import { loadIcpSwapTickers } from "$lib/services/icp-swap.services"; import { neuronsStore } from "$lib/stores/neurons.store"; import { snsNeuronsStore } from "$lib/stores/sns-neurons.store"; @@ -25,8 +24,6 @@ let tableProjects: TableProject[] = []; resetBalanceLoading(); - // maybe I can get rid of it as this is load when calling the loadAccountsBalances - loadCkBTCTokens(); loadIcpSwapTickers(); $: if ($authSignedInStore) { diff --git a/frontend/src/tests/routes/app/portfolio/page.spec.ts b/frontend/src/tests/routes/app/portfolio/page.spec.ts index 27b1f4e56f..bec555c44e 100644 --- a/frontend/src/tests/routes/app/portfolio/page.spec.ts +++ b/frontend/src/tests/routes/app/portfolio/page.spec.ts @@ -35,7 +35,6 @@ import { setAccountsForTesting } from "$tests/utils/accounts.test-utils"; import { setCkETHCanisters } from "$tests/utils/cketh.test-utils"; import { setSnsProjects } from "$tests/utils/sns.test-utils"; import { runResolvedPromises } from "$tests/utils/timers.test-utils"; -import { AnonymousIdentity } from "@dfinity/agent"; import { SnsSwapLifecycle } from "@dfinity/sns"; import { render } from "@testing-library/svelte"; import { get } from "svelte/store"; @@ -62,38 +61,6 @@ describe("Portfolio route", () => { beforeEach(() => { vi.spyOn(icpSwapApi, "queryIcpSwapTickers").mockResolvedValue(tickers); - vi.spyOn(icrcLedgerApi, "queryIcrcToken").mockImplementation( - async ({ canisterId }) => { - const tokenMap = { - [CKBTC_UNIVERSE_CANISTER_ID.toText()]: mockCkBTCToken, - [CKTESTBTC_UNIVERSE_CANISTER_ID.toText()]: mockCkTESTBTCToken, - [CKETH_UNIVERSE_CANISTER_ID.toText()]: mockCkETHToken, - [CKUSDC_UNIVERSE_CANISTER_ID.toText()]: mockCkUSDCToken, - }; - return tokenMap[canisterId.toText()]; - } - ); - }); - - it.skip("should load CkBTC tokens", async () => { - const identity = new AnonymousIdentity(); - - expect(icrcLedgerApi.queryIcrcToken).toBeCalledTimes(0); - - await renderPage(); - - expect(icrcLedgerApi.queryIcrcToken).toBeCalledTimes(2); - expect(icrcLedgerApi.queryIcrcToken).toHaveBeenNthCalledWith(1, { - canisterId: CKBTC_UNIVERSE_CANISTER_ID, - certified: false, - identity, - }); - - expect(icrcLedgerApi.queryIcrcToken).toHaveBeenNthCalledWith(2, { - canisterId: CKTESTBTC_UNIVERSE_CANISTER_ID, - certified: false, - identity, - }); }); it("should load ICP Swap tickers", async () => { @@ -124,6 +91,18 @@ describe("Portfolio route", () => { beforeEach(() => { resetIdentity(); + vi.spyOn(icrcLedgerApi, "queryIcrcToken").mockImplementation( + async ({ canisterId }) => { + const tokenMap = { + [CKBTC_UNIVERSE_CANISTER_ID.toText()]: mockCkBTCToken, + [CKTESTBTC_UNIVERSE_CANISTER_ID.toText()]: mockCkTESTBTCToken, + [CKETH_UNIVERSE_CANISTER_ID.toText()]: mockCkETHToken, + [CKUSDC_UNIVERSE_CANISTER_ID.toText()]: mockCkUSDCToken, + }; + return tokenMap[canisterId.toText()]; + } + ); + vi.spyOn(icrcLedgerApi, "queryIcrcBalance").mockImplementation( async ({ canisterId }) => { const balancesMap = { @@ -152,6 +131,27 @@ describe("Portfolio route", () => { setSnsProjects([tetrisSNS]); }); + it("should load all ckBtc tokens", async () => { + const identity = mockIdentity; + + expect(icrcLedgerApi.queryIcrcToken).toBeCalledTimes(0); + + await renderPage(); + + expect(icrcLedgerApi.queryIcrcToken).toBeCalledTimes(2); + expect(icrcLedgerApi.queryIcrcToken).toHaveBeenNthCalledWith(1, { + canisterId: CKBTC_UNIVERSE_CANISTER_ID, + certified: false, + identity, + }); + + expect(icrcLedgerApi.queryIcrcToken).toHaveBeenNthCalledWith(2, { + canisterId: CKTESTBTC_UNIVERSE_CANISTER_ID, + certified: false, + identity, + }); + }); + it("should load all accounts balances for both ckBTC and icrc(ckETH, ckUSDC, Tetris(SNS token))", async () => { const identity = mockIdentity; const account = { @@ -205,7 +205,6 @@ describe("Portfolio route", () => { setAccountsForTesting({ main: { ...mockMainAccount, balanceUlps: icpBalanceE8s }, }); - vi.spyOn(icrcLedgerApi, "icrcTransfer").mockResolvedValue(1234n); icpSwapTickersStore.set([ { ...mockIcpSwapTicker,