Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions test/helpers/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,13 @@ export async function getClipboardPlaintext(): Promise<string> {
*
* CI intermittently fails `mobile: setPasteboard` with:
* Process ended with exitcode 60 (cmd: 'xcrun simctl pbcopy <udid>')
* Retries that call, then falls back to typeText if the Paste menu never appears
* (so RestoreButton waits don't hang after a silent empty paste).
* Retries that call, then uses the typing fallback if the Paste menu never appears.
*/
export async function pasteIOSText(testId: string, text: string) {
export async function pasteIOSText(
testId: string,
text: string,
typeFallback = () => typeText(testId, text)
) {
if (!driver.isIOS) {
throw new Error('pasteIOSText can only be used on iOS devices');
}
Expand Down Expand Up @@ -543,8 +546,8 @@ export async function pasteIOSText(testId: string, text: string) {
}

if (lastPasteboardError) {
console.warn('→ pasteIOSText: pasteboard unavailable, falling back to typeText');
await typeText(testId, text);
console.warn('→ pasteIOSText: pasteboard unavailable, typing instead');
await typeFallback();
return;
}

Expand All @@ -562,8 +565,8 @@ export async function pasteIOSText(testId: string, text: string) {
await sleep(200); // Allow time for the paste action to propagate
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
console.warn(`→ pasteIOSText: Paste menu unavailable (${message}); falling back to typeText`);
await typeText(testId, text);
console.warn(`→ pasteIOSText: Paste menu unavailable (${message}); typing instead`);
await typeFallback();
}
}

Expand Down Expand Up @@ -996,7 +999,17 @@ export async function restoreWallet(

// Seed
if (driver.isIOS) {
await pasteIOSText('Word-0', seed);
await pasteIOSText('Word-0', seed, async () => {
// Typing the entire phrase into Word-0 fills the fields and dismisses the keyboard as
// soon as the first character of the final word arrives.
const words = seed.trim().split(/\s+/);
for (const [index, word] of words.entries()) {
const field = await elementById(`Word-${index}`);
await field.waitForDisplayed();
await field.setValue(word);
}
await confirmInputOnKeyboard();
});
} else {
await typeText('Word-0', seed);
}
Expand All @@ -1021,6 +1034,7 @@ export async function restoreWallet(
// Restore wallet
const restoreBtn = await elementById('RestoreButton');
await restoreBtn.waitForDisplayed({ timeout: 60_000 });
if (driver.isIOS) await restoreBtn.waitForEnabled({ timeout: 60_000 });
await sleep(150);
await restoreBtn.click();
await waitForSetupWalletScreenFinish();
Expand Down
31 changes: 26 additions & 5 deletions test/helpers/gate-actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { elementById, dragOnElement, formatSats, handleAndroidAlert } from './actions';
import {
elementById,
dragOnElement,
formatSats,
handleAndroidAlert,
withMoveToSparkIntroRecovery,
} from './actions';
import {
actAndExpect,
dismissKeyboardAndExpect,
Expand Down Expand Up @@ -85,10 +91,25 @@ export async function enterGateAddress(

export async function enterGateScanPrompt(address: string, { acceptCameraPermission = true } = {}) {
const permission = 'com.android.permissioncontroller:id/permission_allow_foreground_only_button';
await tapAndExpect(
{ id: 'Scan' },
{ anyVisible: [{ id: 'ScanPrompt' }, ...(driver.isAndroid ? [{ id: permission }] : [])] }
);
const scannerOpened = { anyVisible: [{ id: 'ScanPrompt' }] };
if (driver.isIOS) {
await actAndExpect(
'tap scanner above the tab bar',
async () => {
const scan = await elementById('Scan');
await withMoveToSparkIntroRecovery(() => scan.waitForDisplayed());
const { x, y, width } = await driver.getElementRect(await scan.elementId);
// The scan button protrudes above the overlapping Send and Receive hit regions.
await driver.execute('mobile: tap', { x: x + width / 2, y: y + 2 });
},
scannerOpened
);
} else {
await tapAndExpect(
{ id: 'Scan' },
{ anyVisible: [...scannerOpened.anyVisible, { id: permission }] }
);
}
if (acceptCameraPermission) await handleAndroidAlert('permission_allow_foreground_only_button');
await tapAndExpect({ id: 'ScanPrompt' }, { anyVisible: [{ id: 'QRInput' }] });
await typeAndExpect('QRInput', address, {}, { verifyClear: true });
Expand Down