diff --git a/test/helpers/setup.ts b/test/helpers/setup.ts index 911b7a0..e9dde34 100644 --- a/test/helpers/setup.ts +++ b/test/helpers/setup.ts @@ -30,9 +30,7 @@ export function getRnAppPath(): string { const fallback = path.join(__dirname, '..', '..', 'aut', 'bitkit_rn_regtest.apk'); const appPath = process.env.RN_APK_PATH ?? fallback; if (!fs.existsSync(appPath)) { - throw new Error( - `RN APK not found at: ${appPath}. Set RN_APK_PATH or place it at ${fallback}` - ); + throw new Error(`RN APK not found at: ${appPath}. Set RN_APK_PATH or place it at ${fallback}`); } return appPath; } diff --git a/test/specs/migration.e2e.ts b/test/specs/migration.e2e.ts index 8d03450..b654128 100644 --- a/test/specs/migration.e2e.ts +++ b/test/specs/migration.e2e.ts @@ -1,4 +1,11 @@ -import { elementById, restoreWallet, sleep, tap, typeText, waitForSetupWalletScreenFinish } from '../helpers/actions'; +import { + elementById, + restoreWallet, + sleep, + tap, + typeText, + waitForSetupWalletScreenFinish, +} from '../helpers/actions'; import { ciIt } from '../helpers/suite'; import { getNativeAppPath, getRnAppPath, reinstallAppFromPath } from '../helpers/setup'; @@ -41,7 +48,7 @@ async function restoreLegacyRnWallet(seed: string) { await waitForSetupWalletScreenFinish(); const getStarted = await elementById('GetStartedButton'); - await getStarted.waitForDisplayed( { timeout: 120000 }); + await getStarted.waitForDisplayed({ timeout: 120000 }); await tap('GetStartedButton'); await sleep(1000); } diff --git a/test/specs/numberpad.e2e.ts b/test/specs/numberpad.e2e.ts index 2f09ef7..ad9d917 100644 --- a/test/specs/numberpad.e2e.ts +++ b/test/specs/numberpad.e2e.ts @@ -1,3 +1,4 @@ +import BitcoinJsonRpc from 'bitcoin-json-rpc'; import { completeOnboarding, enterAddress, @@ -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> | 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 () => { @@ -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') { @@ -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`); @@ -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) { diff --git a/test/specs/send.e2e.ts b/test/specs/send.e2e.ts index f7bbb27..7a5f5bd 100644 --- a/test/specs/send.e2e.ts +++ b/test/specs/send.e2e.ts @@ -328,37 +328,31 @@ describe('@send - Send', () => { // send to unified invoice w/ expired invoice let amtAfterUnified3: string; - if (driver.isAndroid) { - console.info('Sending to unified invoice w/ expired invoice...'); - const unified3 = - 'bitcoin:bcrt1qaytrqsrgg75rtxrtr7ur6k75la8p3v95mey48z?lightning=LNBCRT1PN33T20DQQNP4QTNTQ4D2DHDYQ420HAUQF5TS7X32TNW9WGYEPQZQ6R9G69QPHW4RXPP5QU7UYXJYJA9PJV7H6JPEYEFFNZ98N686JDEAAK8AUD5AGC5X70HQSP54V5LEFATCQDEU8TLKAF6MDK3ZLU6MWUA52J4JEMD5XA85KGKMTTQ9QYYSGQCQPCXQRRSSRZJQWU6G4HMGH26EXXQYPQD8XHVWLARA66PL53V7S9CV2EE808UGDRN4APYQQQQQQQGRCQQQQLGQQQQQQGQ2QX7F74RT5SQE0KEYCU47LYMSVY2LM4QA4KLR65PPSY55M0H4VR8AN7WVM9EFVSPYJ5R8EFGVXTGVATAGFTC372VRJ3HEPSEELFZ7FQFCQ9XDU9X'; - console.info({ unified3 }); - - // const ln = - // 'LNBCRT1PN33T20DQQNP4QTNTQ4D2DHDYQ420HAUQF5TS7X32TNW9WGYEPQZQ6R9G69QPHW4RXPP5QU7UYXJYJA9PJV7H6JPEYEFFNZ98N686JDEAAK8AUD5AGC5X70HQSP54V5LEFATCQDEU8TLKAF6MDK3ZLU6MWUA52J4JEMD5XA85KGKMTTQ9QYYSGQCQPCXQRRSSRZJQWU6G4HMGH26EXXQYPQD8XHVWLARA66PL53V7S9CV2EE808UGDRN4APYQQQQQQQGRCQQQQLGQQQQQQGQ2QX7F74RT5SQE0KEYCU47LYMSVY2LM4QA4KLR65PPSY55M0H4VR8AN7WVM9EFVSPYJ5R8EFGVXTGVATAGFTC372VRJ3HEPSEELFZ7FQFCQ9XDU9X'; - // const dec = await lnd.decodePayReq({ payReq: ln }); - // console.info(JSON.stringify(dec, null, 2)); + console.info('Sending to unified invoice w/ expired invoice...'); + const unified3 = + 'bitcoin:bcrt1qaytrqsrgg75rtxrtr7ur6k75la8p3v95mey48z?lightning=LNBCRT1PN33T20DQQNP4QTNTQ4D2DHDYQ420HAUQF5TS7X32TNW9WGYEPQZQ6R9G69QPHW4RXPP5QU7UYXJYJA9PJV7H6JPEYEFFNZ98N686JDEAAK8AUD5AGC5X70HQSP54V5LEFATCQDEU8TLKAF6MDK3ZLU6MWUA52J4JEMD5XA85KGKMTTQ9QYYSGQCQPCXQRRSSRZJQWU6G4HMGH26EXXQYPQD8XHVWLARA66PL53V7S9CV2EE808UGDRN4APYQQQQQQQGRCQQQQLGQQQQQQGQ2QX7F74RT5SQE0KEYCU47LYMSVY2LM4QA4KLR65PPSY55M0H4VR8AN7WVM9EFVSPYJ5R8EFGVXTGVATAGFTC372VRJ3HEPSEELFZ7FQFCQ9XDU9X'; + console.info({ unified3 }); + + // const ln = + // 'LNBCRT1PN33T20DQQNP4QTNTQ4D2DHDYQ420HAUQF5TS7X32TNW9WGYEPQZQ6R9G69QPHW4RXPP5QU7UYXJYJA9PJV7H6JPEYEFFNZ98N686JDEAAK8AUD5AGC5X70HQSP54V5LEFATCQDEU8TLKAF6MDK3ZLU6MWUA52J4JEMD5XA85KGKMTTQ9QYYSGQCQPCXQRRSSRZJQWU6G4HMGH26EXXQYPQD8XHVWLARA66PL53V7S9CV2EE808UGDRN4APYQQQQQQQGRCQQQQLGQQQQQQGQ2QX7F74RT5SQE0KEYCU47LYMSVY2LM4QA4KLR65PPSY55M0H4VR8AN7WVM9EFVSPYJ5R8EFGVXTGVATAGFTC372VRJ3HEPSEELFZ7FQFCQ9XDU9X'; + // const dec = await lnd.decodePayReq({ payReq: ln }); + // console.info(JSON.stringify(dec, null, 2)); - await sleep(1000); - await enterAddress(unified3, { acceptCameraPermission: false }); - await elementById('AssetButton-savings').waitForDisplayed(); - await tap('N1'); - await multiTap('N0', 4); - await tap('ContinueAmount'); - await reviewAmt.waitForDisplayed(); - await expect(reviewAmt).toHaveText('10 000'); - await dragOnElement('GRAB', 'right', 0.95); - await elementById('SendSuccess').waitForDisplayed(); - await tap('Close'); - await expect(totalBalance).not.toHaveText(amtAfterUnified2); - amtAfterUnified3 = await totalBalance.getText(); - console.info({ amtAfterUnified3 }); - await expectTextWithin('ActivitySpending', '7 000'); - } else { - // https://github.com/synonymdev/bitkit-ios/issues/300 - console.info('Skipping sending to unified invoice w/ expired invoice on iOS due to /bitkit-ios/issues/300'); - amtAfterUnified3 = amtAfterUnified2; - } + await sleep(1000); + await enterAddress(unified3, { acceptCameraPermission: false }); + await elementById('AssetButton-savings').waitForDisplayed(); + await tap('N1'); + await multiTap('N0', 4); + await tap('ContinueAmount'); + await reviewAmt.waitForDisplayed(); + await expect(reviewAmt).toHaveText('10 000'); + await dragOnElement('GRAB', 'right', 0.95); + await elementById('SendSuccess').waitForDisplayed(); + await tap('Close'); + await expect(totalBalance).not.toHaveText(amtAfterUnified2); + amtAfterUnified3 = await totalBalance.getText(); + console.info({ amtAfterUnified3 }); + await expectTextWithin('ActivitySpending', '7 000'); // send to unified invoice w/o amount (lightning) console.info('Sending to unified invoice w/o amount (lightning)...'); diff --git a/wdio.conf.ts b/wdio.conf.ts index 7f5dad1..c5f3705 100644 --- a/wdio.conf.ts +++ b/wdio.conf.ts @@ -123,7 +123,7 @@ export const config: WebdriverIO.Config = { // baseUrl: 'http://localhost:8080', // // Default timeout for all waitFor* commands. - waitforTimeout: 30000, + waitforTimeout: process.env.CI ? 30000 : 10000, // // Default timeout in milliseconds for request // if browser driver or grid doesn't send response