Skip to content

Commit

Permalink
test: ✅ adding ENS test + update NFT test
Browse files Browse the repository at this point in the history
  • Loading branch information
VicAlbr committed Jan 17, 2025
1 parent bbb8961 commit b838cb2
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 40 deletions.
13 changes: 12 additions & 1 deletion apps/ledger-live-desktop/tests/page/modal/send.modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-desktop/tests/page/swap.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
20 changes: 3 additions & 17 deletions apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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"),
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-desktop/tests/specs/speculos/nft.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
86 changes: 77 additions & 9 deletions apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
}
});
});
});
10 changes: 1 addition & 9 deletions libs/ledger-live-common/src/e2e/enum/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 7 additions & 2 deletions libs/ledger-live-common/src/e2e/families/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions libs/ledger-live-common/src/e2e/speculos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b838cb2

Please sign in to comment.