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
49 changes: 27 additions & 22 deletions test/helpers/outcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
elementByText,
getAccessibleText,
swipeFullScreen,
withMoveToSparkIntroRecovery,
} from './actions';

export type VisibleTarget = { id: string } | { text: string };
Expand Down Expand Up @@ -281,7 +282,9 @@ export async function tapAndExpect(target: VisibleTarget, outcome: Outcome) {
`tap ${label(target)}`,
async () => {
const current = element(target);
await current.waitForDisplayed({ timeout: outcome.timeout ?? 30_000 });
await withMoveToSparkIntroRecovery(() =>
current.waitForDisplayed({ timeout: outcome.timeout ?? 30_000 })
);
await current.click();
},
outcome
Expand All @@ -296,26 +299,28 @@ export async function tapStationaryAndExpect(target: VisibleTarget, outcome: Out
async () => {
let previous = '';
let ready: { click(): Promise<void> } | undefined;
await browser.waitUntil(
async () => {
const last = previous;
previous = '';
ready = undefined;
const current = await element(target);
if (!(await current.isDisplayed()) || !(await current.isEnabled())) return false;
const location = await current.getLocation();
const size = await current.getSize();
if (size.width <= 0 || size.height <= 0) return false;
previous = JSON.stringify({ id: current.elementId, location, size });
if (previous !== last) return false;
ready = current;
return true;
},
{
timeout: outcome.timeout ?? 30_000,
interval: 200,
timeoutMsg: `${label(target)} did not become enabled and stationary`,
}
await withMoveToSparkIntroRecovery(() =>
browser.waitUntil(
async () => {
const last = previous;
previous = '';
ready = undefined;
const current = await element(target);
if (!(await current.isDisplayed()) || !(await current.isEnabled())) return false;
const location = await current.getLocation();
const size = await current.getSize();
if (size.width <= 0 || size.height <= 0) return false;
previous = JSON.stringify({ id: current.elementId, location, size });
if (previous !== last) return false;
ready = current;
return true;
},
{
timeout: outcome.timeout ?? 30_000,
interval: 200,
timeoutMsg: `${label(target)} did not become enabled and stationary`,
}
)
);
if (!ready) throw new Error(`${label(target)} readiness was not established`);
await ready.click();
Expand Down Expand Up @@ -356,7 +361,7 @@ export async function typeAndExpect(
`type id:${id}`,
async () => {
const current = elementById(id);
await current.waitForDisplayed();
await withMoveToSparkIntroRecovery(() => current.waitForDisplayed());
await current.clearValue();
if (verifyClear) {
let emptySeen = false;
Expand Down
40 changes: 23 additions & 17 deletions test/specs/send.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
editRecipientAddress,
tap,
selectSendFundingSource,
withMoveToSparkIntroRecovery,
} from '../helpers/actions';
import { lndConfig } from '../helpers/constants';
import { reinstallApp } from '../helpers/setup';
Expand Down Expand Up @@ -163,8 +164,7 @@ describe('@send - Send', () => {
await confirmGateAction({ anyVisible: [{ id: 'SendSuccess' }] });
await elementById('SendSuccess').waitForDisplayed();
await tapAndExpect({ id: 'Close' }, { anyVisible: [{ id: 'TotalBalance-primary' }] });
await expect(totalBalance).not.toHaveText('110 000');
const amtAfterOnchain = await totalBalance.getText();
const amtAfterOnchain = await totalBalanceChangedFrom(totalBalance, '110 000');
console.info({ amtAfterOnchain });
await expectTextWithin('ActivitySpending', '10 000');

Expand All @@ -181,8 +181,7 @@ describe('@send - Send', () => {
await confirmGateAction({ anyVisible: [{ id: 'SendSuccess' }] });
await elementById('SendSuccess').waitForDisplayed();
await tapAndExpect({ id: 'Close' }, { anyVisible: [{ id: 'TotalBalance-primary' }] });
await expect(totalBalance).not.toHaveText(amtAfterOnchain);
const amtAfterLightning = await totalBalance.getText();
const amtAfterLightning = await totalBalanceChangedFrom(totalBalance, amtAfterOnchain);
console.info({ amtAfterLightning });
await expectTextWithin('ActivitySpending', '8 000');

Expand Down Expand Up @@ -218,8 +217,7 @@ describe('@send - Send', () => {
await confirmGateAction({ anyVisible: [{ id: 'SendSuccess' }] });
await elementById('SendSuccess').waitForDisplayed();
await tapAndExpect({ id: 'Close' }, { anyVisible: [{ id: 'TotalBalance-primary' }] });
await expect(totalBalance).not.toHaveText(amtAfterLightning);
const amtAfterUnified = await totalBalance.getText();
const amtAfterUnified = await totalBalanceChangedFrom(totalBalance, amtAfterLightning);
console.info({ amtAfterUnified });
await expectTextWithin('ActivitySpending', '7 000');

Expand All @@ -241,8 +239,7 @@ describe('@send - Send', () => {
await confirmGateAction({ anyVisible: [{ id: 'SendSuccess' }] });
await elementById('SendSuccess').waitForDisplayed();
await tapAndExpect({ id: 'Close' }, { anyVisible: [{ id: 'TotalBalance-primary' }] });
await expect(totalBalance).not.toHaveText(amtAfterUnified);
const amtAfterUnified2 = await totalBalance.getText();
const amtAfterUnified2 = await totalBalanceChangedFrom(totalBalance, amtAfterUnified);
console.info({ amtAfterUnified2 });
await expectTextWithin('ActivitySpending', '7 000');

Expand All @@ -267,8 +264,7 @@ describe('@send - Send', () => {
await confirmGateAction({ anyVisible: [{ id: 'SendSuccess' }] });
await elementById('SendSuccess').waitForDisplayed();
await tapAndExpect({ id: 'Close' }, { anyVisible: [{ id: 'TotalBalance-primary' }] });
await expect(totalBalance).not.toHaveText(amtAfterUnified2);
const amtAfterUnified3 = await totalBalance.getText();
const amtAfterUnified3 = await totalBalanceChangedFrom(totalBalance, amtAfterUnified2);
console.info({ amtAfterUnified3 });
await expectTextWithin('ActivitySpending', '7 000');

Expand All @@ -295,8 +291,7 @@ describe('@send - Send', () => {
await confirmGateAction({ anyVisible: [{ id: 'SendSuccess' }] });
await elementById('SendSuccess').waitForDisplayed();
await tapAndExpect({ id: 'Close' }, { anyVisible: [{ id: 'TotalBalance-primary' }] });
await expect(totalBalance).not.toHaveText(amtAfterUnified3);
const amtAfterUnified4 = await totalBalance.getText();
const amtAfterUnified4 = await totalBalanceChangedFrom(totalBalance, amtAfterUnified3);
console.info({ amtAfterUnified4 });
await expectTextWithin('ActivitySpending', '6 000');

Expand Down Expand Up @@ -333,8 +328,7 @@ describe('@send - Send', () => {
await confirmGateAction({ anyVisible: [{ id: 'SendSuccess' }] });
await elementById('SendSuccess').waitForDisplayed();
await tapAndExpect({ id: 'Close' }, { anyVisible: [{ id: 'TotalBalance-primary' }] });
await expect(totalBalance).not.toHaveText(amtAfterUnified4);
const amtAfterUnified5 = await totalBalance.getText();
const amtAfterUnified5 = await totalBalanceChangedFrom(totalBalance, amtAfterUnified4);
console.info({ amtAfterUnified5 });
await expectTextWithin('ActivitySpending', '6 000');

Expand All @@ -353,8 +347,7 @@ describe('@send - Send', () => {
await enterGateAddress(invoice7, { acceptCameraPermission: false });
await elementById('SendSuccess').waitForDisplayed();
await tapAndExpect({ id: 'Close' }, { anyVisible: [{ id: 'TotalBalance-primary' }] });
await expect(totalBalance).not.toHaveText(amtAfterUnified5);
const amtAfterLightning2 = await totalBalance.getText();
const amtAfterLightning2 = await totalBalanceChangedFrom(totalBalance, amtAfterUnified5);
console.info({ amtAfterLightning2 });
await expectTextWithin('ActivitySpending', '5 000');

Expand All @@ -369,7 +362,9 @@ describe('@send - Send', () => {
await enterGateAddress(unified7, { acceptCameraPermission: false });
await elementById('SendSuccess').waitForDisplayed();
await tapAndExpect({ id: 'Close' }, { anyVisible: [{ id: 'TotalBalance-primary' }] });
await expect(totalBalance).not.toHaveText(amtAfterLightning2);
await withMoveToSparkIntroRecovery(async () => {
await expect(totalBalance).not.toHaveText(amtAfterLightning2);
});
await expectTextWithin('ActivitySpending', '4 000');

// send to lightning invoice w/ amount (skip quickpay for large amounts)
Expand Down Expand Up @@ -491,3 +486,14 @@ describe('@send - Send', () => {
await payMsatInvoice('500500', '501', false);
});
});

/** Reads the total balance once it moved off `previous`; the Move to Spark intro can cover home right after Close. */
async function totalBalanceChangedFrom(
totalBalance: Awaited<ReturnType<typeof elementByIdWithin>>,
previous: string
): Promise<string> {
await withMoveToSparkIntroRecovery(async () => {
await expect(totalBalance).not.toHaveText(previous);
});
return withMoveToSparkIntroRecovery(() => totalBalance.getText());
}