Skip to content

Commit

Permalink
test: ✅ Adding new currencies for e2e send testing
Browse files Browse the repository at this point in the history
  • Loading branch information
VicAlbr committed Oct 31, 2024
1 parent 23ae8e1 commit f4f0642
Show file tree
Hide file tree
Showing 17 changed files with 345 additions and 76 deletions.
2 changes: 1 addition & 1 deletion apps/ledger-live-desktop/tests/enum/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export class Account {
static readonly ADA_1 = new Account(
Currency.ADA,
"Cardano 1",
" addr1q9q9q55zyew785z6c2lnrhnzghy038r6mepmqn6v28kupk5ug4c7v5lwwfjwgn4mnpzgmhrhp8xry804kuvfh6ru2ews8d5td8",
"addr1q9q9q55zyew785z6c2lnrhnzghy038r6mepmqn6v28kupk5ug4c7v5lwwfjwgn4mnpzgmhrhp8xry804kuvfh6ru2ews8d5td8",
undefined,
0,
);
Expand Down
3 changes: 3 additions & 0 deletions apps/ledger-live-desktop/tests/enum/DeviceLabels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ export enum DeviceLabels {
MAKE_SURE_TO_USE = "Make sure to use",
YOUR_CRYPTO_ACCOUNTS = "Your crypto accounts",
TURN_ON_SYNC = "Turn on sync?",
NEW_ORDINARY_TRANSACTION = "New ordinary transaction",
SEND_TO_ADDRESS_2 = "Send to address (2/2)",
CONFIRM_TRANSACTION = "Confirm transaction",
}
20 changes: 20 additions & 0 deletions apps/ledger-live-desktop/tests/families/algorand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { expect } from "@playwright/test";
import { Transaction } from "tests/models/Transaction";
import {
pressBoth,
pressUntilTextFound,
containsSubstringInEvent,
} from "@ledgerhq/live-common/e2e/speculos";
import { DeviceLabels } from "tests/enum/DeviceLabels";

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

await pressBoth();
}
36 changes: 36 additions & 0 deletions apps/ledger-live-desktop/tests/families/bitcoin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { expect } from "@playwright/test";
import { Currency } from "tests/enum/Currency";
import { Transaction } from "tests/models/Transaction";
import {
pressBoth,
pressUntilTextFound,
waitFor,
containsSubstringInEvent,
} from "@ledgerhq/live-common/e2e/speculos";
import { DeviceLabels } from "tests/enum/DeviceLabels";

export async function sendBTCBasedCoin(tx: Transaction) {
let deviceLabel: string;

switch (tx.accountToDebit.currency) {
case Currency.BTC:
deviceLabel = DeviceLabels.CONTINUE;
break;
case Currency.DOGE:
case Currency.BCH:
deviceLabel = DeviceLabels.ACCEPT;
break;
default:
throw new Error(`Not a BTC-based coin: ${tx.accountToDebit.currency}`);
}

const events = await pressUntilTextFound(deviceLabel);
const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
expect(isAmountCorrect).toBeTruthy();
const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
expect(isAddressCorrect).toBeTruthy();
await pressBoth();
await waitFor(DeviceLabels.CONFIRM);
await pressUntilTextFound(DeviceLabels.ACCEPT);
await pressBoth();
}
28 changes: 28 additions & 0 deletions apps/ledger-live-desktop/tests/families/cardano.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { expect } from "@playwright/test";
import { Transaction } from "tests/models/Transaction";
import {
pressBoth,
pressUntilTextFound,
containsSubstringInEvent,
waitFor,
} from "@ledgerhq/live-common/e2e/speculos";
import { DeviceLabels } from "tests/enum/DeviceLabels";

