Skip to content
Open
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
6 changes: 5 additions & 1 deletion test/helpers/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,11 @@ export type ToastId =
| 'ReceivedTransactionReplacedToast'
| 'TransactionReplacedToast'
| 'TransactionUnconfirmedToast'
| 'TransactionRemovedToast';
| 'TransactionRemovedToast'
| 'InvalidAddressToast'
| 'ExpiredLightningToast'
| 'InsufficientSpendingToast'
| 'InsufficientSavingsToast';

export async function waitForToast(
toastId: ToastId,
Expand Down
36 changes: 36 additions & 0 deletions test/specs/numberpad.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import BitcoinJsonRpc from 'bitcoin-json-rpc';
import {
completeOnboarding,
enterAddress,
Expand All @@ -8,14 +9,30 @@ import {
tap,
doNavigationClose,
expectTextWithin,
receiveOnchainFunds,
elementById,
} from '../helpers/actions';
import initElectrum from '../helpers/electrum';
import { launchFreshApp, reinstallApp } from '../helpers/setup';
import { ciIt } from '../helpers/suite';
import { bitcoinURL } from '../helpers/constants';

describe('@numberpad - NumberPad', () => {
let electrum: Awaited<ReturnType<typeof initElectrum>> | undefined;
const rpc = new BitcoinJsonRpc(bitcoinURL);
before(async () => {
let balance = await rpc.getBalance();
const address = await rpc.getNewAddress();

while (balance < 10) {
await rpc.generateToAddress(10, address);
balance = await rpc.getBalance();
}

electrum = await initElectrum();
await reinstallApp();
await completeOnboarding();
await receiveOnchainFunds(rpc, { sats: 10_000 });
});

beforeEach(async () => {
Expand Down Expand Up @@ -74,9 +91,12 @@ async function modernDenominationChecks(mode: NumberpadMode) {

await tap('N000');
await expectText('123 000');
await checkContinueButton(mode, { aboveBalance: true });

// Switch to USD
await tap(`${mode}NumberPadUnit`);
await checkContinueButton(mode, { aboveBalance: true });

// reset to 0
await multiTap('NRemove', 8);
if (mode === 'Send') {
Expand All @@ -94,6 +114,7 @@ async function modernDenominationChecks(mode: NumberpadMode) {
await tap('NDecimal');
await tap('N1');
await expectText('1.01');
await checkContinueButton(mode, { aboveBalance: false });

// Switch back to BTC
await tap(`${mode}NumberPadUnit`);
Expand Down Expand Up @@ -134,6 +155,21 @@ async function classicDenominationChecks(mode: NumberpadMode) {

// still there
await expectText('4.20690000');
await checkContinueButton(mode);
}

async function checkContinueButton(
mode: NumberpadMode,
{ aboveBalance = true }: { aboveBalance?: boolean } = {}
) {
if (mode === 'Send') {
// make sure Continue button is disabled as amount is above balance
if (driver.isAndroid) return; // https://github.com/synonymdev/bitkit-android/issues/611
await elementById('ContinueAmount').waitForEnabled({ reverse: aboveBalance });
} else {
// In receive mode Continue is always enabled
await elementById('ReceiveNumberPadSubmit').waitForEnabled();
}
}

async function makeSureIsBitcoinInput(mode: NumberpadMode) {
Expand Down
42 changes: 20 additions & 22 deletions test/specs/send.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,32 @@ describe('@send - Send', () => {
ciIt('@send_1 - Validates payment data in the manual input', async () => {
await tap('Send');
await handleAndroidAlert('permission_allow_foreground_only_button');
await sleep(5000);
await tap('RecipientManual');

// check validation for empty address
await elementById('AddressContinue').waitForEnabled({ reverse: true });

// check validation for invalid data
await typeAddressAndVerifyContinue({ address: 'test123', reverse: true });
await waitForToast('InvalidAddressToast');

//--- skip due to: https://github.com/synonymdev/bitkit-android/issues/354 ---//
// check validation for invalid address (network mismatch)
const mainnetAddress = 'bc1qnc8at2e2navahnz7lvtl39r4dnfzxv3cc9e7ax';
await typeAddressAndVerifyContinue({ address: mainnetAddress, reverse: true });
await waitForToast('InvalidAddressToast');

// // check validation for invalid address (network mismatch)
// const mainnetAddress = 'bc1qnc8at2e2navahnz7lvtl39r4dnfzxv3cc9e7ax';
// await typeAddressAndVerifyContinue({ address: mainnetAddress, reverse: true })

// // check validation for address when balance is 0
// const address = await rpc.getNewAddress();
// console.info({ address });
// await typeAddressAndVerifyContinue({ address: address, reverse: true })

// // check validation for expired invoice
// const invoice =
// 'lnbcrt1pn3zpqpdqqnp4qfh2x8nyvvzq4kf8j9wcaau2chr580l93pnyrh5027l8f7qtm48h6pp5lmwkulnpze4ek4zqwfepguahcr2ma3vfhwa6uepxfd378xlldprssp5wnq34d553g50suuvfy387csx5hx6mdv8zezem6f4tky7rhezycas9qyysgqcqpcxqrrssrzjqtr7pzpunxgwjddwdqucegdphm6776xcarz60gw9gxva0rhal5ntmapyqqqqqqqqpqqqqqlgqqqqqqgq2ql9zpeakxvff9cz5rd6ssc3cngl256u8htm860qv3r28vqkwy9xe3wp0l9ms3zcqvys95yf3r34ytmegz6zynuthh5s0kh7cueunm3mspg3uwpt';
// await typeAddressAndVerifyContinue({ address: invoice, reverse: true })
// check validation for address when balance is 0
const address = await rpc.getNewAddress();
console.info({ address });
await typeAddressAndVerifyContinue({ address: address, reverse: true });
await waitForToast('InsufficientSavingsToast');

//--- skip due to: https://github.com/synonymdev/bitkit-android/issues/354 ---//
// check validation for expired invoice
const invoice =
'lnbcrt1pn3zpqpdqqnp4qfh2x8nyvvzq4kf8j9wcaau2chr580l93pnyrh5027l8f7qtm48h6pp5lmwkulnpze4ek4zqwfepguahcr2ma3vfhwa6uepxfd378xlldprssp5wnq34d553g50suuvfy387csx5hx6mdv8zezem6f4tky7rhezycas9qyysgqcqpcxqrrssrzjqtr7pzpunxgwjddwdqucegdphm6776xcarz60gw9gxva0rhal5ntmapyqqqqqqqqpqqqqqlgqqqqqqgq2ql9zpeakxvff9cz5rd6ssc3cngl256u8htm860qv3r28vqkwy9xe3wp0l9ms3zcqvys95yf3r34ytmegz6zynuthh5s0kh7cueunm3mspg3uwpt';
await typeAddressAndVerifyContinue({ address: invoice, reverse: true });
await waitForToast('ExpiredLightningToast');

// Receive funds and check validation w/ balance
await swipeFullScreen('down');
Expand Down Expand Up @@ -120,13 +121,10 @@ describe('@send - Send', () => {
await typeAddressAndVerifyContinue({ address: unified1 });
}

//--- skip due to: https://github.com/synonymdev/bitkit-android/issues/354 ---//

// // check validation for unified invoice when balance is too low
// const unified2 = 'bitcoin:bcrt1q07x3wl76zdxvdsz3qzzkvxrjg3n6t4tz2vnsx8?amount=0.002';
// await typeAddressAndVerifyContinue({ address: unified2, reverse: true });

//--- skip due to: https://github.com/synonymdev/bitkit-android/issues/354 ---//
// check validation for unified invoice when balance is too low
const unified2 = 'bitcoin:bcrt1q07x3wl76zdxvdsz3qzzkvxrjg3n6t4tz2vnsx8?amount=0.002';
await typeAddressAndVerifyContinue({ address: unified2, reverse: true });
await waitForToast('InsufficientSavingsToast');
});

ciIt('@send_2 - Can receive funds and send to different invoices', async () => {
Expand Down