Skip to content

Commit e3f4cdc

Browse files
authored
Merge pull request #45 from synonymdev/test/receive
Test/receive
2 parents b142e38 + 9ffcbad commit e3f4cdc

File tree

2 files changed

+54
-14
lines changed

2 files changed

+54
-14
lines changed

test/helpers/actions.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,24 @@ export async function expectTextWithin(
175175
const parent = elementById(ancestorId);
176176
await parent.waitForDisplayed();
177177

178+
if (driver.isIOS) {
179+
const parentLabel = await parent.getAttribute('label');
180+
const parentValue = await parent.getAttribute('value');
181+
const matchesParent =
182+
(typeof parentLabel === 'string' && parentLabel.includes(text)) ||
183+
(typeof parentValue === 'string' && parentValue.includes(text));
184+
185+
if (matchesParent) {
186+
if (!visible) {
187+
await parent.waitForDisplayed({ reverse: true, timeout });
188+
}
189+
return;
190+
}
191+
}
192+
178193
const needle = driver.isAndroid
179194
? `.//*[contains(@text,'${text}')]`
180-
: `.//XCUIElementTypeStaticText[contains(@label,'${text}') or contains(@value,'${text}')]`;
195+
: `.//*[self::XCUIElementTypeStaticText or self::XCUIElementTypeTextView or self::XCUIElementTypeTextField][contains(@label,'${text}') or contains(@value,'${text}')]`;
181196

182197
if (!visible) {
183198
await parent.$(needle).waitForDisplayed({ reverse: true, timeout });
@@ -390,10 +405,16 @@ export async function confirmInputOnKeyboard() {
390405
await driver.hideKeyboard();
391406
} catch {}
392407
} else {
408+
for (const el of ['return', 'done', 'go']) {
393409
try {
394-
await elementByText('return').click();
395-
} catch {
396-
// Swallow the error; keyboard might already be closed
410+
const elem = await elementByText(el);
411+
await elem.waitForDisplayed({ timeout: 2000 });
412+
await elem.click();
413+
return;
414+
} catch {
415+
// Swallow the error; keyboard might already be closed
416+
console.warn(`Not closing keyboard on element: ${el}`);
417+
}
397418
}
398419
}
399420
}

test/specs/receive.e2e.ts

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
expectTextWithin,
88
getReceiveAddress,
99
sleep,
10+
swipeFullScreen,
1011
tap,
1112
typeText,
1213
} from '../helpers/actions';
@@ -26,11 +27,19 @@ describe('@receive - Receive', () => {
2627
}
2728

2829
// Onchain/Lightning details
29-
await dragOnElement('ReceiveSlider', 'left', 0.7);
30+
if (driver.isIOS) {
31+
await tap('ShowDetails');
32+
} else {
33+
await dragOnElement('ReceiveSlider', 'left', 0.7);
34+
}
3035
await elementById('ReceiveScreen').waitForDisplayed();
3136

3237
// ReceiveDetail
33-
await dragOnElement('ReceiveScreen', 'right', 0.7);
38+
if (driver.isIOS) {
39+
await tap('QRCode');
40+
} else {
41+
await dragOnElement('ReceiveScreen', 'right', 0.7);
42+
}
3443
await sleep(1000);
3544
await tap('SpecifyInvoiceButton');
3645

@@ -59,31 +68,41 @@ describe('@receive - Receive', () => {
5968

6069
// Show QR
6170
await tap('ShowQrReceive');
71+
await sleep(500);
6272

6373
// Back to ReceiveDetail
6474
// data should still be there
6575
await tap('SpecifyInvoiceButton');
6676
await expectText('123');
6777
await expectTextWithin('ReceiveNote', note);
68-
await expectText(tag);
78+
// tags not shown on iOS
79+
// https://github.com/synonymdev/bitkit-ios/issues/197
80+
if (driver.isAndroid) {
81+
await expectText(tag);
82+
}
6983

7084
// Close & reopen
71-
await dragOnElement('ReceiveScreen', 'down', 0.7);
85+
await swipeFullScreen('down');
7286
await sleep(1000);
7387
await elementById('Receive').waitForDisplayed();
7488
await tap('Receive');
7589

7690
// data should be reset
91+
await sleep(500);
7792
await tap('SpecifyInvoiceButton');
7893
await expectText('123', { visible: false });
7994
await expectTextWithin('ReceiveNote', note, { visible: false });
8095
await expectText(tag, { visible: false });
8196

82-
// check previous tags & delete
83-
await tap('TagsAdd');
84-
await tap(`Tag-${tag}`);
85-
await expectText(tag);
86-
await tap(`Tag-${tag}-delete`);
87-
await expectText(tag, { visible: false });
97+
// tags not shown on iOS
98+
// https://github.com/synonymdev/bitkit-ios/issues/197
99+
if (driver.isAndroid) {
100+
// check previous tags & delete
101+
await tap('TagsAdd');
102+
await tap(`Tag-${tag}`);
103+
await expectText(tag);
104+
await tap(`Tag-${tag}-delete`);
105+
await expectText(tag, { visible: false });
106+
}
88107
});
89108
});

0 commit comments

Comments
 (0)