Skip to content

Commit 2356c07

Browse files
authored
Merge pull request #66 from synonymdev/feat/toast-v59
Feat/toast v59
2 parents c52f79f + cc28f0d commit 2356c07

File tree

5 files changed

+64
-38
lines changed

5 files changed

+64
-38
lines changed

test/helpers/actions.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,8 @@ export async function receiveOnchainFunds(
671671
}
672672

673673
export type ToastId =
674+
| 'LnurlPayAmountTooLowToast'
675+
| 'SpendingBalanceReadyToast'
674676
| 'BalanceUnitSwitchedToast'
675677
| 'BalanceHiddenToast'
676678
| 'RgsUpdatedToast'
@@ -791,7 +793,7 @@ export async function dismissQuickPayIntro({
791793
await sleep(500);
792794
} else {
793795
await elementById('QuickpayIntroDescription').waitForDisplayed();
794-
await sleep(500); // wait for the app to settle
796+
await sleep(1000); // wait for the app to settle
795797
await tap('QuickpayIntroCancel');
796798
await sleep(500);
797799
}
@@ -860,6 +862,21 @@ export async function enterAddress(address: string, { acceptCameraPermission = t
860862
await tap('AddressContinue');
861863
}
862864

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+
863880
export async function deleteAllDefaultWidgets() {
864881
await tap('WidgetsEdit');
865882
for (const w of ['Bitcoin Price', 'Bitcoin Blocks', 'Bitcoin Headlines']) {

test/specs/lightning.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
dismissBackgroundPaymentsTimedSheet,
2727
acknowledgeReceivedPayment,
2828
waitForBackup,
29+
waitForToast,
2930
} from '../helpers/actions';
3031
import { reinstallApp } from '../helpers/setup';
3132
import { bitcoinURL, lndConfig } from '../helpers/constants';
@@ -99,8 +100,7 @@ describe('@lightning - Lightning', () => {
99100
await waitForActiveChannel(lnd, ldkNodeId);
100101

101102
// Toast message
102-
await expectText('Spending Balance Ready');
103-
await expectText('Spending Balance Ready', { visible: false });
103+
await waitForToast('SpendingBalanceReadyToast');
104104

105105
// check channel status
106106
await checkChannelStatus();

test/specs/lnurl.e2e.ts

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ import {
1313
swipeFullScreen,
1414
dragOnElement,
1515
completeOnboarding,
16-
acceptAppNotificationAlert,
1716
multiTap,
1817
receiveOnchainFunds,
1918
expectTextWithin,
2019
enterAddress,
2120
expectText,
2221
dismissQuickPayIntro,
2322
doNavigationClose,
23+
waitForToast,
24+
dismissBackgroundPaymentsTimedSheet,
25+
enterAddressViaScanPrompt,
2426
} from '../helpers/actions';
2527
import { reinstallApp } from '../helpers/setup';
2628
import { ciIt } from '../helpers/suite';
@@ -118,16 +120,11 @@ describe('@lnurl - LNURL', () => {
118120
});
119121
console.log('channelReq', channelReq);
120122

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

129125
const channelRequestPromise = waitForEvent(lnurlServer, 'channelRequest:action');
130126
await elementById('ConnectButton').waitForDisplayed();
127+
// await sleep(100000);
131128
await tap('ConnectButton');
132129
await channelRequestPromise;
133130

@@ -142,10 +139,14 @@ describe('@lnurl - LNURL', () => {
142139
await waitForActiveChannel(lnd as any, ldkNodeID);
143140

144141
// Success toast/flow
145-
await dismissQuickPayIntro();
142+
if (driver.isIOS) await waitForToast('SpendingBalanceReadyToast');
143+
if (driver.isAndroid) await dismissQuickPayIntro();
146144
await elementById('ExternalSuccess').waitForDisplayed({ timeout: 30_000 });
147145
await tap('ExternalSuccess-button');
148-
146+
if (driver.isIOS) {
147+
await dismissBackgroundPaymentsTimedSheet();
148+
await dismissQuickPayIntro({ triggerTimedSheet: driver.isIOS });
149+
}
149150
await expectTextWithin('ActivitySpending', '20 001');
150151

151152
// lnurl-pay (min != max) with comment
@@ -159,11 +160,7 @@ describe('@lnurl - LNURL', () => {
159160
});
160161
console.log('payRequest1', payRequest1);
161162

162-
await tap('Scan');
163-
await tap('ScanPrompt');
164-
await typeText('QRInput', payRequest1.encoded);
165-
await confirmInputOnKeyboard();
166-
await tap('DialogConfirm');
163+
await enterAddressViaScanPrompt(payRequest1.encoded, { acceptCameraPermission: false });
167164
await expectTextWithin('SendNumberField', sats);
168165
// Check amounts 99 - 201 not allowed
169166
await multiTap('NRemove', 3); // remove "100"
@@ -175,7 +172,12 @@ describe('@lnurl - LNURL', () => {
175172
await multiTap('NRemove', 3); // remove "201"
176173
await multiTap('N9', 2);
177174
await expectTextWithin('SendNumberField', '99');
178-
await elementById('ContinueAmount').waitForEnabled({ reverse: true });
175+
if (driver.isIOS) {
176+
await tap('ContinueAmount');
177+
await waitForToast('LnurlPayAmountTooLowToast');
178+
} else {
179+
await elementById('ContinueAmount').waitForEnabled({ reverse: true });
180+
}
179181
await multiTap('NRemove', 2); // remove "99"
180182
// go with 150
181183
await tap('N1');
@@ -217,11 +219,14 @@ describe('@lnurl - LNURL', () => {
217219
});
218220
console.log('payRequest2', payRequest2);
219221

220-
await tap('Scan');
221-
await tap('ScanPrompt');
222-
await typeText('QRInput', payRequest2.encoded);
223-
await confirmInputOnKeyboard();
224-
await tap('DialogConfirm');
222+
try {
223+
await enterAddressViaScanPrompt(payRequest2.encoded, { acceptCameraPermission: false });
224+
await elementById('ReviewAmount-primary').waitForDisplayed({ timeout: 5000 });
225+
} catch {
226+
console.warn('ReviewAmount not found, trying again');
227+
await enterAddressViaScanPrompt(payRequest2.encoded, { acceptCameraPermission: false });
228+
await sleep(1000);
229+
}
225230
// Comment input should not be visible
226231
await elementById('CommentInput').waitForDisplayed({ reverse: true });
227232
const reviewAmt = await elementByIdWithin('ReviewAmount-primary', 'MoneyText');
@@ -250,7 +255,7 @@ describe('@lnurl - LNURL', () => {
250255
});
251256
console.log('payRequest3', payRequest3);
252257

253-
await enterAddress(payRequest3.encoded);
258+
await enterAddress(payRequest3.encoded, { acceptCameraPermission: false });
254259
await expectTextWithin('SendNumberField', minSendableSats);
255260
await elementById('ContinueAmount').waitForDisplayed();
256261
await tap('ContinueAmount');
@@ -276,11 +281,17 @@ describe('@lnurl - LNURL', () => {
276281
});
277282
console.log('withdrawRequest1', withdrawRequest1);
278283

279-
await tap('Scan');
280-
await tap('ScanPrompt');
281-
await typeText('QRInput', withdrawRequest1.encoded);
282-
await confirmInputOnKeyboard();
283-
await tap('DialogConfirm');
284+
try {
285+
await enterAddressViaScanPrompt(withdrawRequest1.encoded, {
286+
acceptCameraPermission: false,
287+
});
288+
await elementById('SendNumberField').waitForDisplayed({ timeout: 5000 });
289+
} catch {
290+
console.warn('SendNumberField not found, trying again');
291+
await enterAddressViaScanPrompt(withdrawRequest1.encoded, {
292+
acceptCameraPermission: false,
293+
});
294+
}
284295
await expectTextWithin('SendNumberField', '102');
285296
await tap('ContinueAmount');
286297
await tap('WithdrawConfirmButton');
@@ -308,7 +319,7 @@ describe('@lnurl - LNURL', () => {
308319

309320
// TODO: after https://github.com/synonymdev/bitkit-android/issues/418 is resolved
310321
// we should test the scan flow here
311-
await enterAddress(withdrawRequest2.encoded);
322+
await enterAddress(withdrawRequest2.encoded, { acceptCameraPermission: false });
312323
const reviewAmtWithdraw = await elementByIdWithin('WithdrawAmount-primary', 'MoneyText');
313324
await expect(reviewAmtWithdraw).toHaveText('303');
314325
await tap('WithdrawConfirmButton');
@@ -329,12 +340,8 @@ describe('@lnurl - LNURL', () => {
329340
// lnurl-auth
330341
const loginRequest1 = await lnurlServer.generateNewUrl('login');
331342
console.log('loginRequest1', loginRequest1);
332-
await tap('Scan');
333-
await tap('ScanPrompt');
334-
await typeText('QRInput', loginRequest1.encoded);
335343
const loginEvent = new Promise<void>((resolve) => lnurlServer.once('login', resolve));
336-
await confirmInputOnKeyboard();
337-
await tap('DialogConfirm');
344+
await enterAddressViaScanPrompt(loginRequest1.encoded, { acceptCameraPermission: false });
338345
await tap('continue_button');
339346
await expectText('Signed In');
340347
await loginEvent;

test/specs/send.e2e.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
mineBlocks,
2121
dismissQuickPayIntro,
2222
doNavigationClose,
23+
waitForToast,
2324
acceptAppNotificationAlert,
2425
} from '../helpers/actions';
2526
import { bitcoinURL, lndConfig } from '../helpers/constants';
@@ -163,7 +164,7 @@ describe('@send - Send', () => {
163164
await waitForActiveChannel(lnd, ldkNodeId);
164165

165166
// Toast message
166-
await expectText('Spending Balance Ready');
167+
await waitForToast('SpendingBalanceReadyToast');
167168

168169
// check channel status
169170
await checkChannelStatus();

test/specs/transfer.e2e.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
enterAddress,
2020
dismissQuickPayIntro,
2121
doNavigationClose,
22+
waitForToast,
2223
} from '../helpers/actions';
2324
import {
2425
checkChannelStatus,
@@ -331,7 +332,7 @@ describe('@transfer - Transfer', () => {
331332

332333
await mineBlocks(rpc, 6);
333334
await electrum?.waitForSync();
334-
await expectText('Spending Balance Ready');
335+
await waitForToast('SpendingBalanceReadyToast');
335336
await dismissQuickPayIntro();
336337
await waitForActiveChannel(lnd, ldkNodeId);
337338

0 commit comments

Comments
 (0)