diff --git a/test/helpers/actions.ts b/test/helpers/actions.ts index e6109d8..680779a 100644 --- a/test/helpers/actions.ts +++ b/test/helpers/actions.ts @@ -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. diff --git a/test/specs/settings.e2e.ts b/test/specs/settings.e2e.ts index ddc7478..66057fe 100644 --- a/test/specs/settings.e2e.ts +++ b/test/specs/settings.e2e.ts @@ -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'; @@ -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 @@ -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 @@ -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 @@ -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); @@ -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); }); @@ -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);