export async function sendCardano(tx: Transaction) {
await waitFor(DeviceLabels.NEW_ORDINARY_TRANSACTION);
await pressBoth();
await pressUntilTextFound(DeviceLabels.SEND_TO_ADDRESS_2);
await pressBoth();
const events = await pressUntilTextFound(DeviceLabels.SEND);
const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
expect(isAmountCorrect).toBeTruthy();
await pressBoth();
await waitFor(DeviceLabels.TRANSACTION_FEE);
await pressBoth();
await waitFor(DeviceLabels.CONFIRM_TRANSACTION);
await pressBoth();

//Todo: Ractivate after QAA-319
//const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
//expect(isAddressCorrect).toBeTruthy();
}
28 changes: 28 additions & 0 deletions apps/ledger-live-desktop/tests/families/cosmos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { expect } from "@playwright/test";
import { Delegate } from "tests/models/Delegate";
import { Transaction } from "tests/models/Transaction";
import {
pressBoth,
pressUntilTextFound,
waitFor,
containsSubstringInEvent,
} from "@ledgerhq/live-common/e2e/speculos";
import { DeviceLabels } from "tests/enum/DeviceLabels";

export async function delegateCosmos(delegatingAccount: Delegate) {
await waitFor(DeviceLabels.PLEASE_REVIEW);
const events = await pressUntilTextFound(DeviceLabels.CAPS_APPROVE);
const isAmountCorrect = containsSubstringInEvent(delegatingAccount.amount, events);
expect(isAmountCorrect).toBeTruthy();
await pressBoth();
}

export async function sendCosmos(tx: Transaction) {
const events = await pressUntilTextFound(DeviceLabels.CAPS_APPROVE);
const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
expect(isAmountCorrect).toBeTruthy();
const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
expect(isAddressCorrect).toBeTruthy();

await pressBoth();
}
18 changes: 18 additions & 0 deletions apps/ledger-live-desktop/tests/families/evm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect } from "@playwright/test";
import { Transaction } from "tests/models/Transaction";
import {
pressBoth,
pressUntilTextFound,
containsSubstringInEvent,
} from "@ledgerhq/live-common/e2e/speculos";
import { DeviceLabels } from "tests/enum/DeviceLabels";

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

await pressBoth();
}
20 changes: 20 additions & 0 deletions apps/ledger-live-desktop/tests/families/near.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { expect } from "@playwright/test";
import { Delegate } from "tests/models/Delegate";
import {
pressBoth,
pressUntilTextFound,
waitFor,
containsSubstringInEvent,
} from "@ledgerhq/live-common/e2e/speculos";
import { DeviceLabels } from "tests/enum/DeviceLabels";

export async function delegateNear(delegatingAccount: Delegate) {
await waitFor(DeviceLabels.VIEW_HEADER);
const events = await pressUntilTextFound(DeviceLabels.CONTINUE_TO_ACTION);
const isProviderCorrect = containsSubstringInEvent(delegatingAccount.provider, events);
expect(isProviderCorrect).toBeTruthy();
await pressBoth();
await waitFor(DeviceLabels.VIEW_ACTION);
await pressUntilTextFound(DeviceLabels.SIGN);
await pressBoth();
}
18 changes: 18 additions & 0 deletions apps/ledger-live-desktop/tests/families/polkadot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect } from "@playwright/test";
import { Transaction } from "tests/models/Transaction";
import {
pressBoth,
pressUntilTextFound,
containsSubstringInEvent,
} from "@ledgerhq/live-common/e2e/speculos";
import { DeviceLabels } from "tests/enum/DeviceLabels";

export async function sendPolkadot(tx: Transaction) {
const events = await pressUntilTextFound(DeviceLabels.CAPS_APPROVE);
const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
expect(isAmountCorrect).toBeTruthy();
const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
expect(isAddressCorrect).toBeTruthy();

await pressBoth();
}
25 changes: 25 additions & 0 deletions apps/ledger-live-desktop/tests/families/solana.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { expect } from "@playwright/test";
import {
pressBoth,
pressUntilTextFound,
waitFor,
containsSubstringInEvent,
} from "@ledgerhq/live-common/e2e/speculos";
import { DeviceLabels } from "tests/enum/DeviceLabels";
import { Transaction } from "tests/models/Transaction";

