diff --git a/test/helpers/actions.ts b/test/helpers/actions.ts index c8a777b..3a23118 100644 --- a/test/helpers/actions.ts +++ b/test/helpers/actions.ts @@ -671,6 +671,8 @@ export async function receiveOnchainFunds( } export type ToastId = + | 'LnurlPayAmountTooLowToast' + | 'SpendingBalanceReadyToast' | 'BalanceUnitSwitchedToast' | 'BalanceHiddenToast' | 'RgsUpdatedToast' @@ -791,7 +793,7 @@ export async function dismissQuickPayIntro({ await sleep(500); } else { await elementById('QuickpayIntroDescription').waitForDisplayed(); - await sleep(500); // wait for the app to settle + await sleep(1000); // wait for the app to settle await tap('QuickpayIntroCancel'); await sleep(500); } @@ -860,6 +862,21 @@ export async function enterAddress(address: string, { acceptCameraPermission = t await tap('AddressContinue'); } +export async function enterAddressViaScanPrompt( + address: string, + { acceptCameraPermission = true } = {} +) { + await tap('Scan'); + await sleep(700); + if (acceptCameraPermission) { + await acceptAppNotificationAlert('permission_allow_foreground_only_button'); + } + await tap('ScanPrompt'); + await typeText('QRInput', address); + await confirmInputOnKeyboard(); + await tap('DialogConfirm'); +} + export async function deleteAllDefaultWidgets() { await tap('WidgetsEdit'); for (const w of ['Bitcoin Price', 'Bitcoin Blocks', 'Bitcoin Headlines']) { diff --git a/test/specs/lightning.e2e.ts b/test/specs/lightning.e2e.ts index 4d62309..336ef1e 100644 --- a/test/specs/lightning.e2e.ts +++ b/test/specs/lightning.e2e.ts @@ -26,6 +26,7 @@ import { dismissBackgroundPaymentsTimedSheet, acknowledgeReceivedPayment, waitForBackup, + waitForToast, } from '../helpers/actions'; import { reinstallApp } from '../helpers/setup'; import { bitcoinURL, lndConfig } from '../helpers/constants'; @@ -99,8 +100,7 @@ describe('@lightning - Lightning', () => { await waitForActiveChannel(lnd, ldkNodeId); // Toast message - await expectText('Spending Balance Ready'); - await expectText('Spending Balance Ready', { visible: false }); + await waitForToast('SpendingBalanceReadyToast'); // check channel status await checkChannelStatus(); diff --git a/test/specs/lnurl.e2e.ts b/test/specs/lnurl.e2e.ts index 7da9f89..425c66a 100644 --- a/test/specs/lnurl.e2e.ts +++ b/test/specs/lnurl.e2e.ts @@ -13,7 +13,6 @@ import { swipeFullScreen, dragOnElement, completeOnboarding, - acceptAppNotificationAlert, multiTap, receiveOnchainFunds, expectTextWithin, @@ -21,6 +20,9 @@ import { expectText, dismissQuickPayIntro, doNavigationClose, + waitForToast, + dismissBackgroundPaymentsTimedSheet, + enterAddressViaScanPrompt, } from '../helpers/actions'; import { reinstallApp } from '../helpers/setup'; import { ciIt } from '../helpers/suite'; @@ -118,16 +120,11 @@ describe('@lnurl - LNURL', () => { }); console.log('channelReq', channelReq); - await tap('Scan'); - // on the first time we need to accept the notifications permission dialog to use camera - await acceptAppNotificationAlert('permission_allow_foreground_only_button'); - await tap('ScanPrompt'); - await typeText('QRInput', channelReq.encoded); - await confirmInputOnKeyboard(); - await tap('DialogConfirm'); + await enterAddressViaScanPrompt(channelReq.encoded); const channelRequestPromise = waitForEvent(lnurlServer, 'channelRequest:action'); await elementById('ConnectButton').waitForDisplayed(); + // await sleep(100000); await tap('ConnectButton'); await channelRequestPromise; @@ -142,10 +139,14 @@ describe('@lnurl - LNURL', () => { await waitForActiveChannel(lnd as any, ldkNodeID); // Success toast/flow - await dismissQuickPayIntro(); + if (driver.isIOS) await waitForToast('SpendingBalanceReadyToast'); + if (driver.isAndroid) await dismissQuickPayIntro(); await elementById('ExternalSuccess').waitForDisplayed({ timeout: 30_000 }); await tap('ExternalSuccess-button'); - + if (driver.isIOS) { + await dismissBackgroundPaymentsTimedSheet(); + await dismissQuickPayIntro({ triggerTimedSheet: driver.isIOS }); + } await expectTextWithin('ActivitySpending', '20 001'); // lnurl-pay (min != max) with comment @@ -159,11 +160,7 @@ describe('@lnurl - LNURL', () => { }); console.log('payRequest1', payRequest1); - await tap('Scan'); - await tap('ScanPrompt'); - await typeText('QRInput', payRequest1.encoded); - await confirmInputOnKeyboard(); - await tap('DialogConfirm'); + await enterAddressViaScanPrompt(payRequest1.encoded, { acceptCameraPermission: false }); await expectTextWithin('SendNumberField', sats); // Check amounts 99 - 201 not allowed await multiTap('NRemove', 3); // remove "100" @@ -175,7 +172,12 @@ describe('@lnurl - LNURL', () => { await multiTap('NRemove', 3); // remove "201" await multiTap('N9', 2); await expectTextWithin('SendNumberField', '99'); - await elementById('ContinueAmount').waitForEnabled({ reverse: true }); + if (driver.isIOS) { + await tap('ContinueAmount'); + await waitForToast('LnurlPayAmountTooLowToast'); + } else { + await elementById('ContinueAmount').waitForEnabled({ reverse: true }); + } await multiTap('NRemove', 2); // remove "99" // go with 150 await tap('N1'); @@ -217,11 +219,14 @@ describe('@lnurl - LNURL', () => { }); console.log('payRequest2', payRequest2); - await tap('Scan'); - await tap('ScanPrompt'); - await typeText('QRInput', payRequest2.encoded); - await confirmInputOnKeyboard(); - await tap('DialogConfirm'); + try { + await enterAddressViaScanPrompt(payRequest2.encoded, { acceptCameraPermission: false }); + await elementById('ReviewAmount-primary').waitForDisplayed({ timeout: 5000 }); + } catch { + console.warn('ReviewAmount not found, trying again'); + await enterAddressViaScanPrompt(payRequest2.encoded, { acceptCameraPermission: false }); + await sleep(1000); + } // Comment input should not be visible await elementById('CommentInput').waitForDisplayed({ reverse: true }); const reviewAmt = await elementByIdWithin('ReviewAmount-primary', 'MoneyText'); @@ -250,7 +255,7 @@ describe('@lnurl - LNURL', () => { }); console.log('payRequest3', payRequest3); - await enterAddress(payRequest3.encoded); + await enterAddress(payRequest3.encoded, { acceptCameraPermission: false }); await expectTextWithin('SendNumberField', minSendableSats); await elementById('ContinueAmount').waitForDisplayed(); await tap('ContinueAmount'); @@ -276,11 +281,17 @@ describe('@lnurl - LNURL', () => { }); console.log('withdrawRequest1', withdrawRequest1); - await tap('Scan'); - await tap('ScanPrompt'); - await typeText('QRInput', withdrawRequest1.encoded); - await confirmInputOnKeyboard(); - await tap('DialogConfirm'); + try { + await enterAddressViaScanPrompt(withdrawRequest1.encoded, { + acceptCameraPermission: false, + }); + await elementById('SendNumberField').waitForDisplayed({ timeout: 5000 }); + } catch { + console.warn('SendNumberField not found, trying again'); + await enterAddressViaScanPrompt(withdrawRequest1.encoded, { + acceptCameraPermission: false, + }); + } await expectTextWithin('SendNumberField', '102'); await tap('ContinueAmount'); await tap('WithdrawConfirmButton'); @@ -308,7 +319,7 @@ describe('@lnurl - LNURL', () => { // TODO: after https://github.com/synonymdev/bitkit-android/issues/418 is resolved // we should test the scan flow here - await enterAddress(withdrawRequest2.encoded); + await enterAddress(withdrawRequest2.encoded, { acceptCameraPermission: false }); const reviewAmtWithdraw = await elementByIdWithin('WithdrawAmount-primary', 'MoneyText'); await expect(reviewAmtWithdraw).toHaveText('303'); await tap('WithdrawConfirmButton'); @@ -329,12 +340,8 @@ describe('@lnurl - LNURL', () => { // lnurl-auth const loginRequest1 = await lnurlServer.generateNewUrl('login'); console.log('loginRequest1', loginRequest1); - await tap('Scan'); - await tap('ScanPrompt'); - await typeText('QRInput', loginRequest1.encoded); const loginEvent = new Promise((resolve) => lnurlServer.once('login', resolve)); - await confirmInputOnKeyboard(); - await tap('DialogConfirm'); + await enterAddressViaScanPrompt(loginRequest1.encoded, { acceptCameraPermission: false }); await tap('continue_button'); await expectText('Signed In'); await loginEvent; diff --git a/test/specs/send.e2e.ts b/test/specs/send.e2e.ts index 7f20238..6e74b56 100644 --- a/test/specs/send.e2e.ts +++ b/test/specs/send.e2e.ts @@ -20,6 +20,7 @@ import { mineBlocks, dismissQuickPayIntro, doNavigationClose, + waitForToast, acceptAppNotificationAlert, } from '../helpers/actions'; import { bitcoinURL, lndConfig } from '../helpers/constants'; @@ -163,7 +164,7 @@ describe('@send - Send', () => { await waitForActiveChannel(lnd, ldkNodeId); // Toast message - await expectText('Spending Balance Ready'); + await waitForToast('SpendingBalanceReadyToast'); // check channel status await checkChannelStatus(); diff --git a/test/specs/transfer.e2e.ts b/test/specs/transfer.e2e.ts index d6cac74..7ff2dde 100644 --- a/test/specs/transfer.e2e.ts +++ b/test/specs/transfer.e2e.ts @@ -19,6 +19,7 @@ import { enterAddress, dismissQuickPayIntro, doNavigationClose, + waitForToast, } from '../helpers/actions'; import { checkChannelStatus, @@ -331,7 +332,7 @@ describe('@transfer - Transfer', () => { await mineBlocks(rpc, 6); await electrum?.waitForSync(); - await expectText('Spending Balance Ready'); + await waitForToast('SpendingBalanceReadyToast'); await dismissQuickPayIntro(); await waitForActiveChannel(lnd, ldkNodeId);