From 72a9086515c3fd4f40d860ac3c6a75de6dcb864f Mon Sep 17 00:00:00 2001 From: Ivan Vershigora Date: Tue, 3 Nov 2020 16:18:46 +0300 Subject: [PATCH] ADD: e2e tests --- BlueComponents.js | 2 +- screen/send/coinControl.js | 7 +- screen/send/details.js | 8 +- screen/send/psbtWithHardwareWallet.js | 7 ++ screen/wallets/transactions.js | 25 +++++-- tests/e2e/bluewallet.spec.js | 102 +++++++++++++++++++++++++- 6 files changed, 140 insertions(+), 11 deletions(-) diff --git a/BlueComponents.js b/BlueComponents.js index 488c63d08..e2f40a28b 100644 --- a/BlueComponents.js +++ b/BlueComponents.js @@ -655,7 +655,7 @@ export const BluePrivateBalance = () => { export const BlueCopyToClipboardButton = ({ stringToCopy, displayText = false }) => { return ( - Clipboard.setString(stringToCopy)}> + Clipboard.setString(stringToCopy)}> {displayText || loc.transactions.details_copy} ); diff --git a/screen/send/coinControl.js b/screen/send/coinControl.js index 9dca1b409..c9fb9dc6b 100644 --- a/screen/send/coinControl.js +++ b/screen/send/coinControl.js @@ -133,6 +133,7 @@ const OutputModalContent = ({ output, wallet, onUseCoin }) => { { /> - onUseCoin([output])} /> + onUseCoin([output])} /> ); }; @@ -210,6 +211,10 @@ const CoinControl = () => { Keyboard.dismiss(); setOutput(false); }} + onBackButtonPress={() => { + Keyboard.dismiss(); + setOutput(false); + }} > diff --git a/screen/send/details.js b/screen/send/details.js index 66d732baa..3109a024e 100644 --- a/screen/send/details.js +++ b/screen/send/details.js @@ -1087,7 +1087,13 @@ export default class SendDetails extends Component { /> )} - + diff --git a/screen/send/psbtWithHardwareWallet.js b/screen/send/psbtWithHardwareWallet.js index db61aa37d..ba314a8de 100644 --- a/screen/send/psbtWithHardwareWallet.js +++ b/screen/send/psbtWithHardwareWallet.js @@ -119,6 +119,10 @@ const styles = StyleSheet.create({ justifyContent: 'center', alignItems: 'center', }, + hidden: { + width: 0, + height: 0, + }, }); export default class PsbtWithHardwareWallet extends Component { @@ -366,6 +370,9 @@ export default class PsbtWithHardwareWallet extends Component { {loc.send.psbt_this_is_psbt} + + {this.state.psbt.toHex()} + { }; const renderListHeaderComponent = () => { - const style = { opacity: isLoading ? 0.5 : 1.0 }; + const style = {}; + if (!isDesktop) { + // we need this button for testing + style.opacity = 0; + style.height = 1; + style.width = 1; + } else if (isLoading) { + style.opacity = 0.5; + } else { + style.opacity = 1.0; + } + return ( @@ -239,11 +250,9 @@ const WalletTransactions = () => { {loc.transactions.list_title} - {isDesktop && ( - - - - )} + + + ); @@ -616,7 +625,9 @@ const WalletTransactions = () => { {!isLightning() && ( - {loc.wallets.list_tap_here_to_buy} + + {loc.wallets.list_tap_here_to_buy} + )} diff --git a/tests/e2e/bluewallet.spec.js b/tests/e2e/bluewallet.spec.js index 5ca8bcf45..857113e27 100644 --- a/tests/e2e/bluewallet.spec.js +++ b/tests/e2e/bluewallet.spec.js @@ -9,7 +9,107 @@ jasmine.getEnv().addReporter({ specDone: result => (jasmine.currentTest = result), }); -describe('BlueWallet UI Tests', () => { +describe.only('BlueWallet UI Tests', () => { + it.only('can manage UTXO', async () => { + await helperImportWallet( + 'zpub6qoWjSiZRHzSYPGYJ6EzxEXJXP1b2Rj9syWwJZFNCmupMwkbSAWSBk3UvSkJyQLEhQpaBAwvhmNj3HPKpwCJiTBB9Tutt46FtEmjL2DoU3J', + 'Imported Watch-only', + '0.00105526 BTC', + ); + + // refresh transactions + await element(by.id('refreshTransactions')).tap(); + await waitFor(element(by.id('NoTxBuyBitcoin'))) + .not.toExist() + .withTimeout(300 * 1000); + + // change note of 0.001 tx output + await element(by.text('0.001')).atIndex(0).tap(); + await element(by.text('details')).tap(); + await expect(element(by.text('49944e90fe917952e36b1967cdbc1139e60c89b4800b91258bf2345a77a8b888'))).toBeVisible(); + await element(by.type('android.widget.EditText')).typeText('test1'); + await element(by.text('Save')).tap(); + await element(by.text('OK')).tap(); + + // back to wallet screen + await device.pressBack(); + await device.pressBack(); + + // open CoinControl + await element(by.id('SendButton')).tap(); + await element(by.text('OK')).tap(); + await element(by.id('advancedOptionsMenuButton')).tap(); + await element(by.id('CoinControl')).tap(); + await waitFor(element(by.id('Loading'))) // wait for outputs to be loaded + .not.toExist() + .withTimeout(300 * 1000); + await expect(element(by.text('test1')).atIndex(0)).toBeVisible(); + + // change output note and freeze it + await element(by.text('test1')).atIndex(0).tap(); + await element(by.id('OutputMemo')).replaceText('test2'); + await element(by.type('android.widget.CompoundButton')).tap(); // freeze switch + await device.pressBack(); // closing modal + await expect(element(by.text('test2')).atIndex(0)).toBeVisible(); + await expect(element(by.text('freeze')).atIndex(0)).toBeVisible(); + + // use frozen output to create tx using "Use coin" feature + await element(by.text('test2')).atIndex(0).tap(); + await element(by.id('UseCoin')).tap(); + await element(by.id('AddressInput')).replaceText('bc1q063ctu6jhe5k4v8ka99qac8rcm2tzjjnuktyrl'); + await element(by.id('advancedOptionsMenuButton')).tap(); + await element(by.id('sendMaxButton')).tap(); + await element(by.text('OK')).tap(); + // setting fee rate: + await element(by.id('chooseFee')).tap(); + await element(by.id('feeCustom')).tap(); + await element(by.type('android.widget.EditText')).typeText('1'); + await element(by.text('OK')).tap(); + + await element(by.id('CreateTransactionButton')).tap(); + await yo('TextHelperForPSBT'); + + const psbthex1 = await extractTextFromElementById('PSBTHex'); + const psbt1 = bitcoin.Psbt.fromHex(psbthex1); + + assert.strictEqual(psbt1.txOutputs.length, 1); + assert.strictEqual(psbt1.txOutputs[0].address, 'bc1q063ctu6jhe5k4v8ka99qac8rcm2tzjjnuktyrl'); + assert.strictEqual(psbt1.txOutputs[0].value, 99808); + assert.strictEqual(psbt1.data.inputs.length, 1); + assert.strictEqual(psbt1.data.inputs[0].witnessUtxo.value, 100000); + + // back to wallet screen + await device.pressBack(); + await device.pressBack(); + + // create tx with unfrozen input + await element(by.id('SendButton')).tap(); + await element(by.id('AddressInput')).replaceText('bc1q063ctu6jhe5k4v8ka99qac8rcm2tzjjnuktyrl'); + await element(by.id('advancedOptionsMenuButton')).tap(); + await element(by.id('sendMaxButton')).tap(); + await element(by.text('OK')).tap(); + // setting fee rate: + await element(by.id('chooseFee')).tap(); + await element(by.id('feeCustom')).tap(); + await element(by.type('android.widget.EditText')).typeText('1'); + await element(by.text('OK')).tap(); + + await element(by.id('CreateTransactionButton')).tap(); + await yo('TextHelperForPSBT'); + + const psbthex2 = await extractTextFromElementById('PSBTHex'); + const psbt2 = bitcoin.Psbt.fromHex(psbthex2); + + console.info('psbthex2', psbthex2) + + assert.strictEqual(psbt2.txOutputs.length, 1); + assert.strictEqual(psbt2.txOutputs[0].address, 'bc1q063ctu6jhe5k4v8ka99qac8rcm2tzjjnuktyrl'); + assert.strictEqual(psbt2.txOutputs[0].value, 99808); + assert.strictEqual(psbt2.data.inputs.length, 1); + assert.strictEqual(psbt2.data.inputs[0].witnessUtxo.value, 5526); + + }); + it('selftest passes', async () => { const lockFile = '/tmp/travislock.' + hashIt(jasmine.currentTest.fullName); if (process.env.TRAVIS) {