From b838cb2f8843d789aeff0381709b5e0cb52e8628 Mon Sep 17 00:00:00 2001 From: Victor Alber Date: Wed, 15 Jan 2025 14:04:23 +0100 Subject: [PATCH] =?UTF-8?q?test:=20=E2=9C=85=20adding=20ENS=20test=20+=20u?= =?UTF-8?q?pdate=20NFT=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/page/modal/send.modal.ts | 13 ++- .../tests/page/swap.page.ts | 2 +- .../tests/specs/speculos/delegate.spec.ts | 20 +---- .../tests/specs/speculos/nft.spec.ts | 2 +- .../tests/specs/speculos/send.tx.spec.ts | 86 +++++++++++++++++-- .../src/e2e/enum/Account.ts | 10 +-- .../src/e2e/families/evm.ts | 9 +- libs/ledger-live-common/src/e2e/speculos.ts | 1 + 8 files changed, 103 insertions(+), 40 deletions(-) diff --git a/apps/ledger-live-desktop/tests/page/modal/send.modal.ts b/apps/ledger-live-desktop/tests/page/modal/send.modal.ts index f61454bfef06..3ce092d9b763 100644 --- a/apps/ledger-live-desktop/tests/page/modal/send.modal.ts +++ b/apps/ledger-live-desktop/tests/page/modal/send.modal.ts @@ -50,7 +50,14 @@ export class SendModal extends Modal { @step("Enter recipient and tag") async fillRecipientInfo(transaction: Transaction) { - await this.fillRecipient(transaction.accountToCredit.address); + if (transaction.accountToCredit.ensName) { + await this.fillRecipient(transaction.accountToCredit.ensName); + const displayedAddress = await this.ENSAddressLabel.innerText(); + expect(displayedAddress).toEqual(transaction.accountToCredit.address); + } else { + await this.fillRecipient(transaction.accountToCredit.address); + } + if (transaction.memoTag && transaction.memoTag !== "noTag") { await this.tagInput.clear(); await this.tagInput.fill(transaction.memoTag); @@ -103,6 +110,10 @@ export class SendModal extends Modal { const displayedAmount = await this.amountDisplayedValue.innerText(); expect(displayedAmount).toEqual(expect.stringContaining(tx.amount)); + if (tx.accountToCredit.ensName) { + const displayedEns = await this.recipientEnsDisplayed.innerText(); + expect(displayedEns).toEqual(tx.accountToCredit.ensName); + } } @step("Verify tx sent text") diff --git a/apps/ledger-live-desktop/tests/page/swap.page.ts b/apps/ledger-live-desktop/tests/page/swap.page.ts index 46c18281e2fb..87dc9111d35f 100644 --- a/apps/ledger-live-desktop/tests/page/swap.page.ts +++ b/apps/ledger-live-desktop/tests/page/swap.page.ts @@ -147,7 +147,7 @@ export class SwapPage extends AppPage { @step("Click Exchange button") async clickExchangeButton(electronApp: ElectronApplication, provider: string) { const [, webview] = electronApp.windows(); - await webview.getByText(`Swap with ${provider}`).click(); + await webview.getByRole("button", { name: `Swap with ${provider}` }).click(); } async confirmExchange() { diff --git a/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts index ce24bf407fbc..da1721c40073 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts @@ -1,7 +1,7 @@ import { test } from "../../fixtures/common"; import { Account } from "@ledgerhq/live-common/e2e/enum/Account"; import { Delegate } from "@ledgerhq/live-common/e2e/models/Delegate"; -import { addTmsLink, addBugLink } from "tests/utils/allureUtils"; +import { addTmsLink } from "tests/utils/allureUtils"; import { getDescription } from "../../utils/customJsonReporter"; import { CLI } from "tests/utils/cliUtils"; import { Currency } from "@ledgerhq/live-common/e2e/enum/Currency"; @@ -11,7 +11,6 @@ const e2eDelegationAccounts = [ { delegate: new Delegate(Account.ATOM_1, "0.001", "Ledger"), xrayTicket: "B2CQA-2740, B2CQA-2770", - bugTicket: "LIVE-14501", }, { delegate: new Delegate(Account.SOL_1, "0.001", "Ledger by Figment"), @@ -39,7 +38,6 @@ const validators = [ { delegate: new Delegate(Account.ADA_1, "0.01", "LBF3 - Ledger by Figment 3"), xrayTicket: "B2CQA-2766", - bugTicket: "LIVE-15536", }, { delegate: new Delegate(Account.MULTIVERS_X_1, "1", "Ledger by Figment"), @@ -72,16 +70,10 @@ test.describe("Delegate flows", () => { test( `[${account.delegate.account.currency.name}] Delegate`, { - annotation: [ - { type: "TMS", description: account.xrayTicket }, - { type: "BUG", description: account.bugTicket }, - ], + annotation: { type: "TMS", description: account.xrayTicket }, }, async ({ app }) => { await addTmsLink(getDescription(test.info().annotations, "TMS").split(", ")); - if (account.bugTicket) { - await addBugLink(getDescription(test.info().annotations, "BUG").split(", ")); - } await app.layout.goToAccounts(); await app.accounts.navigateToAccountByName(account.delegate.account.accountName); @@ -137,16 +129,10 @@ test.describe("Delegate flows", () => { test( `[${validator.delegate.account.currency.name}] - Select validator`, { - annotation: [ - { type: "TMS", description: validator.xrayTicket }, - { type: "BUG", description: validator.bugTicket }, - ], + annotation: { type: "TMS", description: validator.xrayTicket }, }, async ({ app }) => { await addTmsLink(getDescription(test.info().annotations, "TMS").split(", ")); - if (validator.bugTicket) { - await addBugLink(getDescription(test.info().annotations, "BUG").split(", ")); - } await app.layout.goToAccounts(); await app.accounts.navigateToAccountByName(validator.delegate.account.accountName); diff --git a/apps/ledger-live-desktop/tests/specs/speculos/nft.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/nft.spec.ts index d70af1c4646d..f6128199ecb1 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/nft.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/nft.spec.ts @@ -14,7 +14,7 @@ test.describe("send NFT to ENS address", () => { test.beforeAll(async () => { process.env.DISABLE_TRANSACTION_BROADCAST = "1"; }); - const transaction = new NFTTransaction(Account.ETH_1, Account.ETH_MC, Nft.PODIUM, Fee.SLOW); + const transaction = new NFTTransaction(Account.ETH_1, Account.ETH_2, Nft.PODIUM, Fee.SLOW); test.use({ userdata: "skip-onboarding", cliCommands: [ diff --git a/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts index 68073f397606..1fbc251d8631 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts @@ -3,7 +3,7 @@ import { Account } from "@ledgerhq/live-common/e2e/enum/Account"; import { Fee } from "@ledgerhq/live-common/e2e/enum/Fee"; import { TransactionStatus } from "@ledgerhq/live-common/e2e/enum/TransactionStatus"; import { Transaction } from "@ledgerhq/live-common/e2e/models/Transaction"; -import { addTmsLink, addBugLink } from "tests/utils/allureUtils"; +import { addTmsLink } from "tests/utils/allureUtils"; import { getDescription } from "../../utils/customJsonReporter"; import { CLI } from "tests/utils/cliUtils"; import { getEnv } from "@ledgerhq/live-env"; @@ -152,7 +152,6 @@ const transactionE2E = [ { transaction: new Transaction(Account.POL_1, Account.POL_2, "0.001", Fee.SLOW), xrayTicket: "B2CQA-2807", - bugTicket: "BACK-8150", }, { transaction: new Transaction(Account.DOGE_1, Account.DOGE_2, "0.01", Fee.SLOW), @@ -248,16 +247,10 @@ test.describe("Send flows", () => { test( `Send from ${transaction.transaction.accountToDebit.accountName} to ${transaction.transaction.accountToCredit.accountName}`, { - annotation: [ - { type: "TMS", description: transaction.xrayTicket }, - { type: "BUG", description: transaction.bugTicket }, - ], + annotation: { type: "TMS", description: transaction.xrayTicket }, }, async ({ app }) => { await addTmsLink(getDescription(test.info().annotations, "TMS").split(", ")); - if (transaction.bugTicket) { - await addBugLink(getDescription(test.info().annotations, "BUG").split(", ")); - } await app.layout.goToAccounts(); await app.accounts.navigateToAccountByName( @@ -604,4 +597,79 @@ test.describe("Send flows", () => { ); }); } + + const originalValue = process.env.DISABLE_TRANSACTION_BROADCAST; + + test.describe("User sends funds to ENS address", () => { + const transactionEnsAddress = new Transaction( + Account.ETH_1, + Account.ETH_2, + "0.0001", + Fee.MEDIUM, + ); + + test.beforeAll(async () => { + process.env.DISABLE_TRANSACTION_BROADCAST = "1"; + }); + + test.use({ + userdata: "skip-onboarding", + speculosApp: transactionEnsAddress.accountToDebit.currency.speculosApp, + cliCommands: [ + (appjsonPath: string) => { + return CLI.liveData({ + currency: transactionEnsAddress.accountToCredit.currency.currencyId, + index: transactionEnsAddress.accountToCredit.index, + add: true, + appjson: appjsonPath, + }); + }, + (appjsonPath: string) => { + return CLI.liveData({ + currency: transactionEnsAddress.accountToDebit.currency.currencyId, + index: transactionEnsAddress.accountToDebit.index, + add: true, + appjson: appjsonPath, + }); + }, + ], + }); + test( + `User sends funds to ENS address - ${transactionEnsAddress.accountToCredit.ensName}`, + { + annotation: { + type: "TMS", + description: "B2CQA-2202", + }, + }, + async ({ app }) => { + await addTmsLink(getDescription(test.info().annotations, "TMS").split(", ")); + + await app.layout.goToAccounts(); + await app.accounts.navigateToAccountByName( + transactionEnsAddress.accountToDebit.accountName, + ); + + await app.account.clickSend(); + await app.send.craftTx(transactionEnsAddress); + await app.send.countinueSendAmount(); + await app.send.expectTxInfoValidity(transactionEnsAddress); + await app.send.clickContinueToDevice(); + + await app.speculos.signSendTransaction(transactionEnsAddress); + await app.send.expectTxSent(); + await app.account.navigateToViewDetails(); + await app.sendDrawer.addressValueIsVisible(transactionEnsAddress.accountToCredit.address); + await app.drawer.closeDrawer(); + }, + ); + + test.afterAll(() => { + if (originalValue !== undefined) { + process.env.DISABLE_TRANSACTION_BROADCAST = originalValue; + } else { + delete process.env.DISABLE_TRANSACTION_BROADCAST; + } + }); + }); }); diff --git a/libs/ledger-live-common/src/e2e/enum/Account.ts b/libs/ledger-live-common/src/e2e/enum/Account.ts index 965aa4923461..cc73659600f9 100644 --- a/libs/ledger-live-common/src/e2e/enum/Account.ts +++ b/libs/ledger-live-common/src/e2e/enum/Account.ts @@ -159,15 +159,7 @@ export class Account { "0x43047a5023D55a8658Fcb1c1Cea468311AdAA3Ad", undefined, 1, - ); - - static readonly ETH_MC = new Account( - Currency.ETH, - "Ethereum MC", - "0x4258A05DBA420A398bcdFB389E4250759b4223ea", - undefined, - undefined, - "ldgrqamco.eth", + "speculos.eth", ); static readonly ETH_3 = new Account( diff --git a/libs/ledger-live-common/src/e2e/families/evm.ts b/libs/ledger-live-common/src/e2e/families/evm.ts index 6d42c2406438..00b75b8077ab 100644 --- a/libs/ledger-live-common/src/e2e/families/evm.ts +++ b/libs/ledger-live-common/src/e2e/families/evm.ts @@ -7,8 +7,13 @@ export async function sendEVM(tx: Transaction) { const events = await pressUntilTextFound(DeviceLabels.ACCEPT); const isAmountCorrect = containsSubstringInEvent(tx.amount, events); expect(isAmountCorrect).toBeTruthy(); - const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events); - expect(isAddressCorrect).toBeTruthy(); + if (tx.accountToCredit.ensName) { + const isENSNameCorrect = containsSubstringInEvent(tx.accountToCredit.ensName, events); + expect(isENSNameCorrect).toBeTruthy(); + } else { + const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events); + expect(isAddressCorrect).toBeTruthy(); + } await pressBoth(); } diff --git a/libs/ledger-live-common/src/e2e/speculos.ts b/libs/ledger-live-common/src/e2e/speculos.ts index ceda0854cfbf..17f4f1b93947 100644 --- a/libs/ledger-live-common/src/e2e/speculos.ts +++ b/libs/ledger-live-common/src/e2e/speculos.ts @@ -498,6 +498,7 @@ export async function signSendTransaction(tx: Transaction) { switch (currencyName) { case Currency.sepETH: case Currency.POL: + case Currency.ETH: await sendEVM(tx); break; case Currency.DOGE: