Skip to content

Commit 10cc40f

Browse files
committed
refactor(mobile): unify tab navigation selectors and enhance portfolio screen identification
1 parent 2be6bcf commit 10cc40f

File tree

4 files changed

+20
-41
lines changed

4 files changed

+20
-41
lines changed

apps/ledger-live-mobile/src/mvvm/features/Portfolio/screens/Portfolio/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export const PortfolioScreen = ({ navigation }: NavigationProps) => {
158158
<>
159159
<CheckLanguageAvailability />
160160
<CheckTermOfUseUpdate />
161-
<Animated.View style={{ flex: 1 }}>
161+
<Animated.View testID="portfolio-screen" style={{ flex: 1 }}>
162162
<RefreshableCollapsibleHeaderFlatList
163163
data={data}
164164
renderItem={renderItem<React.JSX.Element>}

apps/ledger-live-mobile/src/screens/Portfolio/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ function PortfolioScreen({ navigation }: NavigationProps) {
252252
<>
253253
<CheckLanguageAvailability />
254254
<CheckTermOfUseUpdate />
255-
<Animated.View style={{ flex: 1 }}>
255+
<Animated.View testID="portfolio-screen" style={{ flex: 1 }}>
256256
<RefreshableCollapsibleHeaderFlatList
257257
data={data}
258258
renderItem={renderItem<React.JSX.Element>}

e2e/mobile/page/wallet/mainNavigation.page.ts

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import { element, by } from "detox";
22
import { Step } from "jest-allure2-reporter/api";
33
import { openDeeplink } from "../../helpers/commonHelpers";
44

5+
type Wallet40TabName = "home" | "swap" | "earn" | "card";
6+
57
export default class MainNavigationPage {
68
// --- Wallet 4.0 bottom tabs ---
7-
wallet40HomeTab = () => element(by.id("w40-tab-home"));
8-
wallet40SwapTab = () => element(by.id("w40-tab-swap"));
9-
wallet40EarnTab = () => element(by.id("w40-tab-earn"));
10-
wallet40CardTab = () => element(by.id("w40-tab-card"));
9+
wallet40Tab = (tabName: Wallet40TabName) => element(by.id(`w40-tab-${tabName}`));
1110

1211
// --- Wallet 4.0 top bar buttons ---
1312
topBarMyLedgerId = "topbar-myledger";
@@ -23,8 +22,7 @@ export default class MainNavigationPage {
2322
legacyMyLedgerTabId = "TabBarManager";
2423

2524
// --- Destination page verification IDs ---
26-
portfolioAccountsListId = "PortfolioAccountsList";
27-
portfolioEmptyListId = "PortfolioEmptyList";
25+
portfolioScreenId = "portfolio-screen";
2826
swapFormId = "swap-form-tab";
2927
earnScreenId = "earn-screen";
3028
cardScreenId = "card-landing-screen";
@@ -39,36 +37,21 @@ export default class MainNavigationPage {
3937

4038
@Step("Wait for Wallet 4.0 navigation to be ready")
4139
async waitForWallet40Ready() {
42-
await waitForElementById(this.topBarSettingsId, 120000);
40+
await waitForElementById(this.topBarSettingsId);
4341
}
4442

4543
@Step("Wait for Legacy navigation to be ready")
4644
async waitForLegacyReady() {
47-
await waitForElementById(this.legacyMyLedgerTabId, 120000);
45+
await waitForElementById(this.legacyMyLedgerTabId);
4846
}
4947

5048
// =====================
5149
// Wallet 4.0 Tab Actions
5250
// =====================
5351

54-
@Step("Tap Home tab (Wallet 4.0)")
55-
async tapWallet40HomeTab() {
56-
await this.wallet40HomeTab().tap();
57-
}
58-
59-
@Step("Tap Swap tab (Wallet 4.0)")
60-
async tapWallet40SwapTab() {
61-
await this.wallet40SwapTab().tap();
62-
}
63-
64-
@Step("Tap Earn tab (Wallet 4.0)")
65-
async tapWallet40EarnTab() {
66-
await this.wallet40EarnTab().tap();
67-
}
68-
69-
@Step("Tap Card tab (Wallet 4.0)")
70-
async tapWallet40CardTab() {
71-
await this.wallet40CardTab().tap();
52+
@Step("Tap W40 tab")
53+
async tapWallet40Tab(tabName: Wallet40TabName) {
54+
await this.wallet40Tab(tabName).tap();
7255
}
7356

7457
// =====================
@@ -125,10 +108,10 @@ export default class MainNavigationPage {
125108

126109
@Step("Expect Wallet 4.0 bottom tabs to be visible")
127110
async expectWallet40BottomTabsVisible() {
128-
await detoxExpect(this.wallet40HomeTab()).toBeVisible();
129-
await detoxExpect(this.wallet40SwapTab()).toBeVisible();
130-
await detoxExpect(this.wallet40EarnTab()).toBeVisible();
131-
await detoxExpect(this.wallet40CardTab()).toBeVisible();
111+
await detoxExpect(this.wallet40Tab("home")).toBeVisible();
112+
await detoxExpect(this.wallet40Tab("swap")).toBeVisible();
113+
await detoxExpect(this.wallet40Tab("earn")).toBeVisible();
114+
await detoxExpect(this.wallet40Tab("card")).toBeVisible();
132115
}
133116

134117
@Step("Expect Wallet 4.0 top bar to be visible")
@@ -175,11 +158,7 @@ export default class MainNavigationPage {
175158

176159
@Step("Expect Portfolio page visible")
177160
async expectPortfolioPageVisible() {
178-
try {
179-
await waitForElementById(this.portfolioAccountsListId, 5000);
180-
} catch {
181-
await waitForElementById(this.portfolioEmptyListId, 5000);
182-
}
161+
await waitForElementById(this.portfolioScreenId);
183162
}
184163

185164
@Step("Expect Swap page visible")

e2e/mobile/specs/mainNavigationWallet40.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,25 @@ describe("Wallet 4.0 Main Navigation", () => {
3434
});
3535

3636
it("should navigate to Swap via bottom tab and show Swap page", async () => {
37-
await app.mainNavigation.tapWallet40SwapTab();
37+
await app.mainNavigation.tapWallet40Tab("swap");
3838
await app.mainNavigation.expectSwapPageVisible();
3939
await app.mainNavigation.expectWallet40BottomTabsVisible();
4040
});
4141

4242
it("should navigate to Earn via bottom tab and show Earn page", async () => {
43-
await app.mainNavigation.tapWallet40EarnTab();
43+
await app.mainNavigation.tapWallet40Tab("earn");
4444
await app.mainNavigation.expectEarnPageVisible();
4545
await app.mainNavigation.expectWallet40BottomTabsVisible();
4646
});
4747

4848
it("should navigate to Card via bottom tab and show Card page", async () => {
49-
await app.mainNavigation.tapWallet40CardTab();
49+
await app.mainNavigation.tapWallet40Tab("card");
5050
await app.mainNavigation.expectCardPageVisible();
5151
await app.mainNavigation.expectWallet40BottomTabsVisible();
5252
});
5353

5454
it("should navigate back to Portfolio via Home tab", async () => {
55-
await app.mainNavigation.tapWallet40HomeTab();
55+
await app.mainNavigation.tapWallet40Tab("home");
5656
await app.mainNavigation.expectPortfolioPageVisible();
5757
await app.mainNavigation.expectWallet40BottomTabsVisible();
5858
await app.mainNavigation.expectWallet40TopBarVisible();

0 commit comments

Comments
 (0)