diff --git a/test/helpers/actions.ts b/test/helpers/actions.ts index 680779a..0140c75 100644 --- a/test/helpers/actions.ts +++ b/test/helpers/actions.ts @@ -651,9 +651,6 @@ export async function receiveOnchainFunds( await acknowledgeReceivedPayment(); await mineBlocks(rpc, blocksToMine); - // if (blocksToMine > 0) { - // await waitForToast('PaymentConfirmedToast'); - // } if (driver.isAndroid) { await dismissBackupTimedSheet(); @@ -674,6 +671,8 @@ export async function receiveOnchainFunds( } export type ToastId = + | 'BalanceUnitSwitchedToast' + | 'BalanceHiddenToast' | 'RgsUpdatedToast' | 'RgsErrorToast' | 'ElectrumErrorToast' @@ -684,10 +683,17 @@ export type ToastId = | 'TransactionUnconfirmedToast' | 'TransactionRemovedToast'; -export async function waitForToast(toastId: ToastId, { waitToDisappear = true } = {}) { +export async function waitForToast( + toastId: ToastId, + { waitToDisappear = false, dismiss = true } = {} +) { await elementById(toastId).waitForDisplayed(); if (waitToDisappear) { await elementById(toastId).waitForDisplayed({ reverse: true }); + return; + } + if (dismiss) { + await dragOnElement(toastId, 'up', 0.2); } } diff --git a/test/helpers/setup.ts b/test/helpers/setup.ts index bfcbfd8..a66dca9 100644 --- a/test/helpers/setup.ts +++ b/test/helpers/setup.ts @@ -1,32 +1,13 @@ import { execSync } from 'node:child_process'; -import { elementsById, sleep, tap } from './actions'; +import { sleep } from './actions'; import { getAppId, getAppPath } from './constants'; -export async function launchFreshApp({ tryHandleAlert = true } = {}) { +export async function launchFreshApp() { const appId = getAppId(); await driver.terminateApp(appId); await driver.activateApp(appId); - // workaround to get rid of "Bitkit is running in background" alert - if (tryHandleAlert) { - await sleep(1000); - try { - await tapBalanceToReset(); - } catch { - await tapBalanceToReset(); - } - } - await sleep(500); -} - -async function tapBalanceToReset() { - await tap('TotalBalance'); - const moneyFiatSymbols = await elementsById('MoneyFiatSymbol'); - moneyFiatSymbols[0].waitForDisplayed(); - moneyFiatSymbols[1].waitForDisplayed(); - if ((await moneyFiatSymbols[1].getText()) !== '₿') { - await tap('TotalBalance'); - } + await sleep(3000); } /** diff --git a/test/specs/settings.e2e.ts b/test/specs/settings.e2e.ts index 66057fe..c7fd800 100644 --- a/test/specs/settings.e2e.ts +++ b/test/specs/settings.e2e.ts @@ -43,6 +43,9 @@ describe('@settings - Settings', () => { await tap('TotalBalance'); } await expect(fiatSymbol).toHaveText('$'); + if (driver.isIOS) { + await waitForToast('BalanceUnitSwitchedToast'); + } // - change settings (currency to EUR) // await tap('HeaderMenu'); @@ -122,6 +125,7 @@ describe('@settings - Settings', () => { // switch to Fast await tap('TransactionSpeedSettings'); await tap('fast'); + await sleep(1000); await expect(await elementByIdWithin('TransactionSpeedSettings', 'Value')).toHaveText( /.*Fast/ ); @@ -132,6 +136,7 @@ describe('@settings - Settings', () => { await tap('N1'); await tap('Continue'); await tap('NavigationBack'); + await sleep(1000); await expect(await elementByIdWithin('TransactionSpeedSettings', 'Value')).toHaveText( /.*Custom/ ); @@ -139,6 +144,7 @@ describe('@settings - Settings', () => { // switch back to Normal await tap('TransactionSpeedSettings'); await tap('normal'); + await sleep(1000); await expect(await elementByIdWithin('TransactionSpeedSettings', 'Value')).toHaveText( /.*Normal/ ); @@ -218,6 +224,9 @@ describe('@settings - Settings', () => { await dragOnElement('TotalBalance', 'right', 0.5); } await elementById('ShowBalance').waitForDisplayed(); + if (driver.isIOS) { + await waitForToast('BalanceHiddenToast', { waitToDisappear: false, dismiss: true }); + } // Disable 'swipe to hide balance' await tap('HeaderMenu'); @@ -242,9 +251,12 @@ describe('@settings - Settings', () => { // Restart the app await sleep(3000); - await launchFreshApp({ tryHandleAlert: driver.isAndroid }); + await launchFreshApp(); // Balance should be hidden - await elementById('ShowBalance').waitForDisplayed(); + // https://github.com/synonymdev/bitkit-ios/issues/260 + if (driver.isAndroid) { + await elementById('ShowBalance').waitForDisplayed(); + } }); }); @@ -255,7 +267,9 @@ describe('@settings - Settings', () => { await tap('BackupSettings'); await sleep(1000); await tap('ResetAndRestore'); + await sleep(1000); await tap('NavigationBack'); + await sleep(1000); await tap('BackupWallet'); await sleep(1000); // animation