@@ -23,6 +23,8 @@ import {
2323 dismissBackgroundPaymentsTimedSheet ,
2424 acknowledgeReceivedPayment ,
2525 typeRecipientInput ,
26+ enterAmount ,
27+ verifyAmountToSend ,
2628} from '../helpers/actions' ;
2729import { lndConfig } from '../helpers/constants' ;
2830import { reinstallApp } from '../helpers/setup' ;
@@ -123,7 +125,8 @@ describe('@send - Send', () => {
123125
124126 // Receive funds and check validation w/ balance
125127 await swipeFullScreen ( 'down' ) ;
126- await receiveOnchainFunds ( ) ;
128+ const amount = 15000 ;
129+ await receiveOnchainFunds ( { sats : amount } ) ;
127130
128131 await tap ( 'Send' ) ;
129132 await sleep ( 500 ) ;
@@ -138,7 +141,13 @@ describe('@send - Send', () => {
138141 await typeAddressAndVerifyContinue ( { address : address2 } ) ;
139142 }
140143
141- // check validation for unified invoice when balance is enough
144+ // type amount over balance and verify you cannot continue
145+ await tap ( 'AddressContinue' ) ;
146+ await enterAmount ( amount + 1 ) ;
147+ await elementById ( 'ContinueAmount' ) . waitForEnabled ( { reverse : true } ) ;
148+ await tap ( 'NavigationBack' ) ;
149+
150+ // check validation for unified invoice when balance is enough (10_000 sats)
142151 const unified1 = 'bitcoin:bcrt1q07x3wl76zdxvdsz3qzzkvxrjg3n6t4tz2vnsx8?amount=0.0001' ;
143152 try {
144153 await typeAddressAndVerifyContinue ( { address : unified1 } ) ;
@@ -147,7 +156,13 @@ describe('@send - Send', () => {
147156 await typeAddressAndVerifyContinue ( { address : unified1 } ) ;
148157 }
149158
150- // check validation for unified invoice when balance is too low
159+ // verify amount is set correctly
160+ await tap ( 'AddressContinue' ) ;
161+ await verifyAmountToSend ( 10_000 ) ;
162+ await elementById ( 'ContinueAmount' ) . waitForEnabled ( ) ;
163+ await tap ( 'NavigationBack' ) ;
164+
165+ // check validation for unified invoice when balance is too low (200_000 sats)
151166 const unified2 = 'bitcoin:bcrt1q07x3wl76zdxvdsz3qzzkvxrjg3n6t4tz2vnsx8?amount=0.002' ;
152167 try {
153168 await typeRecipientInput ( unified2 , { confirmKeyboard : false } ) ;
@@ -169,6 +184,7 @@ describe('@send - Send', () => {
169184 // - receive lightning funds
170185
171186 // Send
187+ // - try to send amount over balance
172188 // - send to onchain address
173189 // - send to lightning invoice
174190 // - send to unified invoice
@@ -239,11 +255,20 @@ describe('@send - Send', () => {
239255 await expect ( totalBalance ) . toHaveText ( '110 000' ) ; // 100k onchain + 10k lightning
240256 await expectTextWithin ( 'ActivitySpending' , '10 000' ) ;
241257
258+ // try to send amount over balance and verify you cannot continue
259+ console . info ( 'Trying to send ln amount over balance...' ) ;
260+ const { paymentRequest : invoice0 } = await lnd . addInvoice ( { } ) ;
261+ console . info ( { invoice0 } ) ;
262+ await enterAddress ( invoice0 ) ;
263+ await enterAmount ( 10_000 + 1 ) ;
264+ await elementById ( 'ContinueAmount' ) . waitForEnabled ( { reverse : true } ) ;
265+ await swipeFullScreen ( 'down' ) ;
266+
242267 // send to onchain address
243268 console . info ( 'Sending to onchain address...' ) ;
244269 const { address : onchainAddress } = await lnd . newAddress ( ) ;
245270 console . info ( { onchainAddress } ) ;
246- await enterAddress ( onchainAddress ) ;
271+ await enterAddress ( onchainAddress , { acceptCameraPermission : false } ) ;
247272 await elementById ( 'AssetButton-savings' ) . waitForDisplayed ( ) ;
248273 await tap ( 'N1' ) ;
249274 await multiTap ( 'N0' , 4 ) ;
0 commit comments