Skip to content

Commit

Permalink
chore: review comments, spawning speculos before tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abdurrahman-ledger committed Oct 31, 2024
1 parent e6a91fa commit 073077e
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,4 @@ export default class AddAccountDrawer {
await this.tapSuccessCta();
return accountId;
}

async addAccount(currency: Currency) {
await this.startAccountsDiscovery();
const accountName = await this.expectAccountDiscovery(currency.name, currency.currencyId);
await this.finishAccountsDiscovery();
await this.tapSuccessCta();
return accountName;
}
}
4 changes: 2 additions & 2 deletions apps/ledger-live-mobile/e2e/page/common.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ export default class CommonPage {
return proxyPort;
}

async removeSpeculos(proxyPort: number) {
async removeSpeculos(proxyPort?: number) {
await deleteSpeculos(proxyPort);
await bridge.removeKnownSpeculos(`${proxyAddress}:${proxyPort}`);
proxyPort && (await bridge.removeKnownSpeculos(`${proxyAddress}:${proxyPort}`));
}
}
22 changes: 18 additions & 4 deletions apps/ledger-live-mobile/e2e/page/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ import WalletTabNavigatorPage from "./wallet/walletTabNavigator.page";
import type { Account } from "@ledgerhq/types-live";
import { DeviceLike } from "~/reducers/types";
import { loadAccounts, loadBleState, loadConfig } from "../bridge/server";
import { AppInfos } from "@ledgerhq/live-common/e2e/enum/AppInfos";

type ApplicationOptions = {
speculosApp?: AppInfos;
userdata?: string;
knownDevices?: DeviceLike[];
testAccounts?: Account[];
};

