Skip to content

Commit

Permalink
chore: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
abdurrahman-ledger committed Nov 25, 2024
1 parent bad6a05 commit c8b7fc8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
3 changes: 3 additions & 0 deletions apps/ledger-live-mobile/e2e/page/accounts/account.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ export default class AccountPage {
await tapByElement(this.accountAdvancedLogRow());
}

@Step("Expect operation history to be visible")
async expectOperationHistoryVisible(accountId: string) {
const id = this.operationHistorySectionId(accountId);
await scrollToId(id, this.accountScreenScrollView);
await expect(getElementById(id)).toBeVisible();
}

@Step("Expect account balance to be visible")
async expectAccountBalanceVisible(accountId: string) {
await expect(this.accountGraph(accountId)).toBeVisible();
await expect(this.accountBalance(accountId)).toBeVisible();
}

@Step("Expect address index")
async expectAddressIndex(indexNumber: number) {
await this.openAccountSettings();
await this.openAccountAdvancedLogs();
Expand Down
15 changes: 7 additions & 8 deletions apps/ledger-live-mobile/e2e/page/accounts/addAccount.drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class AddAccountDrawer {
continueButtonId = "add-accounts-continue-button";
succesCtaId = "add-accounts-success-cta";

@Step("Open add account via deeplink")
async openViaDeeplink() {
await openDeeplink(baseLink);
}
Expand All @@ -35,32 +36,38 @@ export default class AddAccountDrawer {
await tapById(this.modalButtonId);
}

@Step("Select currency")
async selectCurrency(currencyId: string) {
const id = this.currencyRow(currencyId);
await scrollToId(id);
await tapById(id);
}

@Step("Start accounts discovery")
async startAccountsDiscovery() {
await waitForElementById(this.continueButtonId, 120000);
}

@Step("Expect account discovered")
async expectAccountDiscovery(currencyName: string, currencyId: string, index = 0) {
const accountName = `${currencyName} ${index + 1}`;
await expect(this.accountCard(this.accountId(currencyId, index))).toBeVisible();
await expect(this.accountTitleId(accountName, index)).toHaveText(accountName);
}

@Step("Finish account discovery")
async finishAccountsDiscovery() {
await waitForElementById(this.continueButtonId);
await tapById(this.continueButtonId);
}

@Step("Close add account success screen")
async tapSuccessCta() {
await waitForElementById(this.succesCtaId);
await tapById(this.succesCtaId);
}

@Step("Add only first discovered account")
async addFirstAccount(currency: Currency) {
await this.startAccountsDiscovery();
await this.expectAccountDiscovery(currency.name, currency.currencyId);
Expand All @@ -74,12 +81,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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ export default class AssetAccountsPage {
accountRowId = (accountId: string) => `account-row-${accountId}`;
accountNameRegExp = /account-row-name-.*/;

@Step("Wait for asset page to load")
async waitForAccountPageToLoad(assetName: string) {
await waitForElementById(this.titleId(assetName.toLowerCase()));
}

@Step("Expect asset balance to be visible")
async expectAccountsBalanceVisible() {
await expect(this.assetBalance()).toBeVisible();
}
Expand All @@ -39,6 +41,7 @@ export default class AssetAccountsPage {
await openDeeplink(link);
}

@Step("Go to the account")
async goToAccount(accountId: string) {
await scrollToId(this.accountNameRegExp);
await tapById(this.accountRowId(accountId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { Application } from "../../../page";
import { Currency } from "@ledgerhq/live-common/e2e/enum/Currency";

export async function runAddAccountTest(currency: Currency, tmsLink: string) {
let app: Application;
let deviceNumber: number;
const app = new Application();

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

Expand All @@ -17,8 +19,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 +29,7 @@ export async function runAddAccountTest(currency: Currency, tmsLink: string) {
});

afterAll(async () => {
await app.common.removeSpeculos(deviceNumber);
await app.common.removeSpeculos();
});
});
}

0 comments on commit c8b7fc8

Please sign in to comment.