From 8741949eacad3a9c6cc655dafc4c25caf3795bd1 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Wed, 8 Jul 2026 16:23:36 +0200 Subject: [PATCH] test: fix ios hw wallet e2e helpers --- test/helpers/actions.ts | 25 +++++++++++++++++++++++++ test/helpers/hardware-wallet.ts | 25 ++++++++----------------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/test/helpers/actions.ts b/test/helpers/actions.ts index 6b8437a..600be56 100644 --- a/test/helpers/actions.ts +++ b/test/helpers/actions.ts @@ -49,6 +49,17 @@ export function elementById(selector: string): ChainablePromiseElement { } } +/** + * Like elementById, but matches ids that start with `prefix` (suffix is often dynamic). + * Android: resourceId regex. iOS: predicate on `name` (the accessibility identifier). + */ +export function elementByIdPrefix(prefix: string): ChainablePromiseElement { + if (driver.isAndroid) { + return $(`android=new UiSelector().resourceIdMatches(".*${prefix}.*")`); + } + return $(`-ios predicate string:name BEGINSWITH '${prefix}'`); +} + // Find a child testID within an ancestor testID (compatible with both Android and iOS.) export async function elementByIdWithin( ancestorId: string, @@ -387,6 +398,20 @@ export async function tap(testId: string, { timeout = 30_000 }: { timeout?: numb await sleep(100); } +/** + * Taps the first element whose accessibility id starts with `prefix`. + */ +export async function tapFirstByAccessibilityIdPrefix( + prefix: string, + { timeout = 30_000 }: { timeout?: number } = {} +) { + const el = elementByIdPrefix(prefix); + await el.waitForExist({ timeout }); + await sleep(200); + await el.click(); + await sleep(100); +} + export async function multiTap(testId: string, count: number) { await elementById(testId).waitForDisplayed(); await sleep(300); // Allow time for the element to settle diff --git a/test/helpers/hardware-wallet.ts b/test/helpers/hardware-wallet.ts index b6e1f2b..00efacb 100644 --- a/test/helpers/hardware-wallet.ts +++ b/test/helpers/hardware-wallet.ts @@ -6,6 +6,7 @@ import { acknowledgeReceivedPaymentIfPresent, doNavigationClose, elementById, + elementByText, enterAmount, expectBalanceWithWait, expectTextWithin, @@ -14,6 +15,7 @@ import { getAmountUnder, sleep, tap, + tapFirstByAccessibilityIdPrefix, typeText, handleAndroidAlert, waitForToast, @@ -134,7 +136,10 @@ export async function expectHardwareWalletInSettings( export async function renameHardwareWalletFromSettings(currentLabel: string, newLabel: string) { await expectHardwareWalletInSettings(currentLabel, { visible: true }); - await tapFirstHardwareWalletName(); + const nameEl = await elementByText(currentLabel, 'contains'); + await nameEl.waitForDisplayed({ timeout: 30_000 }); + await sleep(200); + await nameEl.click(); await elementById('RenameHardwareWalletInput').waitForDisplayed({ timeout: 30_000 }); await typeText('RenameHardwareWalletInput', newLabel); await tap('RenameHardwareWalletSave'); @@ -237,6 +242,7 @@ export async function transferHardwareWalletToSpending({ // Local backend does not have Blocktank, // so we don't wait for the transfer success screen. await tap('TransferSuccess-button'); + await dismissBackupTimedSheet({ triggerTimedSheet: false }); } else { await mineBlocks(1); if (waitForSync) { @@ -266,7 +272,7 @@ export async function transferHardwareWalletToSpending({ export async function removeHardwareWalletFromSettings(label: string) { await openHardwareWalletSettings(); await expectHardwareWalletInSettings(label, { visible: true }); - await tapFirstHardwareWalletDelete(); + await tapFirstByAccessibilityIdPrefix('HardwareWalletRowDelete_'); await tap('DialogConfirm'); await sleep(500); await expectHardwareWalletInSettings(label, { visible: false }); @@ -328,18 +334,3 @@ async function dismissSpendingBalanceToastIfShown() { } } -async function tapFirstHardwareWalletDelete() { - const deleteButton = await $( - 'android=new UiSelector().resourceIdMatches(".*HardwareWalletRowDelete_.*")' - ); - await deleteButton.waitForDisplayed({ timeout: 30_000 }); - await deleteButton.click(); -} - -async function tapFirstHardwareWalletName() { - const nameButton = await $( - 'android=new UiSelector().resourceIdMatches(".*HardwareWalletRowName.*")' - ); - await nameButton.waitForDisplayed({ timeout: 30_000 }); - await nameButton.click(); -}