Skip to content

Commit d0f7eeb

Browse files
committed
expectNoTextWithin
1 parent 4f6fd9f commit d0f7eeb

File tree

2 files changed

+62
-20
lines changed

2 files changed

+62
-20
lines changed

test/helpers/actions.ts

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,34 @@ export async function expectText(
170170
export async function expectTextWithin(
171171
ancestorId: string,
172172
text: string,
173-
{ visible = true, timeout = 30_000 }: { visible?: boolean; timeout?: number } = {}
173+
{
174+
visible = true,
175+
timeout = 30_000,
176+
strategy = 'contains',
177+
}: {
178+
visible?: boolean;
179+
timeout?: number;
180+
strategy?: RetrieveStrategy;
181+
} = {}
174182
) {
175183
const parent = elementById(ancestorId);
176184
await parent.waitForDisplayed();
177185

178186
if (driver.isIOS) {
179187
const parentLabel = await parent.getAttribute('label');
180188
const parentValue = await parent.getAttribute('value');
181-
const matchesParent =
182-
(typeof parentLabel === 'string' && parentLabel.includes(text)) ||
183-
(typeof parentValue === 'string' && parentValue.includes(text));
189+
const matchesParent = (() => {
190+
if (strategy === 'exact') {
191+
return (
192+
(typeof parentLabel === 'string' && parentLabel === text) ||
193+
(typeof parentValue === 'string' && parentValue === text)
194+
);
195+
}
196+
return (
197+
(typeof parentLabel === 'string' && parentLabel.includes(text)) ||
198+
(typeof parentValue === 'string' && parentValue.includes(text))
199+
);
200+
})();
184201

185202
if (matchesParent) {
186203
if (!visible) {
@@ -190,9 +207,15 @@ export async function expectTextWithin(
190207
}
191208
}
192209

193-
const needle = driver.isAndroid
194-
? `.//*[contains(@text,'${text}')]`
195-
: `.//*[self::XCUIElementTypeStaticText or self::XCUIElementTypeTextView or self::XCUIElementTypeTextField][contains(@label,'${text}') or contains(@value,'${text}')]`;
210+
const needle = (() => {
211+
if (driver.isAndroid) {
212+
return strategy === 'exact' ? `.//*[@text='${text}']` : `.//*[contains(@text,'${text}')]`;
213+
}
214+
215+
return strategy === 'exact'
216+
? `.//*[self::XCUIElementTypeStaticText or self::XCUIElementTypeTextView or self::XCUIElementTypeTextField][@label='${text}' or @value='${text}']`
217+
: `.//*[self::XCUIElementTypeStaticText or self::XCUIElementTypeTextView or self::XCUIElementTypeTextField][contains(@label,'${text}') or contains(@value,'${text}')]`;
218+
})();
196219

197220
if (!visible) {
198221
await parent.$(needle).waitForDisplayed({ reverse: true, timeout });
@@ -201,6 +224,10 @@ export async function expectTextWithin(
201224
}
202225
}
203226

227+
export async function expectNoTextWithin(ancestorId: string, text: string) {
228+
await expectTextWithin(ancestorId, text, { visible: false, strategy: 'exact' });
229+
}
230+
204231
type Index = number | 'first' | 'last';
205232
/**
206233
* Get text from a descendant text element under a container.

test/specs/transfer.e2e.ts

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import {
2222
waitForToast,
2323
getTextUnder,
2424
acknowledgeExternalSuccess,
25+
dismissBackgroundPaymentsTimedSheet,
26+
expectNoTextWithin,
2527
} from '../helpers/actions';
2628
import {
2729
checkChannelStatus,
@@ -299,22 +301,28 @@ describe('@transfer - Transfer', () => {
299301
await sleep(500);
300302

301303
// change fee
302-
await tap('SetCustomFee');
303-
await sleep(500);
304-
await tap('NRemove');
305-
await sleep(1000); // wait for input to register
306-
await tap('FeeCustomContinue');
307-
await tap('N5');
308-
await sleep(1000); // wait for input to register
309-
await tap('FeeCustomContinue');
310-
311-
// Swipe to confirm (set x offset to avoid navigating back)
304+
// skiping for iOS as not implemented
305+
// skip: https://github.com/synonymdev/bitkit-ios/issues/285
306+
if (driver.isAndroid) {
307+
await tap('SetCustomFee');
308+
await sleep(500);
309+
await tap('NRemove');
310+
await sleep(1000); // wait for input to register
311+
await tap('FeeCustomContinue');
312+
await tap('N5');
313+
await sleep(1000); // wait for input to register
314+
await tap('FeeCustomContinue');
315+
}
316+
317+
// Swipe to confirm
312318
await dragOnElement('GRAB', 'right', 0.95);
313319
console.info('channel opening...');
314320
await sleep(1000);
315321
await acknowledgeExternalSuccess();
316-
await tap('NavigationBack');
317-
await doNavigationClose();
322+
if (driver.isAndroid) {
323+
await tap('NavigationBack');
324+
await doNavigationClose();
325+
}
318326

319327
// check transfer card
320328
// await elementById('Suggestion-lightning_setting_up').waitForDisplayed();
@@ -334,7 +342,14 @@ describe('@transfer - Transfer', () => {
334342
await mineBlocks(rpc, 6);
335343
await electrum?.waitForSync();
336344
await waitForToast('SpendingBalanceReadyToast');
337-
await dismissQuickPayIntro();
345+
await sleep(1000);
346+
if (driver.isIOS) {
347+
await dismissBackgroundPaymentsTimedSheet({ triggerTimedSheet: driver.isIOS });
348+
await dismissQuickPayIntro({ triggerTimedSheet: driver.isIOS });
349+
} else {
350+
await dismissQuickPayIntro();
351+
}
352+
await expectNoTextWithin('ActivitySpending', '0');
338353
await waitForActiveChannel(lnd, ldkNodeId);
339354

340355
// check transfer card

0 commit comments

Comments
 (0)