Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions test/helpers/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -674,6 +671,8 @@ export async function receiveOnchainFunds(
}

export type ToastId =
| 'BalanceUnitSwitchedToast'
| 'BalanceHiddenToast'
| 'RgsUpdatedToast'
| 'RgsErrorToast'
| 'ElectrumErrorToast'
Expand All @@ -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);
}
}

Expand Down
25 changes: 3 additions & 22 deletions test/helpers/setup.ts
Original file line number Diff line number Diff line change
@@ -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);
}

/**
Expand Down
18 changes: 16 additions & 2 deletions test/specs/settings.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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/
);
Expand All @@ -132,13 +136,15 @@ describe('@settings - Settings', () => {
await tap('N1');
await tap('Continue');
await tap('NavigationBack');
await sleep(1000);
await expect(await elementByIdWithin('TransactionSpeedSettings', 'Value')).toHaveText(
/.*Custom/
);

// switch back to Normal
await tap('TransactionSpeedSettings');
await tap('normal');
await sleep(1000);
await expect(await elementByIdWithin('TransactionSpeedSettings', 'Value')).toHaveText(
/.*Normal/
);
Expand Down Expand Up @@ -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');
Expand All @@ -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();
}
});
});

Expand All @@ -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

Expand Down