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
11 changes: 9 additions & 2 deletions test/helpers/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,15 +673,22 @@ export async function receiveOnchainFunds(
}
}

type ToastId =
export type ToastId =
| 'RgsUpdatedToast'
| 'RgsErrorToast'
| 'ElectrumErrorToast'
| 'ElectrumUpdatedToast'
| 'PaymentFailedToast'
| 'ReceivedTransactionReplacedToast'
| 'TransactionReplacedToast'
| 'TransactionUnconfirmedToast'
| 'TransactionRemovedToast';

export async function waitForToast(toastId: ToastId) {
export async function waitForToast(toastId: ToastId, { waitToDisappear = true } = {}) {
await elementById(toastId).waitForDisplayed();
if (waitToDisappear) {
await elementById(toastId).waitForDisplayed({ reverse: true });
}
}

/** Acknowledges the received payment notification by tapping the button.
Expand Down
36 changes: 15 additions & 21 deletions test/specs/settings.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import {
confirmInputOnKeyboard,
multiTap,
getAccessibleText,
expectText,
doNavigationClose,
waitForToast,
ToastId,
} from '../helpers/actions';
import { electrumHost, electrumPort } from '../helpers/constants';
import { launchFreshApp, reinstallApp } from '../helpers/setup';
Expand Down Expand Up @@ -380,7 +381,7 @@ describe('@settings - Settings', () => {

// disconnected warning should appear
await elementById('Disconnected').waitForDisplayed();
await sleep(1000);
await waitForToast('ElectrumErrorToast');

// scanner - check all possible connection formats
// Umbrel format
Expand All @@ -389,26 +390,14 @@ describe('@settings - Settings', () => {
expectedHost: electrumHost,
expectedPort: electrumPort.toString(),
expectedProtocol: 'TCP',
expectedToastMessage: 'ElectrumUpdatedToast',
};
const umbrel2 = {
url: `${electrumHost}:${electrumPort}:s`,
expectedHost: electrumHost,
expectedPort: electrumPort.toString(),
expectedProtocol: 'TLS',
};

// should detect protocol for common ports
const noProto1 = {
url: `${electrumHost}:50001`,
expectedHost: electrumHost,
expectedPort: '50001',
expectedProtocol: 'TCP',
};
const noProto2 = {
url: `${electrumHost}:50002`,
expectedHost: electrumHost,
expectedPort: '50002',
expectedProtocol: 'TLS',
expectedToastMessage: driver.isAndroid ? 'ElectrumErrorToast' : 'ElectrumUpdatedToast',
};

// HTTP URL
Expand All @@ -417,17 +406,20 @@ describe('@settings - Settings', () => {
expectedHost: electrumHost,
expectedPort: electrumPort.toString(),
expectedProtocol: 'TCP',
expectedToastMessage: 'ElectrumUpdatedToast',
};
const http2 = {
url: `https://${electrumHost}:${electrumPort}`,
expectedHost: electrumHost,
expectedPort: electrumPort.toString(),
expectedProtocol: 'TLS',
expectedToastMessage: driver.isAndroid ? 'ElectrumErrorToast' : 'ElectrumUpdatedToast',
};

const conns = [umbrel1, umbrel2, noProto1, noProto2, http1, http2];
const conns = [umbrel1, umbrel2, http1, http2];
let i = 0;
for (const conn of conns) {
console.info(`Testing Electrum connection format #${i + 1}: ${conn.url}`);
await sleep(1000);
await tap('NavigationAction');
// on the first time we need to accept the notifications permission dialog to use camera
Expand All @@ -437,6 +429,7 @@ describe('@settings - Settings', () => {
await tap('ScanPrompt');
await typeText('QRInput', conn.url);
await tap('DialogConfirm');
await waitForToast(conn.expectedToastMessage as ToastId);
await expect(await elementById('HostInput')).toHaveText(conn.expectedHost);
expect(await elementById('PortInput')).toHaveText(conn.expectedPort);
// await expectTextWithin('ElectrumProtocol', conn.expectedProtocol);
Expand All @@ -447,6 +440,9 @@ describe('@settings - Settings', () => {
await elementById('ResetToDefault').waitForEnabled();
await tap('ResetToDefault');
await tap('ConnectToHost');
if (driver.isIOS) {
await waitForToast('ElectrumUpdatedToast', { waitToDisappear: false });
}
await elementById('Connected').waitForDisplayed();
await sleep(1000);
});
Expand All @@ -467,16 +463,14 @@ describe('@settings - Settings', () => {
await typeText('RGSUrl', newUrl);
await confirmInputOnKeyboard();
await tap('ConnectToHost');
const updatedMsg = 'Rapid-Gossip-Sync Server Updated';
await expectText(updatedMsg);
await expectText(updatedMsg, { visible: false });
await waitForToast('RgsUpdatedToast');
const updatedUrl = await (await elementById('ConnectedUrl')).getText();
await expect(updatedUrl).toBe(newUrl);

// switch back to default
await tap('ResetToDefault');
await tap('ConnectToHost');
await expectText(updatedMsg);
await waitForToast('RgsUpdatedToast', { waitToDisappear: false });

const resetUrl = await (await elementById('ConnectedUrl')).getText();
await expect(resetUrl).toBe(rgsUrl);
Expand Down