export class Application {
public assetAccountsPage = new AssetAccountsPage();
Expand Down Expand Up @@ -59,11 +67,17 @@ export class Application {
public transfertMenu = new TransfertMenuDrawer();
public walletTabNavigator = new WalletTabNavigatorPage();

static async init(userdata?: string, knownDevices?: DeviceLike[], testAccounts?: Account[]) {
static async init({
speculosApp,
userdata,
knownDevices,
testAccounts,
}: ApplicationOptions) {
const app = new Application();
if (userdata) await loadConfig(userdata, true);
if (knownDevices) await loadBleState({ knownDevices: knownDevices });
if (testAccounts) await loadAccounts(testAccounts);
userdata && (await loadConfig(userdata, true));
knownDevices && (await loadBleState({ knownDevices }));
testAccounts && (await loadAccounts(testAccounts));
speculosApp && (await app.common.addSpeculos(speculosApp.name));

return app;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ const knownDevice = knownDevices.nanoX;

describe("Add account from modal", () => {
beforeAll(async () => {
app = await Application.init("onboardingcompleted", [knownDevice]);
app = await Application.init({
userdata: "onboardingcompleted",
knownDevices: [knownDevice],
});
deviceAction = new DeviceAction(knownDevice);

await app.portfolio.waitForPortfolioPageToLoad();
Expand Down
5 changes: 4 additions & 1 deletion apps/ledger-live-mobile/e2e/specs/deeplinks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const bobaLong = "boba";
$TmsLink("B2CQA-1837");
describe("DeepLinks Tests", () => {
beforeAll(async () => {
app = await Application.init("1AccountBTC1AccountETHReadOnlyFalse", [knownDevices.nanoX]);
app = await Application.init({
userdata: "1AccountBTC1AccountETHReadOnlyFalse",
knownDevices: [knownDevices.nanoX],
});
await app.portfolio.waitForPortfolioPageToLoad();
});

Expand Down
6 changes: 5 additions & 1 deletion apps/ledger-live-mobile/e2e/specs/delegate/cosmos.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ const knownDevice = knownDevices.nanoX;

describe("Cosmos delegate flow", () => {
beforeAll(async () => {
app = await Application.init("onboardingcompleted", [knownDevice], [testAccount]);
app = await Application.init({
userdata: "onboardingcompleted",
knownDevices: [knownDevice],
testAccounts: [testAccount],
});
deviceAction = new DeviceAction(knownDevice);

await app.portfolio.waitForPortfolioPageToLoad();
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/e2e/specs/languageChange.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const verifyLanguageCanBeChanged = (l10n: { lang: string; localization: string }
$TmsLink("B2CQA-2344");
describe("Change Language", () => {
beforeAll(async () => {
app = await Application.init("1AccountBTC1AccountETHReadOnlyFalse");
app = await Application.init({ userdata: "1AccountBTC1AccountETHReadOnlyFalse" });
await app.portfolio.waitForPortfolioPageToLoad();
});

Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/e2e/specs/manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const knownDevice = knownDevices.nanoX;

describe("Test My Ledger", () => {
beforeAll(async () => {
app = await Application.init("onboardingcompleted");
app = await Application.init({ userdata: "onboardingcompleted" });
deviceAction = new DeviceAction(knownDevice);

await app.portfolio.waitForPortfolioPageToLoad();
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/e2e/specs/market.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const asset = "Ethereum (ETH)";

describe("Market page for user with no device", () => {
beforeAll(async () => {
app = await Application.init("1accountEth");
app = await Application.init({ userdata: "1accountEth" });
await app.portfolio.waitForPortfolioPageToLoad();
});

Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/e2e/specs/nftGallery.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const accountCurrency = "ethereum";
// To-Do Fix NFT not available in account
describe.skip("NFT Gallery screen", () => {
beforeAll(async () => {
app = await Application.init("1Account1NFTNotSpam");
app = await Application.init({ userdata: "1Account1NFTNotSpam" });

await app.portfolio.waitForPortfolioPageToLoad();
await app.nftGallery.openViaDeeplink();
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/e2e/specs/password.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const CORRECT_PASSWORD = "passWORD$123!";

describe("Password Lock Screen", () => {
beforeAll(async () => {
app = await Application.init("1AccountBTC1AccountETHReadOnlyFalse");
app = await Application.init({ userdata: "1AccountBTC1AccountETHReadOnlyFalse" });
await app.portfolio.waitForPortfolioPageToLoad();
});

Expand Down
5 changes: 4 additions & 1 deletion apps/ledger-live-mobile/e2e/specs/receive/currencies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ $TmsLink("B2CQA-651");
$TmsLink("B2CQA-1854");
describe("Receive different currency", () => {
beforeAll(async () => {
app = await Application.init("onboardingcompleted", [knownDevice]);
app = await Application.init({
userdata: "onboardingcompleted",
knownDevices: [knownDevice],
});
deviceAction = new DeviceAction(knownDevice);

await app.portfolio.waitForPortfolioPageToLoad();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ const knownDevice = knownDevices.nanoX;

describe("Receive Flow", () => {
beforeAll(async () => {
app = await Application.init("EthAccountXrpAccountReadOnlyFalse", [knownDevice]);
app = await Application.init({
userdata: "EthAccountXrpAccountReadOnlyFalse",
knownDevices: [knownDevice],
});
deviceAction = new DeviceAction(knownDevice);

await app.portfolio.waitForPortfolioPageToLoad();
Expand Down
6 changes: 5 additions & 1 deletion apps/ledger-live-mobile/e2e/specs/send/currencies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ const knownDevice = knownDevices.nanoX;
$TmsLink("B2CQA-1823");
describe("Send flow", () => {
beforeAll(async () => {
app = await Application.init("onboardingcompleted", [knownDevice], testAccounts);
app = await Application.init({
userdata: "onboardingcompleted",
knownDevices: [knownDevice],
testAccounts: testAccounts,
});
deviceAction = new DeviceAction(knownDevice);

await app.portfolio.waitForPortfolioPageToLoad();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ export async function runAddAccountTest(currency: Currency, tmsLink: string) {

describe(`Add accounts - ${currency.name}`, () => {
beforeAll(async () => {
app = await Application.init("onboardingcompleted");
app = await Application.init({
userdata: "onboardingcompleted",
speculosApp: currency.speculosApp,
});
await app.portfolio.waitForPortfolioPageToLoad();
});

Expand All @@ -17,8 +20,6 @@ export async function runAddAccountTest(currency: Currency, tmsLink: string) {
await app.common.performSearch(currency.name);
await app.addAccount.selectCurrency(currency.currencyId);

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

const accountId = await app.addAccount.addFirstAccount(currency);
await app.assetAccountsPage.waitForAccountPageToLoad(currency.name);
await app.assetAccountsPage.expectAccountsBalanceVisible();
Expand All @@ -29,7 +30,7 @@ export async function runAddAccountTest(currency: Currency, tmsLink: string) {
});

afterAll(async () => {
await app.common.removeSpeculos(deviceNumber);
await app.common.removeSpeculos();
});
});
}
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/e2e/specs/swap/dexSwap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let app: Application;

describe("DEX Swap", () => {
beforeAll(async () => {
app = await Application.init("1AccountBTC1AccountETHReadOnlyFalse");
app = await Application.init({ userdata: "1AccountBTC1AccountETHReadOnlyFalse" });

await app.portfolio.waitForPortfolioPageToLoad();
await app.swap.openViaDeeplink();
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/e2e/specs/swap/swap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let app: Application;

describe("Swap", () => {
beforeAll(async () => {
app = await Application.init("1AccountBTC1AccountETHReadOnlyFalse");
app = await Application.init({ userdata: "1AccountBTC1AccountETHReadOnlyFalse" });
await app.portfolio.waitForPortfolioPageToLoad();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Portfolio to load with unknown currency data in accounts", () => {
{ data: badAccount2, version: 0 },
]);

app = await Application.init("onboardingcompleted");
app = await Application.init({ userdata: "onboardingcompleted" });
});

it("opens to empty state", async () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/e2e/specs/wallet-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let app: Application;

describe("Wallet API methods", () => {
beforeAll(async () => {
app = await Application.init("1AccountBTC1AccountETHReadOnlyFalse");
app = await Application.init({ userdata: "1AccountBTC1AccountETHReadOnlyFalse" });
await app.dummyWalletApp.startApp();

await app.portfolio.waitForPortfolioPageToLoad();
Expand Down

0 comments on commit 073077e

Please sign in to comment.