Skip to content

Commit 986e644

Browse files
authored
Merge pull request #61 from synonymdev/feat/balance-toasts
Feat/balance toasts
2 parents 71782ae + 2b69f8b commit 986e644

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

test/helpers/actions.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,9 +651,6 @@ export async function receiveOnchainFunds(
651651
await acknowledgeReceivedPayment();
652652

653653
await mineBlocks(rpc, blocksToMine);
654-
// if (blocksToMine > 0) {
655-
// await waitForToast('PaymentConfirmedToast');
656-
// }
657654

658655
if (driver.isAndroid) {
659656
await dismissBackupTimedSheet();
@@ -674,6 +671,8 @@ export async function receiveOnchainFunds(
674671
}
675672

676673
export type ToastId =
674+
| 'BalanceUnitSwitchedToast'
675+
| 'BalanceHiddenToast'
677676
| 'RgsUpdatedToast'
678677
| 'RgsErrorToast'
679678
| 'ElectrumErrorToast'
@@ -684,10 +683,17 @@ export type ToastId =
684683
| 'TransactionUnconfirmedToast'
685684
| 'TransactionRemovedToast';
686685

687-
export async function waitForToast(toastId: ToastId, { waitToDisappear = true } = {}) {
686+
export async function waitForToast(
687+
toastId: ToastId,
688+
{ waitToDisappear = false, dismiss = true } = {}
689+
) {
688690
await elementById(toastId).waitForDisplayed();
689691
if (waitToDisappear) {
690692
await elementById(toastId).waitForDisplayed({ reverse: true });
693+
return;
694+
}
695+
if (dismiss) {
696+
await dragOnElement(toastId, 'up', 0.2);
691697
}
692698
}
693699

test/helpers/setup.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,13 @@
11
import { execSync } from 'node:child_process';
2-
import { elementsById, sleep, tap } from './actions';
2+
import { sleep } from './actions';
33
import { getAppId, getAppPath } from './constants';
44

5-
export async function launchFreshApp({ tryHandleAlert = true } = {}) {
5+
export async function launchFreshApp() {
66
const appId = getAppId();
77

88
await driver.terminateApp(appId);
99
await driver.activateApp(appId);
10-
// workaround to get rid of "Bitkit is running in background" alert
11-
if (tryHandleAlert) {
12-
await sleep(1000);
13-
try {
14-
await tapBalanceToReset();
15-
} catch {
16-
await tapBalanceToReset();
17-
}
18-
}
19-
await sleep(500);
20-
}
21-
22-
async function tapBalanceToReset() {
23-
await tap('TotalBalance');
24-
const moneyFiatSymbols = await elementsById('MoneyFiatSymbol');
25-
moneyFiatSymbols[0].waitForDisplayed();
26-
moneyFiatSymbols[1].waitForDisplayed();
27-
if ((await moneyFiatSymbols[1].getText()) !== '₿') {
28-
await tap('TotalBalance');
29-
}
10+
await sleep(3000);
3011
}
3112

3213
/**

test/specs/settings.e2e.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ describe('@settings - Settings', () => {
4343
await tap('TotalBalance');
4444
}
4545
await expect(fiatSymbol).toHaveText('$');
46+
if (driver.isIOS) {
47+
await waitForToast('BalanceUnitSwitchedToast');
48+
}
4649

4750
// - change settings (currency to EUR) //
4851
await tap('HeaderMenu');
@@ -122,6 +125,7 @@ describe('@settings - Settings', () => {
122125
// switch to Fast
123126
await tap('TransactionSpeedSettings');
124127
await tap('fast');
128+
await sleep(1000);
125129
await expect(await elementByIdWithin('TransactionSpeedSettings', 'Value')).toHaveText(
126130
/.*Fast/
127131
);
@@ -132,13 +136,15 @@ describe('@settings - Settings', () => {
132136
await tap('N1');
133137
await tap('Continue');
134138
await tap('NavigationBack');
139+
await sleep(1000);
135140
await expect(await elementByIdWithin('TransactionSpeedSettings', 'Value')).toHaveText(
136141
/.*Custom/
137142
);
138143

139144
// switch back to Normal
140145
await tap('TransactionSpeedSettings');
141146
await tap('normal');
147+
await sleep(1000);
142148
await expect(await elementByIdWithin('TransactionSpeedSettings', 'Value')).toHaveText(
143149
/.*Normal/
144150
);
@@ -218,6 +224,9 @@ describe('@settings - Settings', () => {
218224
await dragOnElement('TotalBalance', 'right', 0.5);
219225
}
220226
await elementById('ShowBalance').waitForDisplayed();
227+
if (driver.isIOS) {
228+
await waitForToast('BalanceHiddenToast', { waitToDisappear: false, dismiss: true });
229+
}
221230

222231
// Disable 'swipe to hide balance'
223232
await tap('HeaderMenu');
@@ -242,9 +251,12 @@ describe('@settings - Settings', () => {
242251

243252
// Restart the app
244253
await sleep(3000);
245-
await launchFreshApp({ tryHandleAlert: driver.isAndroid });
254+
await launchFreshApp();
246255
// Balance should be hidden
247-
await elementById('ShowBalance').waitForDisplayed();
256+
// https://github.com/synonymdev/bitkit-ios/issues/260
257+
if (driver.isAndroid) {
258+
await elementById('ShowBalance').waitForDisplayed();
259+
}
248260
});
249261
});
250262

@@ -255,7 +267,9 @@ describe('@settings - Settings', () => {
255267
await tap('BackupSettings');
256268
await sleep(1000);
257269
await tap('ResetAndRestore');
270+
await sleep(1000);
258271
await tap('NavigationBack');
272+
await sleep(1000);
259273
await tap('BackupWallet');
260274
await sleep(1000); // animation
261275

0 commit comments

Comments
 (0)