diff --git a/frontend/src/tests/lib/modals/sns/SnsDisburseMaturityModal.spec.ts b/frontend/src/tests/lib/modals/sns/SnsDisburseMaturityModal.spec.ts index 57bf5e256eb..4ab3dc059b5 100644 --- a/frontend/src/tests/lib/modals/sns/SnsDisburseMaturityModal.spec.ts +++ b/frontend/src/tests/lib/modals/sns/SnsDisburseMaturityModal.spec.ts @@ -13,6 +13,7 @@ import { import { mockSnsToken, principal } from "$tests/mocks/sns-projects.mock"; import { DisburseMaturityModalPo } from "$tests/page-objects/DisburseMaturityModal.page-object"; import { JestPageObjectElement } from "$tests/page-objects/jest.page-object"; +import { resetSnsProjects, setSnsProjects } from "$tests/utils/sns.test-utils"; import { decodeIcrcAccount } from "@dfinity/ledger-icrc"; import type { SnsNeuron } from "@dfinity/sns"; import { nonNullish } from "@dfinity/utils"; @@ -41,11 +42,15 @@ describe("SnsDisburseMaturityModal", () => { beforeEach(() => { vi.clearAllMocks(); + resetSnsProjects(); + authStore.setForTesting(mockIdentity); - tokensStore.setToken({ - canisterId: rootCanisterId, - token: mockSnsToken, - }); + setSnsProjects([ + { + rootCanisterId, + tokenMetadata: mockSnsToken, + }, + ]); snsAccountsStore.setAccounts({ rootCanisterId, accounts: [mockSnsMainAccount], diff --git a/frontend/src/tests/lib/modals/sns/SnsIncreaseStakeNeuronModal.spec.ts b/frontend/src/tests/lib/modals/sns/SnsIncreaseStakeNeuronModal.spec.ts index b95e90374df..e505a401934 100644 --- a/frontend/src/tests/lib/modals/sns/SnsIncreaseStakeNeuronModal.spec.ts +++ b/frontend/src/tests/lib/modals/sns/SnsIncreaseStakeNeuronModal.spec.ts @@ -1,10 +1,7 @@ import { AppPath } from "$lib/constants/routes.constants"; import SnsIncreaseStakeNeuronModal from "$lib/modals/sns/neurons/SnsIncreaseStakeNeuronModal.svelte"; -import { loadSnsAccounts } from "$lib/services/sns-accounts.services"; import { increaseStakeNeuron } from "$lib/services/sns-neurons.services"; -import { startBusy } from "$lib/stores/busy.store"; import { snsAccountsStore } from "$lib/stores/sns-accounts.store"; -import { tokensStore } from "$lib/stores/tokens.store"; import { page } from "$mocks/$app/stores"; import { mockPrincipal, @@ -22,12 +19,7 @@ import { import { setSnsProjects } from "$tests/utils/sns.test-utils"; import { SnsSwapLifecycle } from "@dfinity/sns"; import { ICPToken } from "@dfinity/utils"; -import { - fireEvent, - render, - waitFor, - type RenderResult, -} from "@testing-library/svelte"; +import { fireEvent, waitFor, type RenderResult } from "@testing-library/svelte"; import type { SvelteComponent } from "svelte"; vi.mock("$lib/services/sns-neurons.services", () => { @@ -55,6 +47,7 @@ describe("SnsIncreaseStakeNeuronModal", () => { const snsProjectParams = { lifecycle: SnsSwapLifecycle.Committed, rootCanisterId, + tokenMetadata: mockSnsToken, }; const props = { @@ -82,37 +75,6 @@ describe("SnsIncreaseStakeNeuronModal", () => { setSnsProjects([snsProjectParams]); }); - describe("accounts and params are not loaded", () => { - beforeEach(() => { - snsAccountsStore.reset(); - tokensStore.reset(); - }); - - it("should not display modal", async () => { - const { container } = await render(SnsIncreaseStakeNeuronModal, { - props, - }); - - expect(container.querySelector("div.modal")).toBeNull(); - }); - - it("should call sync sns accounts on init", async () => { - await render(SnsIncreaseStakeNeuronModal, { - props, - }); - - expect(loadSnsAccounts).toBeCalled(); - }); - - it("should display a spinner on init", async () => { - await render(SnsIncreaseStakeNeuronModal, { - props, - }); - - expect(startBusy).toHaveBeenCalled(); - }); - }); - describe("accounts and params are loaded", () => { beforeEach(() => { snsAccountsStore.setAccounts({ @@ -120,10 +82,6 @@ describe("SnsIncreaseStakeNeuronModal", () => { accounts: [mockSnsMainAccount], certified: true, }); - tokensStore.setToken({ - canisterId: rootCanisterId, - token: mockSnsToken, - }); }); it("should display modal", async () => { diff --git a/frontend/src/tests/lib/services/_public/sns.services.spec.ts b/frontend/src/tests/lib/services/_public/sns.services.spec.ts index f41db8c16c7..2b2f9644a9b 100644 --- a/frontend/src/tests/lib/services/_public/sns.services.spec.ts +++ b/frontend/src/tests/lib/services/_public/sns.services.spec.ts @@ -21,7 +21,6 @@ import { aggregatorMockSnsesDataDto, aggregatorSnsMockDto, aggregatorSnsMockWith, - aggregatorTokenMock, } from "$tests/mocks/sns-aggregator.mock"; import { nervousSystemFunctionMock } from "$tests/mocks/sns-functions.mock"; import { principal } from "$tests/mocks/sns-projects.mock"; @@ -237,27 +236,6 @@ describe("SNS public services", () => { expect(get(snsAggregatorStore).data).toEqual(aggregatorMockSnsesDataDto); }); - it("should load and map tokens", async () => { - vi.spyOn(aggregatorApi, "querySnsProjects").mockImplementation(() => - Promise.resolve([aggregatorSnsMockDto, aggregatorSnsMockDto]) - ); - - await loadSnsProjects(); - - const ledgerCanisterId = - aggregatorSnsMockDto.canister_ids.ledger_canister_id; - - const tokens = get(tokensStore); - const token = tokens[ledgerCanisterId]; - expect(token).not.toBeUndefined(); - expect(token?.certified).toBeTruthy(); - expect(token?.token).toEqual(aggregatorTokenMock); - - const rootCanisterId = aggregatorSnsMockDto.canister_ids.root_canister_id; - const tokenForRootCanister = tokens[rootCanisterId]; - expect(tokenForRootCanister).toEqual(token); - }); - it("should load and map total token supply", async () => { const rootCanisterId = principal(0); const totalSupply = 2_000_000_000; diff --git a/frontend/src/tests/routes/app/tokens/page.spec.ts b/frontend/src/tests/routes/app/tokens/page.spec.ts index cbf7e3be2ab..b76045f4ee6 100644 --- a/frontend/src/tests/routes/app/tokens/page.spec.ts +++ b/frontend/src/tests/routes/app/tokens/page.spec.ts @@ -162,23 +162,16 @@ describe("Tokens route", () => { { rootCanisterId: rootCanisterIdTetris, projectName: "Tetris", + tokenMetadata: tetrisToken, lifecycle: SnsSwapLifecycle.Committed, }, { rootCanisterId: rootCanisterIdPacman, projectName: "Pacman", + tokenMetadata: pacmanToken, lifecycle: SnsSwapLifecycle.Committed, }, ]); - // Tokens are loaded in SNS aggregator - tokensStore.setTokens({ - [rootCanisterIdTetris.toText()]: { - token: tetrisToken, - }, - [rootCanisterIdPacman.toText()]: { - token: pacmanToken, - }, - }); setCkETHCanisters(); icpAccountsStore.setForTesting({ main: { ...mockMainAccount, balanceUlps: icpBalanceE8s },