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
19 changes: 18 additions & 1 deletion test/helpers/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,8 @@ export async function receiveOnchainFunds(
}

export type ToastId =
| 'LnurlPayAmountTooLowToast'
| 'SpendingBalanceReadyToast'
| 'BalanceUnitSwitchedToast'
| 'BalanceHiddenToast'
| 'RgsUpdatedToast'
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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']) {
Expand Down
4 changes: 2 additions & 2 deletions test/specs/lightning.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
dismissBackgroundPaymentsTimedSheet,
acknowledgeReceivedPayment,
waitForBackup,
waitForToast,
} from '../helpers/actions';
import { reinstallApp } from '../helpers/setup';
import { bitcoinURL, lndConfig } from '../helpers/constants';
Expand Down Expand Up @@ -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();
Expand Down
73 changes: 40 additions & 33 deletions test/specs/lnurl.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ import {
swipeFullScreen,
dragOnElement,
completeOnboarding,
acceptAppNotificationAlert,
multiTap,
receiveOnchainFunds,
expectTextWithin,
enterAddress,
expectText,
dismissQuickPayIntro,
doNavigationClose,
waitForToast,
dismissBackgroundPaymentsTimedSheet,
enterAddressViaScanPrompt,
} from '../helpers/actions';
import { reinstallApp } from '../helpers/setup';
import { ciIt } from '../helpers/suite';
Expand Down Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand All @@ -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');
Expand Down Expand Up @@ -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');
Expand All @@ -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<void>((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;
Expand Down
3 changes: 2 additions & 1 deletion test/specs/send.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
mineBlocks,
dismissQuickPayIntro,
doNavigationClose,
waitForToast,
acceptAppNotificationAlert,
} from '../helpers/actions';
import { bitcoinURL, lndConfig } from '../helpers/constants';
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion test/specs/transfer.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
enterAddress,
dismissQuickPayIntro,
doNavigationClose,
waitForToast,
} from '../helpers/actions';
import {
checkChannelStatus,
Expand Down Expand Up @@ -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);

Expand Down