From 734e1f7e6dd8a848a3ae77aee45a52a3dfd7aafd Mon Sep 17 00:00:00 2001 From: Max Strasinsky Date: Fri, 11 Oct 2024 14:36:14 +0200 Subject: [PATCH] Update tests --- .../src/lib/components/accounts/ImportTokenForm.svelte | 2 +- .../lib/components/accounts/ImportTokenForm.spec.ts | 9 +++++++-- frontend/src/tests/lib/pages/IcrcWallet.spec.ts | 6 ++++++ .../tests/page-objects/ImportTokenForm.page-object.ts | 8 ++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/components/accounts/ImportTokenForm.svelte b/frontend/src/lib/components/accounts/ImportTokenForm.svelte index 2ffdd974c31..0cda94b5d8b 100644 --- a/frontend/src/lib/components/accounts/ImportTokenForm.svelte +++ b/frontend/src/lib/components/accounts/ImportTokenForm.svelte @@ -27,7 +27,7 @@
dispatch("nnsSubmit")}> {#if addIndexCanisterMode} diff --git a/frontend/src/tests/lib/components/accounts/ImportTokenForm.spec.ts b/frontend/src/tests/lib/components/accounts/ImportTokenForm.spec.ts index f7a990e4b7e..e41d0c33934 100644 --- a/frontend/src/tests/lib/components/accounts/ImportTokenForm.spec.ts +++ b/frontend/src/tests/lib/components/accounts/ImportTokenForm.spec.ts @@ -163,13 +163,18 @@ describe("ImportTokenForm", () => { }); it("should display addIndexCanister mode ", async () => { + const ledgerCanisterId = principal(0); const { po } = renderComponent({ - ledgerCanisterId: principal(0), + ledgerCanisterId, indexCanisterId: undefined, addIndexCanisterMode: true, }); - expect(await po.getLedgerCanisterInputPo().isDisabled()).toEqual(true); + expect(await po.getLedgerCanisterInputPo().isPresent()).toEqual(false); + expect(await po.getLedgerCanisterIdPo().isPresent()).toEqual(true); + expect(await po.getLedgerCanisterIdPo().getCanisterIdText()).toEqual( + ledgerCanisterId.toText() + ); expect(await po.getIndexCanisterInputPo().isRequired()).toEqual(true); expect((await po.getIndexCanisterInputPo().getText()).trim()).toEqual( "Index Canister ID" diff --git a/frontend/src/tests/lib/pages/IcrcWallet.spec.ts b/frontend/src/tests/lib/pages/IcrcWallet.spec.ts index 34c6936e764..43f8df70785 100644 --- a/frontend/src/tests/lib/pages/IcrcWallet.spec.ts +++ b/frontend/src/tests/lib/pages/IcrcWallet.spec.ts @@ -729,6 +729,12 @@ describe("IcrcWallet", () => { expect(spyOnSetImportedTokens).toBeCalledTimes(0); expect(await addIndexCanisterModalPo.isPresent()).toBe(true); expect(get(busyStore)).toEqual([]); + expect( + await addIndexCanisterModalPo + .getImportTokenFormPo() + .getLedgerCanisterIdPo() + .getCanisterIdText() + ).toEqual(ledgerCanisterId.toText()); await addIndexCanisterModalPo.typeIndexCanisterId( indexCanisterId.toText() diff --git a/frontend/src/tests/page-objects/ImportTokenForm.page-object.ts b/frontend/src/tests/page-objects/ImportTokenForm.page-object.ts index c73af5c63db..c7529c31027 100644 --- a/frontend/src/tests/page-objects/ImportTokenForm.page-object.ts +++ b/frontend/src/tests/page-objects/ImportTokenForm.page-object.ts @@ -1,5 +1,6 @@ import { ButtonPo } from "$tests/page-objects/Button.page-object"; import { CalloutWarningPo } from "$tests/page-objects/CalloutWarning.page-object"; +import { ImportTokenCanisterIdPo } from "$tests/page-objects/ImportTokenCanisterId.page-object"; import { InputWithErrorPo } from "$tests/page-objects/InputWithError.page-object"; import { BasePageObject } from "$tests/page-objects/base.page-object"; import type { PageObjectElement } from "$tests/types/page-object.types"; @@ -18,6 +19,13 @@ export class ImportTokenFormPo extends BasePageObject { }); } + getLedgerCanisterIdPo(): ImportTokenCanisterIdPo { + return ImportTokenCanisterIdPo.under({ + element: this.root, + testId: "ledger-canister-id-view", + }); + } + getIndexCanisterInputPo(): InputWithErrorPo { return InputWithErrorPo.under({ element: this.root,