Skip to content

Commit 22a023e

Browse files
committed
adjust numberpad
1 parent 671eb24 commit 22a023e

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

test/specs/numberpad.e2e.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import BitcoinJsonRpc from 'bitcoin-json-rpc';
12
import {
23
completeOnboarding,
34
enterAddress,
@@ -8,14 +9,30 @@ import {
89
tap,
910
doNavigationClose,
1011
expectTextWithin,
12+
receiveOnchainFunds,
13+
elementById,
1114
} from '../helpers/actions';
15+
import initElectrum from '../helpers/electrum';
1216
import { launchFreshApp, reinstallApp } from '../helpers/setup';
1317
import { ciIt } from '../helpers/suite';
18+
import { bitcoinURL } from '../helpers/constants';
1419

1520
describe('@numberpad - NumberPad', () => {
21+
let electrum: Awaited<ReturnType<typeof initElectrum>> | undefined;
22+
const rpc = new BitcoinJsonRpc(bitcoinURL);
1623
before(async () => {
24+
let balance = await rpc.getBalance();
25+
const address = await rpc.getNewAddress();
26+
27+
while (balance < 10) {
28+
await rpc.generateToAddress(10, address);
29+
balance = await rpc.getBalance();
30+
}
31+
32+
electrum = await initElectrum();
1733
await reinstallApp();
1834
await completeOnboarding();
35+
await receiveOnchainFunds(rpc, { sats: 10_000 });
1936
});
2037

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

7592
await tap('N000');
7693
await expectText('123 000');
94+
await checkContinueButton(mode, { aboveBalance: true });
7795

7896
// Switch to USD
7997
await tap(`${mode}NumberPadUnit`);
98+
await checkContinueButton(mode, { aboveBalance: true });
99+
80100
// reset to 0
81101
await multiTap('NRemove', 8);
82102
if (mode === 'Send') {
@@ -94,6 +114,7 @@ async function modernDenominationChecks(mode: NumberpadMode) {
94114
await tap('NDecimal');
95115
await tap('N1');
96116
await expectText('1.01');
117+
await checkContinueButton(mode, { aboveBalance: false });
97118

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

135156
// still there
136157
await expectText('4.20690000');
158+
await checkContinueButton(mode);
159+
}
160+
161+
async function checkContinueButton(
162+
mode: NumberpadMode,
163+
{ aboveBalance = true }: { aboveBalance?: boolean } = {}
164+
) {
165+
if (mode === 'Send') {
166+
// make sure Continue button is disabled as amount is above balance
167+
if (driver.isAndroid) return; // https://github.com/synonymdev/bitkit-android/issues/611
168+
await elementById('ContinueAmount').waitForEnabled({ reverse: aboveBalance });
169+
} else {
170+
// In receive mode Continue is always enabled
171+
await elementById('ReceiveNumberPadSubmit').waitForEnabled();
172+
}
137173
}
138174

139175
async function makeSureIsBitcoinInput(mode: NumberpadMode) {

0 commit comments

Comments
 (0)