Skip to content

Commit

Permalink
Merge pull request #8306 from LedgerHQ/support/QAA-319
Browse files Browse the repository at this point in the history
[QAA] Refacto transaction for E2E testing & Adding check addresses split on 2 speculos screens
  • Loading branch information
VicAlbr authored Nov 6, 2024
2 parents 530dafc + c64196f commit c6d32b9
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 38 deletions.
6 changes: 2 additions & 4 deletions apps/ledger-live-desktop/tests/families/algorand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
5 changes: 2 additions & 3 deletions apps/ledger-live-desktop/tests/families/cardano.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
5 changes: 2 additions & 3 deletions apps/ledger-live-desktop/tests/families/stellar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
2 changes: 1 addition & 1 deletion apps/ledger-live-desktop/tests/models/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {}
}
10 changes: 3 additions & 7 deletions apps/ledger-live-desktop/tests/page/modal/send.modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -42,27 +41,24 @@ 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);
}
}

@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();
}

Expand Down
36 changes: 18 additions & 18 deletions apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand All @@ -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",
},
Expand All @@ -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",
},
Expand Down Expand Up @@ -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",
},
];
Expand Down
13 changes: 11 additions & 2 deletions libs/ledger-live-common/src/e2e/speculos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,17 @@ async function pressRightButton(speculosApiPort: number): Promise<void> {
}

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("");

let result = concatenatedEvents.includes(targetString);

if (!result) {
const regexPattern = targetString.split("").join(".*?");
const regex = new RegExp(regexPattern, "s");
result = regex.test(concatenatedEvents);
}

return result;
}

export async function takeScreenshot() {
Expand Down

0 comments on commit c6d32b9

Please sign in to comment.