Skip to content

Commit dcf875d

Browse files
committed
extract enterAddressViaScanPrompt
1 parent 6bbcb05 commit dcf875d

File tree

3 files changed

+29
-43
lines changed

3 files changed

+29
-43
lines changed

test/helpers/actions.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,21 @@ export async function enterAddress(address: string, { acceptCameraPermission = t
862862
await tap('AddressContinue');
863863
}
864864

865+
export async function enterAddressViaScanPrompt(
866+
address: string,
867+
{ acceptCameraPermission = true } = {}
868+
) {
869+
await tap('Scan');
870+
await sleep(700);
871+
if (acceptCameraPermission) {
872+
await acceptAppNotificationAlert('permission_allow_foreground_only_button');
873+
}
874+
await tap('ScanPrompt');
875+
await typeText('QRInput', address);
876+
await confirmInputOnKeyboard();
877+
await tap('DialogConfirm');
878+
}
879+
865880
export async function deleteAllDefaultWidgets() {
866881
await tap('WidgetsEdit');
867882
for (const w of ['Bitcoin Price', 'Bitcoin Blocks', 'Bitcoin Headlines']) {

test/specs/lnurl.e2e.ts

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
swipeFullScreen,
1414
dragOnElement,
1515
completeOnboarding,
16-
acceptAppNotificationAlert,
1716
multiTap,
1817
receiveOnchainFunds,
1918
expectTextWithin,
@@ -23,6 +22,7 @@ import {
2322
doNavigationClose,
2423
waitForToast,
2524
dismissBackgroundPaymentsTimedSheet,
25+
enterAddressViaScanPrompt,
2626
} from '../helpers/actions';
2727
import { reinstallApp } from '../helpers/setup';
2828
import { ciIt } from '../helpers/suite';
@@ -120,13 +120,7 @@ describe('@lnurl - LNURL', () => {
120120
});
121121
console.log('channelReq', channelReq);
122122

123-
await tap('Scan');
124-
// on the first time we need to accept the notifications permission dialog to use camera
125-
await acceptAppNotificationAlert('permission_allow_foreground_only_button');
126-
await tap('ScanPrompt');
127-
await typeText('QRInput', channelReq.encoded);
128-
await confirmInputOnKeyboard();
129-
await tap('DialogConfirm');
123+
await enterAddressViaScanPrompt(channelReq.encoded);
130124

131125
const channelRequestPromise = waitForEvent(lnurlServer, 'channelRequest:action');
132126
await elementById('ConnectButton').waitForDisplayed();
@@ -166,11 +160,7 @@ describe('@lnurl - LNURL', () => {
166160
});
167161
console.log('payRequest1', payRequest1);
168162

169-
await tap('Scan');
170-
await tap('ScanPrompt');
171-
await typeText('QRInput', payRequest1.encoded);
172-
await confirmInputOnKeyboard();
173-
await tap('DialogConfirm');
163+
await enterAddressViaScanPrompt(payRequest1.encoded, { acceptCameraPermission: false });
174164
await expectTextWithin('SendNumberField', sats);
175165
// Check amounts 99 - 201 not allowed
176166
await multiTap('NRemove', 3); // remove "100"
@@ -230,21 +220,11 @@ describe('@lnurl - LNURL', () => {
230220
console.log('payRequest2', payRequest2);
231221

232222
try {
233-
await tap('Scan');
234-
await tap('ScanPrompt');
235-
await typeText('QRInput', payRequest2.encoded);
236-
await confirmInputOnKeyboard();
237-
await tap('DialogConfirm');
238-
await sleep(1000);
223+
await enterAddressViaScanPrompt(payRequest2.encoded, { acceptCameraPermission: false });
239224
await elementById('ReviewAmount-primary').waitForDisplayed({ timeout: 5000 });
240225
} catch {
241226
console.warn('ReviewAmount not found, trying again');
242-
await dismissQuickPayIntro({ triggerTimedSheet: driver.isIOS });
243-
await tap('Scan');
244-
await tap('ScanPrompt');
245-
await typeText('QRInput', payRequest2.encoded);
246-
await confirmInputOnKeyboard();
247-
await tap('DialogConfirm');
227+
await enterAddressViaScanPrompt(payRequest2.encoded, { acceptCameraPermission: false });
248228
await sleep(1000);
249229
}
250230
// Comment input should not be visible
@@ -302,20 +282,15 @@ describe('@lnurl - LNURL', () => {
302282
console.log('withdrawRequest1', withdrawRequest1);
303283

304284
try {
305-
await tap('Scan');
306-
await tap('ScanPrompt');
307-
await typeText('QRInput', withdrawRequest1.encoded);
308-
await confirmInputOnKeyboard();
309-
await tap('DialogConfirm');
285+
await enterAddressViaScanPrompt(withdrawRequest1.encoded, {
286+
acceptCameraPermission: false,
287+
});
310288
await elementById('SendNumberField').waitForDisplayed({ timeout: 5000 });
311289
} catch {
312290
console.warn('SendNumberField not found, trying again');
313-
await dismissQuickPayIntro({ triggerTimedSheet: driver.isIOS });
314-
await tap('Scan');
315-
await tap('ScanPrompt');
316-
await typeText('QRInput', withdrawRequest1.encoded);
317-
await confirmInputOnKeyboard();
318-
await tap('DialogConfirm');
291+
await enterAddressViaScanPrompt(withdrawRequest1.encoded, {
292+
acceptCameraPermission: false,
293+
});
319294
}
320295
await expectTextWithin('SendNumberField', '102');
321296
await tap('ContinueAmount');
@@ -365,14 +340,10 @@ describe('@lnurl - LNURL', () => {
365340
// lnurl-auth
366341
const loginRequest1 = await lnurlServer.generateNewUrl('login');
367342
console.log('loginRequest1', loginRequest1);
368-
await tap('Scan');
369-
await tap('ScanPrompt');
370-
await typeText('QRInput', loginRequest1.encoded);
371-
const loginEvent = new Promise<void>((resolve) => lnurlServer.once('login', resolve));
372-
await confirmInputOnKeyboard();
373-
await tap('DialogConfirm');
343+
await enterAddressViaScanPrompt(loginRequest1.encoded, { acceptCameraPermission: false });
374344
await tap('continue_button');
375345
await expectText('Signed In');
346+
const loginEvent = new Promise<void>((resolve) => lnurlServer.once('login', resolve));
376347
await loginEvent;
377348
}
378349
);

test/specs/send.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
waitForPeerConnection,
3434
waitForActiveChannel,
3535
openLNDAndSync,
36-
checkChannelStatus
36+
checkChannelStatus,
3737
} from '../helpers/lnd';
3838
import { ciIt } from '../helpers/suite';
3939

0 commit comments

Comments
 (0)