-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpaykit.e2e.ts
More file actions
107 lines (94 loc) · 3.26 KB
/
Copy pathpaykit.e2e.ts
File metadata and controls
107 lines (94 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import {
completeOnboarding,
dragOnElement,
elementById,
enterAddress,
enterAddressViaScanPrompt,
enterAmount,
expectText,
receiveOnchainFunds,
sleep,
tap,
} from '../helpers/actions';
import { STAGING_PAYKIT_CONTACTS } from '../helpers/fixtures';
import { doNavigationClose, openContacts } from '../helpers/navigation';
import {
addContact,
cleanupProfile,
createProfile,
discardAddContactRoute,
verifyAddContactRoute,
verifyContactRowDisplayed,
} from '../helpers/profile';
import { reinstallApp } from '../helpers/setup';
import { ciIt } from '../helpers/suite';
async function switchToOnchainIfNeeded() {
await elementById('ContinueAmount').waitForDisplayed();
const switchButton = await elementById('AssetButton-switch');
if (await switchButton.isDisplayed().catch(() => false)) {
await tap('AssetButton-switch');
await sleep(500);
} else {
await elementById('AssetButton-savings').waitForDisplayed();
}
}
async function payCurrentContactOnchain(amountSats: number) {
await elementById('ContactPay').waitForDisplayed();
await tap('ContactPay');
await switchToOnchainIfNeeded();
await enterAmount(amountSats);
await tap('ContinueAmount');
await sleep(1000);
await dragOnElement('GRAB', 'right', 0.95);
await sleep(1000);
await elementById('SendSuccess').waitForDisplayed();
await tap('Close');
}
async function openContactActivity(publicKey: string) {
await openContacts();
await elementById(`Contact_${publicKey}`).waitForDisplayed();
await tap(`Contact_${publicKey}`);
await elementById('ContactActivity').waitForDisplayed();
await tap('ContactActivity');
}
describe.skip('@pubky @paykit - Public payments', () => {
beforeEach(async () => {
await reinstallApp();
await completeOnboarding();
});
ciIt('@paykit_1 - Can pay saved contact via public on-chain endpoint', async () => {
const [savedPaykitContact, unsavedPaykitContact] = STAGING_PAYKIT_CONTACTS;
let hasProfile = false;
try {
await receiveOnchainFunds({ sats: 50_000 });
await createProfile({ name: 'Paykit Sender' });
hasProfile = true;
await doNavigationClose();
// Unsaved public Paykit pubkys should route to the Add Contact payment surface.
await enterAddress(unsavedPaykitContact.pubky, { acceptCameraPermission: true });
await verifyAddContactRoute(unsavedPaykitContact.pubky, {
ableToPay: unsavedPaykitContact.ableToPay,
});
await discardAddContactRoute();
await enterAddressViaScanPrompt(unsavedPaykitContact.pubky, {
acceptCameraPermission: false,
});
await verifyAddContactRoute(unsavedPaykitContact.pubky, {
ableToPay: unsavedPaykitContact.ableToPay,
});
await discardAddContactRoute();
await addContact({ pubky: savedPaykitContact.pubky, firstContact: true });
await verifyContactRowDisplayed(savedPaykitContact.pubky);
await tap(`Contact_${savedPaykitContact.pubky}`);
await payCurrentContactOnchain(10_000);
await openContactActivity(savedPaykitContact.pubky);
await expectText('Sent to', { strategy: 'contains' });
await tap('ContactActivity-1');
await expectText('10 000');
} finally {
if (hasProfile) {
await cleanupProfile('@paykit_1');
}
}
});
});