export async function delegateSolana() {
await waitFor(DeviceLabels.DELEGATE_FROM);
await pressUntilTextFound(DeviceLabels.APPROVE);
await pressBoth();
}

export async function sendSolana(tx: Transaction) {
const events = await pressUntilTextFound(DeviceLabels.APPROVE);
const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
expect(isAmountCorrect).toBeTruthy();
const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
expect(isAddressCorrect).toBeTruthy();

await pressBoth();
}
20 changes: 20 additions & 0 deletions apps/ledger-live-desktop/tests/families/stellar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { expect } from "@playwright/test";
import { Transaction } from "tests/models/Transaction";
import {
pressBoth,
pressUntilTextFound,
containsSubstringInEvent,
} from "@ledgerhq/live-common/e2e/speculos";
import { DeviceLabels } from "tests/enum/DeviceLabels";

export async function sendStellar(tx: Transaction) {
const events = await pressUntilTextFound(DeviceLabels.SIGN);
const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
expect(isAmountCorrect).toBeTruthy();

//Todo: Ractivate after QAA-319
//const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
//expect(isAddressCorrect).toBeTruthy();

await pressBoth();
}
18 changes: 18 additions & 0 deletions apps/ledger-live-desktop/tests/families/tron.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect } from "@playwright/test";
import { Transaction } from "tests/models/Transaction";
import {
pressBoth,
pressUntilTextFound,
containsSubstringInEvent,
} from "@ledgerhq/live-common/e2e/speculos";
import { DeviceLabels } from "tests/enum/DeviceLabels";

export async function sendTron(tx: Transaction) {
const events = await pressUntilTextFound(DeviceLabels.SIGN);
const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
expect(isAmountCorrect).toBeTruthy();
const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
expect(isAddressCorrect).toBeTruthy();

await pressBoth();
}
18 changes: 18 additions & 0 deletions apps/ledger-live-desktop/tests/families/xrp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect } from "@playwright/test";
import { Transaction } from "tests/models/Transaction";
import {
pressBoth,
pressUntilTextFound,
containsSubstringInEvent,
} from "@ledgerhq/live-common/e2e/speculos";
import { DeviceLabels } from "tests/enum/DeviceLabels";

export async function sendXRP(tx: Transaction) {
const events = await pressUntilTextFound(DeviceLabels.SIGN);
const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
expect(isAmountCorrect).toBeTruthy();
const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
expect(isAddressCorrect).toBeTruthy();

await pressBoth();
}
12 changes: 9 additions & 3 deletions apps/ledger-live-desktop/tests/page/modal/send.modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ 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);
readonly recipientInput = this.page.getByPlaceholder("Enter");
readonly tagInput = this.page.getByPlaceholder("Optional");
readonly continueButton = this.page.getByRole("button", { name: "continue" });
private totalDebitValue = this.page.locator("text=Total to debit");
private checkDeviceLabel = this.page.locator(
"text=Double-check the transaction details on your Ledger device before signing.",
);
Expand Down Expand Up @@ -52,13 +52,19 @@ export class SendModal extends Modal {
await this.fillRecipientInfo(tx);
await this.continueButton.click();
await this.cryptoAmountField.fill(tx.amount);
await this.feeStrategy(tx.speed).click();
if (
tx.accountToDebit.currency == Currency.sepETH &&
tx.accountToDebit.currency == Currency.POL &&
tx.accountToDebit.currency == Currency.DOGE &&
tx.accountToDebit.currency == Currency.BCH
) {
await this.feeStrategy(tx.speed).click();
}
await this.countinueSendAmount();
}

@step("Verify tx information before confirming")
async expectTxInfoValidity(tx: Transaction) {
await expect(this.totalDebitValue).toBeVisible();
const displayedReceiveAddress = await this.recipientAddressDisplayedValue.innerText();
expect(displayedReceiveAddress).toEqual(tx.accountToCredit.address);

Expand Down
Loading

0 comments on commit f4f0642

Please sign in to comment.