Skip to content

Commit d96a7c8

Browse files
authored
Merge pull request #56 from synonymdev/feat/onchain-events
Onchain events adjustments
2 parents 19fcfd4 + 2f5cd13 commit d96a7c8

File tree

9 files changed

+156
-136
lines changed

9 files changed

+156
-136
lines changed

test/helpers/actions.ts

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -647,11 +647,10 @@ export async function receiveOnchainFunds(
647647
const address = await getReceiveAddress();
648648
await swipeFullScreen('down');
649649
await rpc.sendToAddress(address, btc);
650-
await mineBlocks(rpc, blocksToMine);
651650

652-
// https://github.com/synonymdev/bitkit-android/issues/268
653-
// send - onchain - receiver sees no confetti — missing-in-ldk-node missing onchain payment event
654-
// await elementById('ReceivedTransaction').waitForDisplayed();
651+
await acknowledgeReceivedPayment();
652+
653+
await mineBlocks(rpc, blocksToMine);
655654

656655
if (driver.isAndroid) {
657656
await dismissBackupTimedSheet();
@@ -671,6 +670,41 @@ export async function receiveOnchainFunds(
671670
}
672671
}
673672

673+
export type ToastId =
674+
| 'BalanceUnitSwitchedToast'
675+
| 'BalanceHiddenToast'
676+
| 'RgsUpdatedToast'
677+
| 'RgsErrorToast'
678+
| 'ElectrumErrorToast'
679+
| 'ElectrumUpdatedToast'
680+
| 'PaymentFailedToast'
681+
| 'ReceivedTransactionReplacedToast'
682+
| 'TransactionReplacedToast'
683+
| 'TransactionUnconfirmedToast'
684+
| 'TransactionRemovedToast';
685+
686+
export async function waitForToast(
687+
toastId: ToastId,
688+
{ waitToDisappear = false, dismiss = true } = {}
689+
) {
690+
await elementById(toastId).waitForDisplayed();
691+
if (waitToDisappear) {
692+
await elementById(toastId).waitForDisplayed({ reverse: true });
693+
return;
694+
}
695+
if (dismiss) {
696+
await dragOnElement(toastId, 'up', 0.2);
697+
}
698+
}
699+
700+
/** Acknowledges the received payment notification by tapping the button.
701+
*/
702+
export async function acknowledgeReceivedPayment() {
703+
await elementById('ReceivedTransaction').waitForDisplayed();
704+
await tap('ReceivedTransactionButton');
705+
await sleep(300);
706+
}
707+
674708
/**
675709
* Triggers the timed backup sheet by navigating to settings and back.
676710
* Since timed sheets are sometimes triggered by user behavior (when user goes back to home screen),
@@ -681,12 +715,25 @@ export async function receiveOnchainFunds(
681715
* await doTriggerTimedSheet();
682716
*/
683717
export async function doTriggerTimedSheet() {
718+
await sleep(700); // wait for any previous animations to finish
684719
await tap('HeaderMenu');
685720
await tap('DrawerSettings');
686721
await sleep(500); // wait for the app to settle
687722
await doNavigationClose();
688723
}
689724

725+
export async function dismissBackgroundPaymentsTimedSheet({
726+
triggerTimedSheet = false,
727+
}: { triggerTimedSheet?: boolean } = {}) {
728+
if (triggerTimedSheet) {
729+
await doTriggerTimedSheet();
730+
}
731+
await elementById('BackgroundPaymentsDescription').waitForDisplayed();
732+
await sleep(500); // wait for the app to settle
733+
await tap('BackgroundPaymentsCancel');
734+
await sleep(500);
735+
}
736+
690737
/**
691738
* Dismisses the backup reminder sheet.
692739
* This sheet is triggered by first onchain balance change.
@@ -710,7 +757,7 @@ export async function dismissBackupTimedSheet({
710757
}
711758
await elementById('BackupIntroViewDescription').waitForDisplayed();
712759
await sleep(500); // wait for the app to settle
713-
await tap('BackupIntroViewCancel');
760+
await swipeFullScreen('down');
714761
await sleep(500);
715762
}
716763

@@ -732,14 +779,22 @@ export async function dismissBackupTimedSheet({
732779
export async function dismissQuickPayIntro({
733780
triggerTimedSheet = false,
734781
}: { triggerTimedSheet?: boolean } = {}) {
735-
if (driver.isIOS) return; // Not supported on iOS yet
736782
if (triggerTimedSheet) {
737783
await doTriggerTimedSheet();
738784
}
739-
await elementById('QuickpayIntro-button').waitForDisplayed();
740-
await sleep(500); // wait for the app to settle
741-
await swipeFullScreen('down');
742-
await sleep(500);
785+
786+
if (driver.isAndroid) {
787+
// TODO: it's temp, change on Android to match iOS testID
788+
await elementById('QuickpayIntro-button').waitForDisplayed();
789+
await sleep(500); // wait for the app to settle
790+
await swipeFullScreen('down');
791+
await sleep(500);
792+
} else {
793+
await elementById('QuickpayIntroDescription').waitForDisplayed();
794+
await sleep(500); // wait for the app to settle
795+
await tap('QuickpayIntroCancel');
796+
await sleep(500);
797+
}
743798
}
744799

745800
/**

test/helpers/lnd.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export async function getLDKNodeID(): Promise<string> {
103103
await elementById('LDKNodeID').waitForDisplayed({ timeout: 60_000 });
104104
const ldkNodeId = (await elementById('LDKNodeID').getText()).trim();
105105
console.info({ ldkNodeId });
106+
await sleep(500);
106107
await tap('NavigationBack');
107108
return ldkNodeId;
108109
}

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/boost.e2e.ts

Lines changed: 27 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
elementByIdWithin,
1616
getTextUnder,
1717
mineBlocks,
18-
attemptRefreshOnHomeScreen,
1918
doNavigationClose,
2019
getSeed,
2120
waitForBackup,
@@ -80,25 +79,16 @@ describe('@boost - Boost', () => {
8079
// check Activity
8180
await elementById('BoostingIcon').waitForDisplayed();
8281
await elementById('ActivityShort-0').waitForDisplayed();
83-
84-
// no additional boost tx item on iOS, there is one on Android
85-
// https://github.com/synonymdev/bitkit-android/issues/463
86-
const showsBoostTxItem = driver.isAndroid;
87-
if (showsBoostTxItem) {
88-
await expect(elementById('ActivityShort-1')).toBeDisplayed();
89-
await expect(elementById('ActivityShort-2')).not.toBeDisplayed();
90-
} else {
91-
await expect(elementById('ActivityShort-1')).not.toBeDisplayed();
92-
await expect(elementById('ActivityShort-2')).not.toBeDisplayed();
93-
}
82+
await elementById('ActivityShort-1').waitForDisplayed();
83+
await expect(elementById('ActivityShort-2')).not.toBeDisplayed();
84+
await expectTextWithin('ActivityShort-0', '-');
85+
await expectTextWithin('ActivityShort-0', 'Boost Fee');
86+
await expectTextWithin('ActivityShort-1', '100 000');
87+
await expectTextWithin('ActivityShort-1', '+');
9488

9589
// orig tx still there
9690
await swipeFullScreen('up');
97-
if (showsBoostTxItem) {
98-
await tap('ActivityShort-1');
99-
} else {
100-
await tap('ActivityShort-0');
101-
}
91+
await tap('ActivityShort-1');
10292
await expectText('100 000', { strategy: 'contains' });
10393
await elementById('BoostedButton').waitForDisplayed();
10494
await elementById('StatusBoosting').waitForDisplayed();
@@ -111,17 +101,14 @@ describe('@boost - Boost', () => {
111101
console.info({ parentTxId });
112102
await doNavigationClose();
113103

114-
if (showsBoostTxItem) {
115-
// new tx
116-
await tap('ActivityShort-0');
117-
await tap('ActivityTxDetails');
118-
const boostTxId = await getTextUnder('TXID');
119-
console.info({ newTxId: boostTxId });
120-
await expect(origTxId !== boostTxId).toBe(true);
121-
// TODO: not implemented yet
122-
// await expect(boostTxId === parentTxId).toBe(true);
123-
await doNavigationClose();
124-
}
104+
// new tx: Boost Fee
105+
await tap('ActivityShort-0');
106+
await tap('ActivityTxDetails');
107+
const boostTxId = await getTextUnder('TXID');
108+
console.info({ newTxId: boostTxId });
109+
await expect(origTxId !== boostTxId).toBe(true);
110+
await expect(boostTxId === parentTxId).toBe(true);
111+
await doNavigationClose();
125112

126113
// wipe & restore
127114
const seed = await getSeed();
@@ -131,39 +118,25 @@ describe('@boost - Boost', () => {
131118
// check activity after restore
132119
await swipeFullScreen('up');
133120
await elementById('BoostingIcon').waitForDisplayed();
134-
if (showsBoostTxItem) {
135-
await elementById('ActivityShort-1').waitForDisplayed();
136-
await tap('ActivityShort-1');
137-
} else {
138-
await elementById('ActivityShort-0').waitForDisplayed();
139-
await tap('ActivityShort-0');
140-
}
121+
await elementById('ActivityShort-1').waitForDisplayed();
122+
await tap('ActivityShort-1');
141123
await elementById('BoostedButton').waitForDisplayed();
142124
await elementById('StatusBoosting').waitForDisplayed();
143125

144126
// mine new block
145127
await mineBlocks(rpc, 1);
146-
147-
// check activity item after mine
148-
// TEMP: refresh until proper events available
149128
await doNavigationClose();
150129
await sleep(500);
151-
await swipeFullScreen('down');
152-
await attemptRefreshOnHomeScreen();
153-
await swipeFullScreen('up');
130+
131+
// check activity item after mine
154132
await elementById('ActivityShort-0').waitForDisplayed();
155-
if (showsBoostTxItem) {
156-
await elementById('ActivityShort-1').waitForDisplayed();
157-
}
158-
// TEMP: refresh until proper events available
133+
await elementById('ActivityShort-1').waitForDisplayed();
159134

160135
await tap('ActivityShort-0');
161136
await elementById('StatusConfirmed').waitForDisplayed();
162137
await doNavigationClose();
163-
if (showsBoostTxItem) {
164-
await tap('ActivityShort-1');
165-
await elementById('StatusConfirmed').waitForDisplayed();
166-
}
138+
await tap('ActivityShort-1');
139+
await elementById('StatusConfirmed').waitForDisplayed();
167140
});
168141

169142
ciIt('@boost_2 - Can do RBF', async () => {
@@ -233,11 +206,10 @@ describe('@boost - Boost', () => {
233206
await elementById('BoostingIcon').waitForDisplayed();
234207
await elementById('ActivityShort-0').waitForDisplayed();
235208
await elementById('ActivityShort-1').waitForDisplayed();
236-
await elementById('ActivityShort-2').waitForDisplayed();
209+
await expect(elementById('ActivityShort-2')).not.toBeDisplayed();
237210
await expectTextWithin('ActivityShort-0', '-');
238-
await expectTextWithin('ActivityShort-1', '-');
239-
await expectTextWithin('ActivityShort-2', '100 000');
240-
await expectTextWithin('ActivityShort-2', '+');
211+
await expectTextWithin('ActivityShort-1', '100 000');
212+
await expectTextWithin('ActivityShort-1', '+');
241213

242214
// new tx
243215
await tap('ActivityShort-0');
@@ -262,32 +234,20 @@ describe('@boost - Boost', () => {
262234
// check activity after restore
263235
await swipeFullScreen('up');
264236
(await elementByIdWithin('ActivityShort-0', 'BoostingIcon')).waitForDisplayed();
265-
(await elementByIdWithin('ActivityShort-1', 'BoostingIcon')).waitForDisplayed();
266237
await tap('ActivityShort-0');
267238
await elementById('BoostedButton').waitForDisplayed();
268239
await elementById('StatusBoosting').waitForDisplayed();
269240
await doNavigationClose();
270-
await tap('ActivityShort-1');
271-
await elementById('BoostedButton').waitForDisplayed();
272-
await elementById('StatusRemoved').waitForDisplayed();
273241

274242
// mine new block
275243
await mineBlocks(rpc, 1);
276-
277-
// check activity item after mine
278-
// TEMP: refresh until proper events available
279244
await doNavigationClose();
280245
await sleep(500);
281-
await swipeFullScreen('down');
282-
await attemptRefreshOnHomeScreen();
283-
await swipeFullScreen('up');
284-
// TEMP: refresh until proper events available
246+
247+
// check activity item after mine
285248
await elementById('ActivityShort-0').waitForDisplayed();
286249
await tap('ActivityShort-0');
287250
await elementById('StatusConfirmed').waitForDisplayed();
288251
await doNavigationClose();
289-
(await elementByIdWithin('ActivityShort-1', 'BoostingIcon')).waitForDisplayed();
290-
await tap('ActivityShort-1');
291-
await elementById('StatusRemoved').waitForDisplayed();
292252
});
293253
});

0 commit comments

Comments
 (0)