Skip to content

Commit

Permalink
Merge pull request #6072 from LedgerHQ/support/B2CQA-2125_detox_fix_a…
Browse files Browse the repository at this point in the history
…ddAccount_tests

[B2CQA-2125] Detox: fix add account tests
  • Loading branch information
abdurrahman-ledger authored Feb 2, 2024
2 parents c6ea968 + 494cac4 commit 0fc0718
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions apps/ledger-live-mobile/e2e/models/accounts/accountsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const baseLink = "accounts";

export default class accountsPage {
accountTitle = (coin: string) => getElementById(`accounts-title-${coin}`);
addAccountCta = () => getElementById("add-account-cta");
addAccountButton = () => getElementById("add-account-button");

async openViaDeeplink() {
await openDeeplink(baseLink);
Expand All @@ -17,6 +17,6 @@ export default class accountsPage {
}

async addAccount() {
await tapByElement(this.addAccountCta());
await tapByElement(this.addAccountButton());
}
}
19 changes: 11 additions & 8 deletions apps/ledger-live-mobile/e2e/models/wallet/portfolioPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
openDeeplink,
scrollToId,
tapByElement,
tapById,
waitForElementById,
} from "../../helpers";

Expand All @@ -12,13 +13,14 @@ export default class PortfolioPage {
zeroBalance = "$0.00";
graphCardBalanceId = "graphCard-balance";
assetBalanceId = "asset-balance";
readOnlyPortfolioId = "PortfolioReadOnlyList";
readOnlyItemsId = "PortfolioReadOnlyItems";
transferScrollListId = "transfer-scroll-list";
stakeMenuButtonId = "transfer-stake-button";
accountsListView = "PortfolioAccountsList";
seeAllTransactionButton = "portfolio-seeAll-transaction";
transactionAmountId = "portfolio-operation-amount";
emptyPortfolioComponent = () => getElementById("PortfolioEmptyAccount");
emptyPortfolioListId = "PortfolioEmptyList";
emptyPortfolioList = () => getElementById(this.emptyPortfolioListId);
portfolioSettingsButton = () => getElementById("settings-icon");
transferButton = () => getElementById("transfer-button");
swapTransferMenuButton = () => getElementById("swap-transfer-button");
Expand All @@ -29,6 +31,7 @@ export default class PortfolioPage {
marketTabButton = () => getElementById("tab-bar-market");
walletTabMarket = () => getElementById("wallet-tab-Market");
earnButton = () => getElementById("tab-bar-earn");
addAccountCta = "add-account-cta";
lastTransactionAmount = () => getElementById(this.transactionAmountId, 0);

navigateToSettings() {
Expand Down Expand Up @@ -61,18 +64,13 @@ export default class PortfolioPage {
return tapByElement(this.receiveTransfertMenuButton());
}

async openAddAccount() {
const element = getElementById("add-account-button");
await element.tap();
}

async receive() {
const element = getElementById("receive-button");
await element.tap();
}

async waitForPortfolioReadOnly() {
await waitForElementById(this.readOnlyPortfolioId);
await waitForElementById(this.readOnlyItemsId);
expect(await getTextOfElement(this.graphCardBalanceId)).toBe(this.zeroBalance);
for (let index = 0; index < 4; index++)
expect(await getTextOfElement(this.assetBalanceId, index)).toBe(this.zeroBalance);
Expand All @@ -98,6 +96,11 @@ export default class PortfolioPage {
return tapByElement(this.earnButton());
}

async addAccount() {
await scrollToId(this.addAccountCta, this.emptyPortfolioListId);
await tapById(this.addAccountCta);
}

async scrollToTransactions() {
await scrollToId(this.seeAllTransactionButton, this.accountsListView);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { knownDevice } from "../../models/devices";
import { loadBleState, loadConfig } from "../../bridge/server";
import PortfolioPage from "../../models/wallet/portfolioPage";
import AccountPage from "../../models/accounts/accountPage";
import AccountsPage from "../../models/accounts/accountsPage";

import DeviceAction from "../../models/DeviceAction";
import AddAccountDrawer from "../../models/accounts/addAccountDrawer";
Expand All @@ -13,7 +12,6 @@ let portfolioPage: PortfolioPage;
let accountPage: AccountPage;
let deviceAction: DeviceAction;
let addAccountDrawer: AddAccountDrawer;
let accountsPage: AccountsPage;

describe("Add account from modal", () => {
beforeAll(async () => {
Expand All @@ -24,13 +22,12 @@ describe("Add account from modal", () => {
accountPage = new AccountPage();
deviceAction = new DeviceAction(knownDevice);
addAccountDrawer = new AddAccountDrawer();
accountsPage = new AccountsPage();

await portfolioPage.waitForPortfolioPageToLoad();
});

it("open add accounts from modal", async () => {
await accountsPage.addAccount();
await portfolioPage.addAccount();
await addAccountDrawer.importWithYourLedger();
});

Expand Down
4 changes: 2 additions & 2 deletions apps/ledger-live-mobile/e2e/specs/onboarding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("Onboarding", () => {
await portfolioPage.waitForPortfolioPageToLoad();
await expect(portfolioPage.portfolioSettingsButton()).toBeVisible();
//should see an empty portfolio page
await expect(portfolioPage.emptyPortfolioComponent()).toBeVisible();
await expect(portfolioPage.emptyPortfolioList()).toBeVisible();
});

it("does the Onboarding and choose to restore a Nano X", async () => {
Expand All @@ -45,7 +45,7 @@ describe("Onboarding", () => {
await onboardingSteps.openLedgerLive();
await portfolioPage.waitForPortfolioPageToLoad();
await expect(portfolioPage.portfolioSettingsButton()).toBeVisible();
await expect(portfolioPage.emptyPortfolioComponent()).toBeVisible();
await expect(portfolioPage.emptyPortfolioList()).toBeVisible();
});

it("does the Onboarding and choose to restore a Nano SP", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ describe("Portfolio to load with unknown currency data in accounts", () => {

it("opens to empty state", async () => {
await portfolioPage.waitForPortfolioPageToLoad();
await expect(await portfolioPage.emptyPortfolioComponent()).toBeVisible();
await expect(await portfolioPage.emptyPortfolioList()).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function ReadOnlyPortfolio({ navigation }: NavigationProps) {
renderItem={({ item }: ListRenderItemInfo<unknown>) => item as JSX.Element}
keyExtractor={(_: unknown, index: number) => String(index)}
showsVerticalScrollIndicator={false}
testID="PortfolioReadOnlyList"
testID="PortfolioReadOnlyItems"
/>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/src/screens/Portfolio/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ function PortfolioScreen({ navigation }: NavigationProps) {
}}
keyExtractor={(_: unknown, index: number) => String(index)}
showsVerticalScrollIndicator={false}
testID={showAssets ? "PortfolioAccountsList" : "PortfolioEmptyAccount"}
testID={showAssets ? "PortfolioAccountsList" : "PortfolioEmptyList"}
/>
<AddAccountsModal
navigation={navigation as unknown as BaseNavigation}
Expand Down

0 comments on commit 0fc0718

Please sign in to comment.