Skip to content
This repository was archived by the owner on Feb 8, 2026. It is now read-only.
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
6 changes: 4 additions & 2 deletions e2e/backup.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
electrumPort,
getSeed,
restoreWallet,
waitForBackup,
} from './helpers';
import initWaitForElectrumToSync from '../__tests__/utils/wait-for-electrum';

Expand Down Expand Up @@ -95,7 +96,7 @@ d('Backup', () => {
await element(by.id('NavigationClose')).atIndex(0).tap();

// remove 2 default widgets, leave PriceWidget
await element(by.id('WalletsScrollView')).scroll(200, 'down', NaN, 0.85);
await element(by.id('WalletsScrollView')).scroll(200, 'down', 0);
await element(by.id('WidgetsEdit')).tap();
for (const w of ['NewsWidget', 'BlocksWidget']) {
await element(by.id('WidgetActionDelete').withAncestor(by.id(w))).tap();
Expand All @@ -107,6 +108,7 @@ d('Backup', () => {

// restore wallet
const seed = await getSeed();
await waitForBackup();
await restoreWallet(seed);

// check settings
Expand All @@ -124,7 +126,7 @@ d('Backup', () => {
await sleep(200); // animation

// check widgets
await element(by.id('WalletsScrollView')).scroll(300, 'down', NaN, 0.85);
await element(by.id('WalletsScrollView')).scroll(300, 'down', 0);
await expect(element(by.id('PriceWidget'))).toExist();
await expect(element(by.id('NewsWidget'))).not.toExist();
await expect(element(by.id('BlocksWidget'))).not.toExist();
Expand Down
8 changes: 5 additions & 3 deletions e2e/boost.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
electrumPort,
getSeed,
restoreWallet,
waitForBackup,
} from './helpers';
import initWaitForElectrumToSync from '../__tests__/utils/wait-for-electrum';

Expand Down Expand Up @@ -100,7 +101,7 @@ d('Boost', () => {
await element(by.id('Close')).tap();

// check Activity
await element(by.id('WalletsScrollView')).scrollTo('bottom', NaN, 0.85);
await element(by.id('WalletsScrollView')).scrollTo('bottom', 0);
await expect(element(by.id('ActivityShort-1'))).toBeVisible();
await expect(
element(by.text('100 000').withAncestor(by.id('ActivityShort-2'))),
Expand Down Expand Up @@ -211,7 +212,7 @@ d('Boost', () => {
await element(by.id('Close')).tap();

// check Activity
await element(by.id('WalletsScrollView')).scrollTo('bottom', NaN, 0.85);
await element(by.id('WalletsScrollView')).scrollTo('bottom', 0);
await expect(element(by.id('ActivityShort-1'))).toBeVisible();
await expect(
element(by.text('100 000').withAncestor(by.id('ActivityShort-2'))),
Expand Down Expand Up @@ -273,10 +274,11 @@ d('Boost', () => {

// wipe & restore
const seed = await getSeed();
await waitForBackup();
await restoreWallet(seed);

// check activity after restore
await element(by.id('WalletsScrollView')).scrollTo('bottom', NaN, 0.85);
await element(by.id('WalletsScrollView')).scrollTo('bottom', 0);
await expect(element(by.id('BoostingIcon'))).toBeVisible();
await element(by.id('ActivityShort-1')).tap();
await expect(element(by.id('BoostedButton'))).toBeVisible();
Expand Down
35 changes: 20 additions & 15 deletions e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const checkComplete = (name) => {
}

for (const n of name) {
if (!fs.existsSync(path.join(LOCK_PATH, 'lock-' + n))) {
if (!fs.existsSync(path.join(LOCK_PATH, `lock-${n}`))) {
return false;
}
}
Expand All @@ -38,7 +38,7 @@ export const markComplete = (name) => {
}

fs.mkdirSync(LOCK_PATH, { recursive: true });
fs.writeFileSync(path.join(LOCK_PATH, 'lock-' + name), '1');
fs.writeFileSync(path.join(LOCK_PATH, `lock-${name}`), '1');
};

export const sleep = (ms) => {
Expand All @@ -63,15 +63,13 @@ export async function waitForElementAttribute(
if (attributes[attribute] === expectedValue) {
console.log(`${elementId} has attribute ${attribute}=${expectedValue}`);
break;
} else {
console.log(
`Waiting for ${elementId} to have attribute ${attribute}=${expectedValue}...`,
);
await new Promise((resolve) => {
setTimeout(resolve, 1000);
});
timeout--;
}

console.log(
`Waiting for ${elementId} to have attribute ${attribute}=${expectedValue}...`,
);
await sleep(1000);
timeout--;
}
}

Expand Down Expand Up @@ -102,7 +100,7 @@ export const completeOnboarding = async () => {
await element(by.id('WalletOnboardingClose')).tap();
await sleep(3000); // wait for redux-persist to save state
return;
} catch (e) {}
} catch (_e) {}
}

throw new Error('Tapping "WalletOnboardingClose" timeout');
Expand All @@ -124,9 +122,7 @@ export const launchAndWait = async () => {
await element(by.id('SuggestionsLabel')).tap();
await sleep(1000);
break;
} catch (e) {
continue;
}
} catch (_e) {}
}
};

Expand Down Expand Up @@ -246,6 +242,15 @@ export const restoreWallet = async (seed, passphrase) => {
try {
await element(by.id('SuggestionsLabel')).tap();
break;
} catch (e) {}
} catch (_e) {}
}
};

export const waitForBackup = async () => {
await element(by.id('Settings')).tap();
await element(by.id('BackupSettings')).tap();
await waitFor(element(by.id('AllSynced')))
.toBeVisible()
.withTimeout(40000);
await element(by.id('NavigationClose')).atIndex(0).tap();
};
12 changes: 7 additions & 5 deletions e2e/lightning.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
waitForPeerConnection,
restoreWallet,
getSeed,
waitForBackup,
} from './helpers';

d = checkComplete('lighting-1') ? describe.skip : describe;
Expand Down Expand Up @@ -83,7 +84,7 @@ d('Lightning', () => {
await waitFor(element(by.id('LDKNodeID')))
.toBeVisible()
.withTimeout(60000);
let { label: ldkNodeId } = await element(
const { label: ldkNodeId } = await element(
by.id('LDKNodeID'),
).getAttributes();
await element(by.id('NavigationBack')).atIndex(0).tap();
Expand Down Expand Up @@ -123,7 +124,7 @@ d('Lightning', () => {
await expect(
element(by.id('MoneyText').withAncestor(by.id('TotalSize'))),
).toHaveText('100 000');
await element(by.id('ChannelScrollView')).scrollTo('bottom', NaN, 0.1);
await element(by.id('ChannelScrollView')).scrollTo('bottom', Number.NaN, 0.1);
await expect(element(by.id('IsUsableYes'))).toBeVisible();
await element(by.id('NavigationClose')).atIndex(0).tap();

Expand Down Expand Up @@ -234,7 +235,7 @@ d('Lightning', () => {
.withTimeout(10000);

// check tx history
await element(by.id('WalletsScrollView')).scroll(1000, 'down', NaN, 0.85);
await element(by.id('WalletsScrollView')).scroll(1000, 'down', 0);
await expect(
element(by.text('1 000').withAncestor(by.id('ActivityShort-1'))),
).toBeVisible();
Expand Down Expand Up @@ -315,6 +316,7 @@ d('Lightning', () => {

// wipe and restore wallet
const seed = await getSeed();
await waitForBackup();
await restoreWallet(seed);

// check balance
Expand All @@ -325,7 +327,7 @@ d('Lightning', () => {
.withTimeout(10000);

// check tx history
await element(by.id('WalletsScrollView')).scroll(1000, 'down', NaN, 0.85);
await element(by.id('WalletsScrollView')).scroll(1000, 'down', 0);
await expect(
element(by.text('111').withAncestor(by.id('ActivityShort-2'))),
).toBeVisible();
Expand All @@ -339,7 +341,7 @@ d('Lightning', () => {
await sleep(100);
await element(by.id('Channels')).tap();
await element(by.id('Channel')).atIndex(0).tap();
await element(by.id('ChannelScrollView')).scrollTo('bottom', NaN, 0.1);
await element(by.id('ChannelScrollView')).scrollTo('bottom', Number.NaN, 0.1);
await expect(element(by.id('IsUsableYes'))).toBeVisible();

// close channel
Expand Down
4 changes: 2 additions & 2 deletions e2e/lnurl.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ d('LNURL', () => {
await waitFor(element(by.id('LDKNodeID')))
.toBeVisible()
.withTimeout(60000);
let { label: ldkNodeID } = await element(
const { label: ldkNodeID } = await element(
by.id('LDKNodeID'),
).getAttributes();
await element(by.id('NavigationClose')).atIndex(0).tap();
Expand Down Expand Up @@ -200,7 +200,7 @@ d('LNURL', () => {
.withTimeout(10000);
await element(by.id('Close')).tap();
// check if comment is displayed
await element(by.id('WalletsScrollView')).scrollTo('bottom', NaN, 0.85);
await element(by.id('WalletsScrollView')).scrollTo('bottom', 0);
await element(by.id('ActivityShort-1')).tap();
await expect(element(by.id('InvoiceComment'))).toHaveText('test comment');
await element(by.id('NavigationClose')).tap();
Expand Down
4 changes: 2 additions & 2 deletions e2e/onchain.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ d('Onchain', () => {
).toHaveText('0');

// check Activity
await element(by.id('WalletsScrollView')).scroll(1000, 'down', NaN, 0.85);
await element(by.id('WalletsScrollView')).scroll(1000, 'down', 0);
await expect(element(by.id('ActivityShort-1'))).toBeVisible();
await expect(element(by.id('ActivityShort-2'))).toBeVisible();
await expect(element(by.id('ActivityShort-3'))).toBeVisible();
Expand Down Expand Up @@ -311,7 +311,7 @@ d('Onchain', () => {
).toHaveText('0');

// check number of outputs for send tx
await element(by.id('WalletsScrollView')).scroll(1000, 'down', NaN, 0.85);
await element(by.id('WalletsScrollView')).scroll(1000, 'down', 0);
await expect(element(by.id('ActivityShort-1'))).toBeVisible();
await expect(element(by.id('ActivityShort-2'))).toBeVisible();
await element(by.id('ActivityShowAll')).tap();
Expand Down
4 changes: 2 additions & 2 deletions e2e/send.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ d('Send', () => {
await waitFor(element(by.id('LDKNodeID')))
.toBeVisible()
.withTimeout(60000);
let { label: ldkNodeId } = await element(
const { label: ldkNodeId } = await element(
by.id('LDKNodeID'),
).getAttributes();
await element(by.id('NavigationBack')).atIndex(0).tap();
Expand Down Expand Up @@ -238,7 +238,7 @@ d('Send', () => {
await expect(
element(by.id('MoneyText').withAncestor(by.id('TotalSize'))),
).toHaveText('100 000');
await element(by.id('ChannelScrollView')).scrollTo('bottom', NaN, 0.1);
await element(by.id('ChannelScrollView')).scrollTo('bottom', Number.NaN, 0.1);
await expect(element(by.id('IsUsableYes'))).toBeVisible();
await element(by.id('NavigationClose')).atIndex(0).tap();
await sleep(500);
Expand Down
2 changes: 2 additions & 0 deletions e2e/slashtags.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
electrumPort,
getSeed,
restoreWallet,
waitForBackup,
} from './helpers';
import initWaitForElectrumToSync from '../__tests__/utils/wait-for-electrum';

Expand Down Expand Up @@ -227,6 +228,7 @@ d('Profile and Contacts', () => {

// WIPE APP AND RESTORE FROM THE SEED
const seed = await getSeed();
await waitForBackup();
await restoreWallet(seed);

// CHECK PROFILE, CONTACTS, TRANSACTION
Expand Down
19 changes: 9 additions & 10 deletions e2e/transfer.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
waitForPeerConnection,
getSeed,
restoreWallet,
waitForBackup,
} from './helpers';

d = checkComplete(['transfer-1', 'transfer-2']) ? describe.skip : describe;
Expand Down Expand Up @@ -104,7 +105,7 @@ d('Transfer', () => {
await expect(element(by.text('100 000'))).toBeVisible();
await element(by.id('SpendingAdvancedDefault')).tap();
await element(by.id('SpendingAdvancedNumberField')).tap();
let { label } = await element(
const { label } = await element(
by.id('SpendingAdvancedNumberField'),
).getAttributes();
const lspBalance = Number.parseInt(label, 10);
Expand Down Expand Up @@ -211,13 +212,14 @@ d('Transfer', () => {
await element(by.id('NavigationClose')).tap();

const seed = await getSeed();
await waitForBackup();
await restoreWallet(seed);

// check transfer card
await expect(element(by.id('Suggestion-lightningSettingUp'))).toBeVisible();

// check activity after restore
await element(by.id('WalletsScrollView')).scrollTo('bottom', NaN, 0.85);
await element(by.id('WalletsScrollView')).scrollTo('bottom', 0);
await element(by.id('ActivityShort-1')).tap();
await expect(element(by.id('StatusTransfer'))).toBeVisible();

Expand All @@ -234,10 +236,11 @@ d('Transfer', () => {
.withTimeout(30000);

// reset & restore again
await waitForBackup();
await restoreWallet(seed);

// check activity after restore
await element(by.id('WalletsScrollView')).scrollTo('bottom', NaN, 0.85);
await element(by.id('WalletsScrollView')).scrollTo('bottom', 0);
await expect(element(by.id('BoostingIcon'))).toBeVisible();
await element(by.id('ActivityShort-1')).tap();
await expect(element(by.id('StatusBoosting'))).toBeVisible();
Expand Down Expand Up @@ -275,9 +278,7 @@ d('Transfer', () => {
await waitFor(element(by.id('LDKNodeID')))
.toBeVisible()
.withTimeout(60000);
let { label: ldkNodeId } = await element(
by.id('LDKNodeID'),
).getAttributes();
const { label: ldkNodeId } = await element(by.id('LDKNodeID')).getAttributes();
await element(by.id('NavigationClose')).tap();

// Get LND node id
Expand Down Expand Up @@ -331,12 +332,10 @@ d('Transfer', () => {
await expect(element(by.id('Suggestion-lightningSettingUp'))).toBeVisible();

// check activity
await element(by.id('WalletsScrollView')).scrollTo('bottom', NaN, 0.85);
await element(by.id('WalletsScrollView')).scrollTo('bottom', 0);
await expect(element(by.text('From Savings (±30m)'))).toBeVisible();
await element(by.id('ActivityShort-1')).tap();
await expect(element(by.text('Transfer (±30m)'))).toBeVisible();
await element(by.id('NavigationClose')).tap();
await element(by.id('WalletsScrollView')).scrollTo('top', NaN, 0.85);

// Mine 3 blocks
await rpc.generateToAddress(3, await rpc.getNewAddress());
Expand All @@ -361,7 +360,7 @@ d('Transfer', () => {
await expect(
element(by.id('MoneyText').withAncestor(by.id('TotalSize'))),
).toHaveText('20 000');
await element(by.id('ChannelScrollView')).scrollTo('bottom', NaN, 0.1);
await element(by.id('ChannelScrollView')).scrollTo('bottom', Number.NaN, 0.1);
await expect(element(by.id('IsUsableYes'))).toBeVisible();
await element(by.id('NavigationClose')).atIndex(0).tap();

Expand Down
4 changes: 2 additions & 2 deletions e2e/widgets.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ d('Widgets', () => {
}

// add price widget
await element(by.id('WalletsScrollView')).scroll(300, 'down', NaN, 0.85);
await element(by.id('WalletsScrollView')).scroll(300, 'down', 0);
await element(by.id('WidgetsAdd')).tap();
await element(by.id('WidgetsOnboarding-button')).tap();
await element(by.id('WidgetListItem-price')).tap();
Expand All @@ -50,7 +50,7 @@ d('Widgets', () => {
await element(by.id('WidgetEditField-showSource')).tap();
await element(by.id('WidgetEditPreview')).tap();
await element(by.id('WidgetSave')).tap();
await element(by.id('WalletsScrollView')).scroll(200, 'down', NaN, 0.85);
await element(by.id('WalletsScrollView')).scroll(200, 'down', 0);
await expect(element(by.id('PriceWidget'))).toBeVisible();
await expect(element(by.id('PriceWidgetRow-BTC/EUR'))).toBeVisible();
await expect(element(by.id('PriceWidgetSource'))).toBeVisible();
Expand Down
6 changes: 6 additions & 0 deletions src/hooks/useBlocksWidget.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect, useState } from 'react';
import { __E2E__ } from '../constants/env';
import { i18nTime } from '../utils/i18n';

type TBlocksWidgetData = {
Expand Down Expand Up @@ -132,6 +133,11 @@ const useBlocksWidget = (): TWidgetState => {

fetchData();

// Don't start polling in E2E tests
if (__E2E__) {
return;
}

const interval = setInterval(fetchData, REFRESH_INTERVAL);

return () => {
Expand Down
Loading
Loading