Skip to content

Commit

Permalink
test: fix Speculos add account test
Browse files Browse the repository at this point in the history
  • Loading branch information
abdurrahman-ledger committed Oct 23, 2024
1 parent 7cde954 commit a66eb73
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export async function launchSpeculos(appName: string, proxyPort: number) {
setEnv("SPECULOS_PID_OFFSET", speculosPidOffset);

const testName = expect.getState().testPath || "unknown";
const speculosDevice = await startSpeculos(testName, specs[appName]);
const speculosDevice = await startSpeculos(testName, specs[appName.replace(/ /g, "_")]);
invariant(speculosDevice, "[E2E Setup] Speculos not started");

const speculosApiPort = speculosDevice.ports.apiPort;
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/e2e/page/accounts/account.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class AccountPage {
accountAssetId = (assetName: string) => `account-assets-${assetName}`;

async waitForAccountPageToLoad(assetName: string) {
await waitForElementById(this.accountTitleId(assetName));
await waitForElementById(this.accountTitleId(assetName.toLowerCase()));
}

async expectAccountBalanceVisible() {
Expand Down
17 changes: 13 additions & 4 deletions apps/ledger-live-mobile/e2e/page/accounts/addAccount.drawer.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import { expect } from "detox";
import { getElementById, openDeeplink, tapById, waitForElementById } from "../../helpers";
import {
getElementById,
openDeeplink,
scrollToId,
tapById,
waitForElementById,
} from "../../helpers";
import { capitalize } from "../../models/currencies";
import { getEnv } from "@ledgerhq/live-env";

const baseLink = "add-account";
const isMock = getEnv("MOCK");

export default class AddAccountDrawer {
accountCardId = (id: string) => getElementById(`account-card-${id}`);
accountId = (currency: string, index: number) => `mock:1:${currency}:MOCK_${currency}_${index}:`;
accountCardId = (id: string | RegExp) => getElementById(new RegExp(`account-card-${id}`));
accountId = (currency: string, index: number) =>
isMock ? `mock:1:${currency}:MOCK_${currency}_${index}:` : `js:2:${currency}:xpub.*`;
accountTitleId = (accountName: string) => getElementById(`test-id-account-${accountName}`);
modalButtonId = "add-accounts-modal-add-button";
currencyRow = (currencyId: string) => `currency-row-${currencyId}`;
Expand All @@ -24,7 +33,7 @@ export default class AddAccountDrawer {

async selectCurrency(currencyId: string) {
const id = this.currencyRow(currencyId);
await waitForElementById(id);
await scrollToId(id);
await tapById(id);
}

Expand Down
30 changes: 22 additions & 8 deletions apps/ledger-live-mobile/e2e/specs/speculos/addAccount.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import { Application } from "../../page";
import { Currency } from "@ledgerhq/live-common/e2e/enum/Currency";

let app: Application;

const currencies = [
{ currency: "bitcoin", nanoApp: "Bitcoin", tmsLink: "B2CQA-101" },
{ currency: "ethereum", nanoApp: "Ethereum", tmsLink: "B2CQA-102" },
{ currency: Currency.BTC, tmsLink: "B2CQA-2499, B2CQA-2644, B2CQA-2672, B2CQA-786" },
{ currency: Currency.ETH, tmsLink: "B2CQA-2503, B2CQA-2645, B2CQA-2673" },
{ currency: Currency.ETC, tmsLink: "B2CQA-2502, B2CQA-2646, B2CQA-2674" },
{ currency: Currency.XRP, tmsLink: "B2CQA-2505, B2CQA-2647, B2CQA-2675" },
{ currency: Currency.DOT, tmsLink: "B2CQA-2504, B2CQA-2648, B2CQA-2676" },
{ currency: Currency.TRX, tmsLink: "B2CQA-2508, B2CQA-2649, B2CQA-2677" },
{ currency: Currency.ADA, tmsLink: "B2CQA-2500, B2CQA-2650, B2CQA-2678" },
{ currency: Currency.XLM, tmsLink: "B2CQA-2506, B2CQA-2651, B2CQA-2679" },
{ currency: Currency.BCH, tmsLink: "B2CQA-2498, B2CQA-2652, B2CQA-2680" },
{ currency: Currency.ALGO, tmsLink: "B2CQA-2497, B2CQA-2653, B2CQA-2681" },
{ currency: Currency.ATOM, tmsLink: "B2CQA-2501, B2CQA-2654, B2CQA-2682" },
{ currency: Currency.XTZ, tmsLink: "B2CQA-2507, B2CQA-2655, B2CQA-2683" },
{ currency: Currency.SOL, tmsLink: "B2CQA-2642, B2CQA-2656, B2CQA-2684" },
{ currency: Currency.TON, tmsLink: "B2CQA-2643, B2CQA-2657, B2CQA-2685" },
];

describe("Add accounts", () => {
Expand All @@ -13,21 +26,22 @@ describe("Add accounts", () => {
await app.portfolio.waitForPortfolioPageToLoad();
});

currencies.forEach(({ currency, nanoApp, tmsLink }) => {
currencies.forEach(({ currency, tmsLink }) => {
let deviceNumber: number;

$TmsLink(tmsLink);
it(`${currency}: add accounts`, async () => {
it(`${currency.name}: add accounts`, async () => {
await app.addAccount.openViaDeeplink();
await app.addAccount.selectCurrency(currency);
await app.common.performSearch(currency.name);
await app.addAccount.selectCurrency(currency.currencyId);

deviceNumber = await app.common.addSpeculos(nanoApp);
deviceNumber = await app.common.addSpeculos(currency.speculosApp.name);

await app.addAccount.startAccountsDiscovery();
await app.addAccount.expectAccountDiscovery(currency, 1);
await app.addAccount.expectAccountDiscovery(currency.currencyId, 1);
await app.addAccount.finishAccountsDiscovery();
await app.addAccount.tapSuccessCta();
await app.account.waitForAccountPageToLoad(currency);
await app.account.waitForAccountPageToLoad(currency.name);
await app.account.expectAccountBalanceVisible();
});

Expand Down

0 comments on commit a66eb73

Please sign in to comment.