From f63f116840e58e141a805a8582fb9fde0262e00f Mon Sep 17 00:00:00 2001 From: Victor Alber Date: Mon, 4 Nov 2024 13:42:02 +0100 Subject: [PATCH 1/2] =?UTF-8?q?test:=20=E2=9A=A1=EF=B8=8F=20Adding=20possi?= =?UTF-8?q?bility=20to=20check=20addresses=20split=20on=202=20speculos=20s?= =?UTF-8?q?creens?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/page/speculos.page.ts | 3 +++ .../specs/speculos/receive.address.spec.ts | 9 ++++---- libs/ledger-live-common/src/e2e/speculos.ts | 23 +++++++++++++++++-- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/apps/ledger-live-desktop/tests/page/speculos.page.ts b/apps/ledger-live-desktop/tests/page/speculos.page.ts index 4681469b3b1d..77de1296d885 100644 --- a/apps/ledger-live-desktop/tests/page/speculos.page.ts +++ b/apps/ledger-live-desktop/tests/page/speculos.page.ts @@ -31,6 +31,9 @@ export class SpeculosPage extends AppPage { let deviceLabels: string[]; switch (account.currency) { + case Currency.NEAR: + deviceLabels = [DeviceLabels.WALLET_ID, DeviceLabels.APPROVE, DeviceLabels.REJECT]; + break; case Currency.SOL: deviceLabels = [DeviceLabels.PUBKEY, DeviceLabels.APPROVE, DeviceLabels.REJECT]; break; diff --git a/apps/ledger-live-desktop/tests/specs/speculos/receive.address.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/receive.address.spec.ts index 5ecf99b5bc6e..a239fac65eaa 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/receive.address.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/receive.address.spec.ts @@ -5,16 +5,17 @@ import { getDescription } from "../../utils/customJsonReporter"; import { commandCLI } from "tests/utils/cliUtils"; const accounts = [ - { account: Account.BTC_NATIVE_SEGWIT_1, xrayTicket: "B2CQA-2559, B2CQA-2687" }, + //{ account: Account.BTC_NATIVE_SEGWIT_1, xrayTicket: "B2CQA-2559, B2CQA-2687" }, { account: Account.ETH_1, xrayTicket: "B2CQA-2561, B2CQA-2688, B2CQA-2697" }, - { account: Account.SOL_1, xrayTicket: "B2CQA-2563, B2CQA-2689" }, + { account: Account.NEAR_1, xrayTicket: "DO NOT PUSH" }, + /*{ account: Account.SOL_1, xrayTicket: "B2CQA-2563, B2CQA-2689" }, { account: Account.TRX_1, xrayTicket: "B2CQA-2565, B2CQA-2690, B2CQA-2699" }, { account: Account.DOT_1, xrayTicket: "B2CQA-2562, B2CQA-2691" }, { account: Account.XRP_1, xrayTicket: "B2CQA-2566, B2CQA-2692" }, { account: Account.BCH_1, xrayTicket: "B2CQA-2558, B2CQA-2693" }, { account: Account.ATOM_1, xrayTicket: "B2CQA-2560, B2CQA-2694" }, { account: Account.XTZ_1, xrayTicket: "B2CQA-2564, B2CQA-2695" }, - { account: Account.BSC_1, xrayTicket: "B2CQA-2686, B2CQA-2696, B2CQA-2698" }, + { account: Account.BSC_1, xrayTicket: "B2CQA-2686, B2CQA-2696, B2CQA-2698" },*/ ]; //Warning 🚨: Test may fail due to the GetAppAndVersion issue - Jira: LIVE-12581 @@ -75,7 +76,7 @@ for (const account of accounts) { }); } -test.describe("Receive", () => { +test.describe.skip("Receive", () => { const account = Account.TRX_3; test.use({ userdata: "skip-onboarding", diff --git a/libs/ledger-live-common/src/e2e/speculos.ts b/libs/ledger-live-common/src/e2e/speculos.ts index 349058d3de86..1ee75ac88fdf 100644 --- a/libs/ledger-live-common/src/e2e/speculos.ts +++ b/libs/ledger-live-common/src/e2e/speculos.ts @@ -399,8 +399,27 @@ async function pressRightButton(speculosApiPort: number): Promise { } export function containsSubstringInEvent(targetString: string, events: string[]): boolean { - const relevantEvent = events.find(entry => entry.includes(targetString.slice(0, 6))); - return !!relevantEvent && events.join("").includes(targetString); + const concatenatedEvents = events.join(""); + //eslint-disable-next-line no-console + console.log(`Target String: ${targetString}`); + //eslint-disable-next-line no-console + console.log(`Concatenated Events: ${concatenatedEvents}`); + + let result = concatenatedEvents.includes(targetString); + + if (!result) { + const regexPattern = targetString.split("").join(".*?"); + const regex = new RegExp(regexPattern, "s"); + + //eslint-disable-next-line no-console + console.log(`regex: ${regex}`); + + result = regex.test(concatenatedEvents); + } + + //eslint-disable-next-line no-console + console.log(`containsSubstringInEvent result: ${result}`); + return result; } export async function takeScreenshot() { From c64196f273fc194627b96b29344df336791d8577 Mon Sep 17 00:00:00 2001 From: Victor Alber Date: Mon, 4 Nov 2024 13:51:15 +0100 Subject: [PATCH 2/2] =?UTF-8?q?test:=20=E2=99=BB=EF=B8=8F=20refectoring=20?= =?UTF-8?q?transacation=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/families/algorand.ts | 6 ++-- .../tests/families/cardano.ts | 5 ++- .../tests/families/stellar.ts | 5 ++- .../tests/models/Transaction.ts | 2 +- .../tests/page/modal/send.modal.ts | 10 ++---- .../tests/page/speculos.page.ts | 3 -- .../specs/speculos/receive.address.spec.ts | 9 +++-- .../tests/specs/speculos/send.tx.spec.ts | 36 +++++++++---------- libs/ledger-live-common/src/e2e/speculos.ts | 10 ------ 9 files changed, 32 insertions(+), 54 deletions(-) diff --git a/apps/ledger-live-desktop/tests/families/algorand.ts b/apps/ledger-live-desktop/tests/families/algorand.ts index bd2a9ae0e914..b1f7a016305f 100644 --- a/apps/ledger-live-desktop/tests/families/algorand.ts +++ b/apps/ledger-live-desktop/tests/families/algorand.ts @@ -11,10 +11,8 @@ export async function sendAlgorand(tx: Transaction) { const events = await pressUntilTextFound(DeviceLabels.CAPS_APPROVE); const isAmountCorrect = containsSubstringInEvent(tx.amount, events); expect(isAmountCorrect).toBeTruthy(); - - //Todo: Ractivate after QAA-319 - //const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events); - //expect(isAddressCorrect).toBeTruthy(); + const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events); + expect(isAddressCorrect).toBeTruthy(); await pressBoth(); } diff --git a/apps/ledger-live-desktop/tests/families/cardano.ts b/apps/ledger-live-desktop/tests/families/cardano.ts index c8e39613caf1..7433b878e87c 100644 --- a/apps/ledger-live-desktop/tests/families/cardano.ts +++ b/apps/ledger-live-desktop/tests/families/cardano.ts @@ -22,7 +22,6 @@ export async function sendCardano(tx: Transaction) { await waitFor(DeviceLabels.CONFIRM_TRANSACTION); await pressBoth(); - //Todo: Ractivate after QAA-319 - //const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events); - //expect(isAddressCorrect).toBeTruthy(); + const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events); + expect(isAddressCorrect).toBeTruthy(); } diff --git a/apps/ledger-live-desktop/tests/families/stellar.ts b/apps/ledger-live-desktop/tests/families/stellar.ts index 8389ffd5d425..3936ad2ffe71 100644 --- a/apps/ledger-live-desktop/tests/families/stellar.ts +++ b/apps/ledger-live-desktop/tests/families/stellar.ts @@ -12,9 +12,8 @@ export async function sendStellar(tx: Transaction) { const isAmountCorrect = containsSubstringInEvent(tx.amount, events); expect(isAmountCorrect).toBeTruthy(); - //Todo: Ractivate after QAA-319 - //const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events); - //expect(isAddressCorrect).toBeTruthy(); + const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events); + expect(isAddressCorrect).toBeTruthy(); await pressBoth(); } diff --git a/apps/ledger-live-desktop/tests/models/Transaction.ts b/apps/ledger-live-desktop/tests/models/Transaction.ts index 08333b27e952..42ad80fd4733 100644 --- a/apps/ledger-live-desktop/tests/models/Transaction.ts +++ b/apps/ledger-live-desktop/tests/models/Transaction.ts @@ -6,7 +6,7 @@ export class Transaction { public accountToDebit: Account, public accountToCredit: Account, public amount: string, - public speed: Fee, + public speed?: Fee, public memoTag?: string, ) {} } 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 433dec0675a0..ea7bfcb94296 100644 --- a/apps/ledger-live-desktop/tests/page/modal/send.modal.ts +++ b/apps/ledger-live-desktop/tests/page/modal/send.modal.ts @@ -2,7 +2,6 @@ import { expect } from "@playwright/test"; import { Modal } from "../../component/modal.component"; import { step } from "tests/misc/reporters/step"; import { Transaction } from "../../models/Transaction"; -import { Currency } from "tests/enum/Currency"; export class SendModal extends Modal { private drowdownAccount = this.page.locator('[data-testid="modal-content"] svg').nth(1); @@ -42,7 +41,7 @@ export class SendModal extends Modal { @step("Enter recipient and tag") async fillRecipientInfo(transaction: Transaction) { await this.fillRecipient(transaction.accountToCredit.address); - if (transaction.memoTag) { + if (transaction.memoTag && transaction.memoTag !== "noTag") { await this.tagInput.clear(); await this.tagInput.fill(transaction.memoTag); } @@ -50,19 +49,16 @@ export class SendModal extends Modal { @step("Fill tx information") async craftTx(tx: Transaction) { - const memotagModalCurrencies = [Currency.XLM, Currency.ADA, Currency.ATOM]; - const feeStrategyCurrencies = [Currency.sepETH, Currency.POL, Currency.DOGE, Currency.BCH]; - await this.fillRecipientInfo(tx); await this.continueButton.click(); - if (memotagModalCurrencies.includes(tx.accountToDebit.currency)) { + if (tx.memoTag === "noTag") { await this.noTagButton.click(); } await this.cryptoAmountField.fill(tx.amount); - if (feeStrategyCurrencies.includes(tx.accountToDebit.currency)) { + if (tx.speed !== undefined) { await this.feeStrategy(tx.speed).click(); } diff --git a/apps/ledger-live-desktop/tests/page/speculos.page.ts b/apps/ledger-live-desktop/tests/page/speculos.page.ts index 77de1296d885..4681469b3b1d 100644 --- a/apps/ledger-live-desktop/tests/page/speculos.page.ts +++ b/apps/ledger-live-desktop/tests/page/speculos.page.ts @@ -31,9 +31,6 @@ export class SpeculosPage extends AppPage { let deviceLabels: string[]; switch (account.currency) { - case Currency.NEAR: - deviceLabels = [DeviceLabels.WALLET_ID, DeviceLabels.APPROVE, DeviceLabels.REJECT]; - break; case Currency.SOL: deviceLabels = [DeviceLabels.PUBKEY, DeviceLabels.APPROVE, DeviceLabels.REJECT]; break; diff --git a/apps/ledger-live-desktop/tests/specs/speculos/receive.address.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/receive.address.spec.ts index a239fac65eaa..5ecf99b5bc6e 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/receive.address.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/receive.address.spec.ts @@ -5,17 +5,16 @@ import { getDescription } from "../../utils/customJsonReporter"; import { commandCLI } from "tests/utils/cliUtils"; const accounts = [ - //{ account: Account.BTC_NATIVE_SEGWIT_1, xrayTicket: "B2CQA-2559, B2CQA-2687" }, + { account: Account.BTC_NATIVE_SEGWIT_1, xrayTicket: "B2CQA-2559, B2CQA-2687" }, { account: Account.ETH_1, xrayTicket: "B2CQA-2561, B2CQA-2688, B2CQA-2697" }, - { account: Account.NEAR_1, xrayTicket: "DO NOT PUSH" }, - /*{ account: Account.SOL_1, xrayTicket: "B2CQA-2563, B2CQA-2689" }, + { account: Account.SOL_1, xrayTicket: "B2CQA-2563, B2CQA-2689" }, { account: Account.TRX_1, xrayTicket: "B2CQA-2565, B2CQA-2690, B2CQA-2699" }, { account: Account.DOT_1, xrayTicket: "B2CQA-2562, B2CQA-2691" }, { account: Account.XRP_1, xrayTicket: "B2CQA-2566, B2CQA-2692" }, { account: Account.BCH_1, xrayTicket: "B2CQA-2558, B2CQA-2693" }, { account: Account.ATOM_1, xrayTicket: "B2CQA-2560, B2CQA-2694" }, { account: Account.XTZ_1, xrayTicket: "B2CQA-2564, B2CQA-2695" }, - { account: Account.BSC_1, xrayTicket: "B2CQA-2686, B2CQA-2696, B2CQA-2698" },*/ + { account: Account.BSC_1, xrayTicket: "B2CQA-2686, B2CQA-2696, B2CQA-2698" }, ]; //Warning 🚨: Test may fail due to the GetAppAndVersion issue - Jira: LIVE-12581 @@ -76,7 +75,7 @@ for (const account of accounts) { }); } -test.describe.skip("Receive", () => { +test.describe("Receive", () => { const account = Account.TRX_3; test.use({ userdata: "skip-onboarding", 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 d8d9c1ea3c7a..b02b1aed8dc0 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 @@ -20,17 +20,17 @@ const transactionsAmountInvalid = [ xrayTicket: "B2CQA-2569", }, { - transaction: new Transaction(Account.XRP_1, Account.XRP_3, "1", Fee.MEDIUM), + transaction: new Transaction(Account.XRP_1, Account.XRP_3, "1"), expectedErrorMessage: "Recipient address is inactive. Send at least 10 XRP to activate it", xrayTicket: "B2CQA-2571", }, { - transaction: new Transaction(Account.DOT_1, Account.DOT_2, "1.2", Fee.MEDIUM), + transaction: new Transaction(Account.DOT_1, Account.DOT_2, "1.2"), expectedErrorMessage: "Balance cannot be below 1 DOT. Send max to empty account.", xrayTicket: "B2CQA-2567", }, { - transaction: new Transaction(Account.DOT_1, Account.DOT_3, "0.5", Fee.MEDIUM), + transaction: new Transaction(Account.DOT_1, Account.DOT_3, "0.5"), expectedErrorMessage: "Recipient address is inactive. Send at least 1 DOT to activate it", xrayTicket: "B2CQA-2570", }, @@ -53,17 +53,17 @@ const transactionsAddressInvalid = [ xrayTicket: "B2CQA-2710", }, { - transaction: new Transaction(Account.DOT_1, Account.DOT_1, "0.5", Fee.MEDIUM), + transaction: new Transaction(Account.DOT_1, Account.DOT_1, "0.5"), expectedErrorMessage: "Recipient address is the same as the sender address", xrayTicket: "B2CQA-2711", }, { - transaction: new Transaction(Account.XRP_1, Account.XRP_1, "1", Fee.MEDIUM, "123456"), + transaction: new Transaction(Account.XRP_1, Account.XRP_1, "1", undefined, "123456"), expectedErrorMessage: "Recipient address is the same as the sender address", xrayTicket: "B2CQA-2712", }, { - transaction: new Transaction(Account.ATOM_1, Account.ATOM_1, "0.00001", Fee.MEDIUM), + transaction: new Transaction(Account.ATOM_1, Account.ATOM_1, "0.00001"), expectedErrorMessage: "Recipient address is the same as the sender address", xrayTicket: "B2CQA-2713", }, @@ -86,22 +86,22 @@ const transactionAddressValid = [ xrayTicket: "B2CQA-2717", }, { - transaction: new Transaction(Account.XRP_1, Account.XRP_2, "1", Fee.MEDIUM, "123456"), + transaction: new Transaction(Account.XRP_1, Account.XRP_2, "1", undefined, "123456"), expectedWarningMessage: null, xrayTicket: "B2CQA-2718", }, { - transaction: new Transaction(Account.XRP_1, Account.XRP_2, "2", Fee.MEDIUM), + transaction: new Transaction(Account.XRP_1, Account.XRP_2, "2"), expectedWarningMessage: null, xrayTicket: "B2CQA-2719", }, { - transaction: new Transaction(Account.ATOM_1, Account.ATOM_2, "0.00001", Fee.MEDIUM, "123456"), + transaction: new Transaction(Account.ATOM_1, Account.ATOM_2, "0.00001", undefined, "123456"), expectedWarningMessage: null, xrayTicket: "B2CQA-2720", }, { - transaction: new Transaction(Account.ATOM_1, Account.ATOM_2, "0.0001", Fee.MEDIUM), + transaction: new Transaction(Account.ATOM_1, Account.ATOM_2, "0.0001"), expectedWarningMessage: null, xrayTicket: "B2CQA-2721", }, @@ -160,35 +160,35 @@ const transactionE2E = [ xrayTicket: "B2CQA-2808", }, { - transaction: new Transaction(Account.DOT_1, Account.DOT_2, "0.0001", Fee.SLOW), + transaction: new Transaction(Account.DOT_1, Account.DOT_2, "0.0001"), xrayTicket: "B2CQA-2809", }, { - transaction: new Transaction(Account.ALGO_1, Account.ALGO_2, "0.001", Fee.SLOW), + transaction: new Transaction(Account.ALGO_1, Account.ALGO_2, "0.001"), xrayTicket: "B2CQA-2810", }, { - transaction: new Transaction(Account.SOL_1, Account.SOL_2, "0.000001", Fee.SLOW), + transaction: new Transaction(Account.SOL_1, Account.SOL_2, "0.000001"), xrayTicket: "B2CQA-2811", }, { - transaction: new Transaction(Account.TRX_1, Account.TRX_2, "0.01", Fee.SLOW), + transaction: new Transaction(Account.TRX_1, Account.TRX_2, "0.01"), xrayTicket: "B2CQA-2812", }, { - transaction: new Transaction(Account.XLM_1, Account.XLM_2, "0.0001", Fee.SLOW), + transaction: new Transaction(Account.XLM_1, Account.XLM_2, "0.0001", undefined, "noTag"), xrayTicket: "B2CQA-2813", }, { - transaction: new Transaction(Account.ATOM_1, Account.ATOM_2, "0.0001", Fee.SLOW), + transaction: new Transaction(Account.ATOM_1, Account.ATOM_2, "0.0001", undefined, "noTag"), xrayTicket: "B2CQA-2814", }, { - transaction: new Transaction(Account.ADA_1, Account.ADA_1, "1", Fee.SLOW), + transaction: new Transaction(Account.ADA_1, Account.ADA_1, "1", undefined, "noTag"), xrayTicket: "B2CQA-2815", }, { - transaction: new Transaction(Account.XRP_1, Account.XRP_2, "0.0001", Fee.SLOW), + transaction: new Transaction(Account.XRP_1, Account.XRP_2, "0.0001"), xrayTicket: "B2CQA-2816", }, ]; diff --git a/libs/ledger-live-common/src/e2e/speculos.ts b/libs/ledger-live-common/src/e2e/speculos.ts index 1ee75ac88fdf..0d5fffe6416d 100644 --- a/libs/ledger-live-common/src/e2e/speculos.ts +++ b/libs/ledger-live-common/src/e2e/speculos.ts @@ -400,25 +400,15 @@ async function pressRightButton(speculosApiPort: number): Promise { export function containsSubstringInEvent(targetString: string, events: string[]): boolean { const concatenatedEvents = events.join(""); - //eslint-disable-next-line no-console - console.log(`Target String: ${targetString}`); - //eslint-disable-next-line no-console - console.log(`Concatenated Events: ${concatenatedEvents}`); let result = concatenatedEvents.includes(targetString); if (!result) { const regexPattern = targetString.split("").join(".*?"); const regex = new RegExp(regexPattern, "s"); - - //eslint-disable-next-line no-console - console.log(`regex: ${regex}`); - result = regex.test(concatenatedEvents); } - //eslint-disable-next-line no-console - console.log(`containsSubstringInEvent result: ${result}`); return result; }