Skip to content

Commit

Permalink
Test: Improving speculos Tests + adding new currencies (#6984)
Browse files Browse the repository at this point in the history
* test: fix countAccounts function + typescript issues

* test: updating the app.JSON

* test: changing app.json name

* test: removing 1 ETH send + update on account.page
  • Loading branch information
valber-ledger committed Jun 5, 2024
1 parent 4b3e5b0 commit 652631c
Show file tree
Hide file tree
Showing 16 changed files with 61,658 additions and 25,236 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-pens-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": minor
---

improving speculos tests: adding new checks + new currencies
71 changes: 71 additions & 0 deletions apps/ledger-live-desktop/tests/enum/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,75 @@ export class Account {
static readonly XRP_1 = new Account(Currency.XRP, "XRP 1", "rhQvt8XfAGn1hVVtMUmdGKBUdnKzi2oimV");

static readonly XRP_2 = new Account(Currency.XRP, "XRP 2", "r36cgyrfC1xSQMvjuiSeFJEcBTq31imZS");

static readonly ADA_1 = new Account(
Currency.ADA,
"Cardano 1",
" addr1q9q9q55zyew785z6c2lnrhnzghy038r6mepmqn6v28kupk5ug4c7v5lwwfjwgn4mnpzgmhrhp8xry804kuvfh6ru2ews8d5td8",
);
static readonly ADA_2 = new Account(
Currency.ADA,
"Cardano 2",
"addr1qyjd47qfktpza4ycjddjadaarzwdumwrqws0xage8gvsmrq5ghmxjmdj4eylq78wur2gmm7gtqfq49v6mtdkaqwqzy2qwzv6ac",
);

static readonly ALGO_1 = new Account(
Currency.ALGO,
"Algorand 1",
"HQ6YJWSVG3KVRE56V6UGWMUJLDVNPQUNXJBY7VJ56VMNMGIKVDTC7JEKOU",
);

static readonly ALGO_2 = new Account(
Currency.ALGO,
"Algorand 2",
"6TFDU3BYQ2FO32SOYQDTHDW5XKGEYH4FCT34ZQRHFPJRVMLEQWOO2OEUU4",
);

static readonly XLM_1 = new Account(
Currency.XLM,
"Stellar 1",
"GCAGRZ7XABYSXV7CPFSFWQIUK6XFXECBPWP2SGMVOB2KFWN7YM4TDGSX",
);

static readonly XLM_2 = new Account(
Currency.XLM,
"Stellar 2",
"GCTGRCFN7AT6NW4DZVI4QN55BRNQA64TXEZSMYPE7BNUZMLMVISXT652",
);

static readonly BCH_1 = new Account(
Currency.BCH,
"Bitcoin Cash 1",
"qz82kem69vdafku8xf4zpt9p5ytj8umwpujj7wjcv6",
);

static readonly BCH_2 = new Account(
Currency.BCH,
"Bitcoin Cash 2",
"qp2ka732e6h82djvr5ge4vtru0cl3g8lxqtyfmzzl9",
);

static readonly ATOM_1 = new Account(
Currency.ATOM,
"Cosmos 1",
"cosmos18sdl4lvyjtvpjkkt5smglux9sf4phdcpaddfae",
);

static readonly ATOM_2 = new Account(
Currency.ATOM,
"Cosmos 2",
"cosmos12d854g9mut943gu5ncyhalapukttkddnvlxaq6",
);

static readonly XTZ_1 = new Account(
Currency.XTZ,
"Tezos 1",
"tz1UD2zz5eFTW2Jy26kBnC3ZkdeazUgeFWST",
);

static readonly XTZ_2 = new Account(
Currency.XTZ,
"Tezos 2",
"tz1g3uEPZ9T3AhUZDTbGW9V43JRfizJmSnPv",
);
}
47 changes: 47 additions & 0 deletions apps/ledger-live-desktop/tests/enum/Currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,51 @@ export class Currency {
[DeviceLabels.AMOUT, DeviceLabels.DESTINATION, DeviceLabels.SIGN, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
static readonly ADA = new Currency(
"Cardano",
"ADA",
"Cardano",
[DeviceLabels.SEND, DeviceLabels.SEND_TO_ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.CONFIRM, DeviceLabels.REJECT],
);
static readonly XLM = new Currency(
"Stellar",
"XLM",
"Stellar",
[DeviceLabels.SEND, DeviceLabels.DESTINATION, DeviceLabels.FINALIZE, DeviceLabels.CANCEL],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
static readonly BCH = new Currency(
"Bitcoin Cash",
"BCH",
"Bitcoin Cash",
[DeviceLabels.AMOUT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
static readonly ALGO = new Currency(
"Algorand",
"ALGO",
"Algorand",
[
DeviceLabels.AMOUT,
DeviceLabels.RECEIVER,
DeviceLabels.CAPS_APPROVE,
DeviceLabels.CAPS_REJECT,
],
[DeviceLabels.ADDRESS, DeviceLabels.CAPS_APPROVE, DeviceLabels.CAPS_REJECT],
);
static readonly ATOM = new Currency(
"Cosmos",
"ATOM",
"Cosmos",
[DeviceLabels.AMOUT, DeviceLabels.TO, DeviceLabels.CAPS_APPROVE, DeviceLabels.CAPS_REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.CAPS_APPROVE, DeviceLabels.CAPS_REJECT],
);
static readonly XTZ = new Currency(
"Tezos",
"XTZ",
"Tezos",
[DeviceLabels.AMOUT, DeviceLabels.DESTINATION, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.PUBLICKEY, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
);
}
7 changes: 7 additions & 0 deletions apps/ledger-live-desktop/tests/enum/DeviceLabels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@ export enum DeviceLabels {
CANCEL = "Cancel",
ACCOUNT = "Account",
DESTINATION = "Destination",
CONFIRM = "Confirm",
PUBLICKEY = "Public Key Hash",
SEND_TO_ADDRESS = "Send to address",
SEND = "Send",
TRANSACTION_FEE = "Transaction fee",
FINALIZE = "Finalize",
RECEIVER = "Receiver",
}
8 changes: 8 additions & 0 deletions apps/ledger-live-desktop/tests/page/account.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export class AccountPage extends AppPage {
private lastOperation = this.page.locator("text=Latest operations");
private tokenValue = (tokenName: string) =>
this.page.locator(`data-test-id=account-row-${tokenName.toLowerCase()}`);
private accountBalance = this.page.locator("data-test-id=total-balance");
private operationList = this.page.locator("id=operation-list");

@step("Navigate to token $0")
async navigateToToken(token: string) {
Expand Down Expand Up @@ -83,9 +85,15 @@ export class AccountPage extends AppPage {
await this.settingsButton.waitFor({ state: "visible" });
}

@step("Expect account to be not null")
async expectAccountBalance() {
expect(this.accountBalance).toBeTruthy();
}

@step("Expect `Last operations` to be visible")
async expectLastOperationsVisibility() {
await this.scrollToOperations();
await expect(this.lastOperation).toBeVisible();
await expect(this.operationList).not.toBeEmpty();
}
}
7 changes: 5 additions & 2 deletions apps/ledger-live-desktop/tests/page/accounts.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ export class AccountsPage extends AppPage {
const accountElements = await this.accountListNumber.all();
const accountNames = [];
for (const element of accountElements) {
const accountName = await element.getAttribute("data-test-id");
accountNames.push(accountName);
let accountName = await element.getAttribute("data-test-id");
if (accountName) {
accountName = accountName.replace("account-component-", "");
accountNames.push(accountName);
}
}
return accountNames;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-desktop/tests/page/portfolio.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class PortfolioPage extends AppPage {
);
private buySellEntryButton = this.page.locator("data-test-id=buy-sell-entry-button");
private stakeEntryButton = this.page.locator("data-test-id=stake-entry-button");
private showAllButton = this.page.locator("text=Show all");
private showAllButton = this.page.getByText("Show all");
private assetRow = (currency: string) =>
this.page.locator(`data-test-id=asset-row-${currency.toLowerCase()}`);

Expand Down
8 changes: 4 additions & 4 deletions apps/ledger-live-desktop/tests/page/speculos.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { step } from "tests/misc/reporters/step";
import {
pressBoth,
pressRightUntil,
verifyAddress,
verifyAddress as assertAddressesEquality,
verifyAmount,
waitFor,
} from "tests/utils/speculos";
Expand All @@ -17,8 +17,8 @@ export class SpeculosPage extends AppPage {
@step("Verify receive address correctness $0")
async expectValidReceiveAddress(account: Account) {
await waitFor(account.currency.receivePattern[0]);
const addressScreen = await pressRightUntil(account.currency.receivePattern[0]);
expect(verifyAddress(account.address, addressScreen)).toBe(true);
const actualAddress = await pressRightUntil(account.currency.receivePattern[0]);
expect(assertAddressesEquality(account.address, actualAddress)).toBe(true);
await pressRightUntil(account.currency.receivePattern[1]);
await pressBoth();
}
Expand All @@ -28,7 +28,7 @@ export class SpeculosPage extends AppPage {
const amountScreen = await pressRightUntil(DeviceLabels.AMOUT);
expect(verifyAmount(tx.amount, amountScreen)).toBe(true);
const addressScreen = await pressRightUntil(DeviceLabels.ADDRESS);
expect(verifyAddress(tx.recipient, addressScreen)).toBe(true);
expect(assertAddressesEquality(tx.recipient, addressScreen)).toBe(true);
await pressRightUntil(tx.accountToDebit.currency.sendPattern[2]);
await pressBoth();
if (tx.accountToDebit.currency.uiName === Currency.tBTC.uiName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import { Application } from "tests/page";

const currencies: Currency[] = [
Currency.BTC,
Currency.tBTC,
Currency.ETH,
Currency.tETH,
Currency.sepETH,
Currency.XRP,
Currency.DOT,
Currency.TRX,
Currency.ADA,
//Currency.XLM, //TODO: Reactivate when Date.Parse issue is fixed - desactivate time machine for Speculos tests
Currency.BCH,
Currency.ALGO,
Currency.ATOM,
Currency.XTZ,
];

for (const [i, currency] of currencies.entries()) {
Expand Down Expand Up @@ -45,6 +48,7 @@ for (const [i, currency] of currencies.entries()) {
await app.layout.goToAccounts();
await app.accounts.navigateToAccountByName(firstAccountName);
await app.account.expectAccountVisibility(firstAccountName);
await app.account.expectAccountBalance();
await app.account.expectLastOperationsVisibility();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,31 @@ import { Application } from "tests/page";

const accounts: Account[] = [
Account.BTC_1,
Account.tBTC_1,
Account.ETH_1,
Account.tETH_1,
Account.sep_ETH_1,
Account.SOL_1,
Account.TRX_1,
Account.DOT_1,
Account.XRP_1,
Account.ADA_1,
Account.ALGO_1,
Account.XLM_1,
Account.BCH_1,
Account.ATOM_1,
Account.XTZ_1,
];

for (const [i, account] of accounts.entries()) {
test.describe.parallel("Accounts @smoke", () => {
test.use({
userdata: "speculos",
userdata: "speculos-tests-app",
testName: `deleteAccount_${account.currency.uiName}`,
speculosCurrency: specs[account.currency.deviceLabel.replace(/ /g, "_")],
speculosOffset: i,
});

//@TmsLink("B2CQA-320")

test(`[${account.currency.uiName}] Receive`, async ({ page }) => {
test(`[${account.currency.uiName}] Delete Account`, async ({ page }) => {
const app = new Application(page);

await app.layout.goToAccounts();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { specs } from "../../utils/speculos";
import { Application } from "tests/page";

test.use({
userdata: "speculos",
userdata: "speculos-tests-app",
testName: "tokenERC20",
speculosCurrency: specs["Ethereum".replace(/ /g, "_")],
speculosOffset: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ import { specs } from "../../utils/speculos";
import { Application } from "tests/page";

const accounts: Account[] = [
// Derivation path is updated when account (BTC and tBTC) receive money
// Derivation path is updated when account receive money
Account.BTC_1,
Account.tBTC_1,
Account.ETH_1,
Account.tETH_1,
Account.sep_ETH_1,
Account.SOL_1,
Account.TRX_1,
Account.DOT_1,
Account.XRP_1,
Account.BCH_1,
Account.ATOM_1,
Account.XTZ_1,
];

//This test might sporadically fail due to getAppAndVersion issue - Jira: LIVE-12581
//Reactivate test after fixing the GetAppAndVersion issue - Jira: LIVE-12581
for (const [i, account] of accounts.entries()) {
test.describe.parallel("Receive @smoke", () => {
test.describe.skip("Receive @smoke", () => {
test.use({
userdata: "speculos",
userdata: "speculos-tests-app",
testName: `receiveSpeculos_${account.currency.uiName}`,
speculosCurrency: specs[account.currency.deviceLabel.replace(/ /g, "_")],
speculosOffset: i,
Expand Down
10 changes: 2 additions & 8 deletions apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,20 @@ import { Application } from "tests/page";
const transactions = [
//TODO: Reactivate when fees will be stable
//new Transaction(Account.tBTC_1, Account.tBTC_2, "0.00001", "medium"),
//TODO: Reactivate after blobs limit in txpool is full (-32000) resolved - JIRA: BACK-7135
//new Transaction(Account.tETH_1, Account.tETH_2, "0.00001", "medium"),
new Transaction(Account.sep_ETH_1, Account.sep_ETH_2.address, "0.00001", "medium"),
];

//This test might sporadically fail due to getAppAndVersion issue - Jira: LIVE-12581
for (const [i, transaction] of transactions.entries()) {
test.describe.parallel("Send Approve @smoke", () => {
test.use({
userdata: "speculos",
userdata: "speculos-tests-app",
testName: `sendApprove_${transaction.accountToDebit.currency.uiName}`,
speculosCurrency: specs[transaction.accountToDebit.currency.deviceLabel.replace(/ /g, "_")],
speculosOffset: i,
});

//@TmsLink("B2CQA-479")
//@TmsLink("B2CQA-1904")
//@TmsLink("B2CQA-473")
//@TmsLink("B2CQA-472")
//@TmsLink("B2CQA-475")
//@TmsLink("TODO")

test(`[${transaction.accountToDebit.accountName}] send Approve`, async ({ page }) => {
const app = new Application(page);
Expand Down
Loading

0 comments on commit 652631c

Please sign in to comment.