-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathsendPayment.test.ts
More file actions
518 lines (449 loc) · 16.7 KB
/
Copy pathsendPayment.test.ts
File metadata and controls
518 lines (449 loc) · 16.7 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
import { test, expect } from "./test-fixtures";
import { login, loginAndFund, loginToTestAccount } from "./helpers/login";
import { TEST_M_ADDRESS, TEST_TOKEN_ADDRESS } from "./helpers/test-token";
import {
stubAccountBalances,
stubAccountBalancesE2e,
stubAccountHistory,
stubTokenDetails,
stubTokenPrices,
} from "./helpers/stubs";
test("Swap doesn't throw error when account is unfunded", async ({
page,
extensionId,
}) => {
test.slow();
await login({ page, extensionId });
await page.getByTestId("nav-link-swap").click();
await expect(page.getByTestId("AppHeaderPageTitle")).toContainText(
"Swap from",
);
});
test("Swap shows correct balances for assets", async ({
page,
extensionId,
}) => {
await stubAccountHistory(page);
await stubTokenDetails(page);
await page.route("*/**/account-balances/*", async (route) => {
const json = {
balances: {
"FOO:GDF32CQINROD3E2LMCGZUDVMWTXCJFR5SBYVRJ7WAAIAS3P7DCVWZEFY": {
token: {
type: "credit_alphanum12",
code: "FOO",
issuer: {
key: "GDF32CQINROD3E2LMCGZUDVMWTXCJFR5SBYVRJ7WAAIAS3P7DCVWZEFY",
},
},
sellingLiabilities: "0",
buyingLiabilities: "0",
total: "100",
limit: "922337203685.4775807",
available: "100",
blockaidData: {
result_type: "Benign",
malicious_score: "0.0",
attack_types: {},
chain: "stellar",
address:
"FOO-GDF32CQINROD3E2LMCGZUDVMWTXCJFR5SBYVRJ7WAAIAS3P7DCVWZEFY",
metadata: {
external_links: {},
},
fees: {},
features: [],
trading_limits: {},
financial_stats: {
top_holders: [],
},
},
},
"BAZ:GDF32CQINROD3E2LMCGZUDVMWTXCJFR5SBYVRJ7WAAIAS3P7DCVWZEFY": {
token: {
type: "credit_alphanum12",
code: "BAZ",
issuer: {
key: "GDF32CQINROD3E2LMCGZUDVMWTXCJFR5SBYVRJ7WAAIAS3P7DCVWZEFY",
},
},
sellingLiabilities: "0",
buyingLiabilities: "0",
total: "10",
limit: "922337203685.4775807",
available: "10",
blockaidData: {
result_type: "Benign",
malicious_score: "0.0",
attack_types: {},
chain: "stellar",
address:
"BAZ-GDF32CQINROD3E2LMCGZUDVMWTXCJFR5SBYVRJ7WAAIAS3P7DCVWZEFY",
metadata: {
external_links: {},
},
fees: {},
features: [
{
feature_id: "HIGH_REPUTATION_TOKEN",
type: "Benign",
description: "Token with verified high reputation",
},
],
trading_limits: {},
financial_stats: {
top_holders: [],
},
},
},
native: {
token: {
type: "native",
code: "XLM",
},
total: "999",
available: "999",
sellingLiabilities: "0",
buyingLiabilities: "0",
minimumBalance: "8",
blockaidData: {
result_type: "Benign",
malicious_score: "0.0",
attack_types: {},
chain: "stellar",
address: "",
metadata: {
type: "",
},
fees: {},
features: [],
trading_limits: {},
financial_stats: {},
},
},
"PBT:GDF32CQINROD3E2LMCGZUDVMWTXCJFR5SBYVRJ7WAAIAS3P7DCVWZEFY": {
token: {
code: "PBT",
issuer: {
key: "CAZXRTOKNUQ2JQQF3NCRU7GYMDJNZ2NMQN6IGN4FCT5DWPODMPVEXSND",
},
},
contractId:
"CAZXRTOKNUQ2JQQF3NCRU7GYMDJNZ2NMQN6IGN4FCT5DWPODMPVEXSND",
symbol: "PBT",
decimals: 5,
total: "9899700",
available: "9899700",
blockaidData: {
result_type: "Benign",
malicious_score: "0.0",
attack_types: {},
chain: "stellar",
address:
"PBT-CAZXRTOKNUQ2JQQF3NCRU7GYMDJNZ2NMQN6IGN4FCT5DWPODMPVEXSND",
metadata: {
external_links: {},
},
fees: {},
features: [],
trading_limits: {},
financial_stats: {
top_holders: [],
},
},
},
},
isFunded: true,
subentryCount: 0,
error: {
horizon: null,
soroban: null,
},
};
await route.fulfill({ json });
});
test.slow();
await login({ page, extensionId });
await page.getByTestId("nav-link-swap").click();
await expect(page.getByTestId("AppHeaderPageTitle")).toContainText(
"Swap from",
);
await expect(page.getByText(/FOO/)).toBeVisible();
await expect(page.getByTestId("FOO-balance")).toContainText("100");
await expect(page.getByTestId("BAZ-balance")).toContainText("10");
await expect(page.getByTestId("PBT-balance")).toContainText("98.997");
await expect(page.getByTestId("XLM-balance")).toContainText("998");
});
test("Send doesn't throw error when account is unfunded", async ({
page,
extensionId,
}) => {
test.slow();
await login({ page, extensionId });
await page.getByTestId("nav-link-send").click({ force: true });
await expect(page.getByText("Send")).toBeVisible();
await page
.getByTestId("send-to-input")
.fill("GBTYAFHGNZSTE4VBWZYAGB3SRGJEPTI5I4Y22KZ4JTVAN56LESB6JZOF");
await page.getByText("Continue").click({ force: true });
await expect(page.getByTestId("AppHeaderPageTitle")).toContainText("Send");
});
test("Send doesn't throw error when creating muxed account", async ({
page,
extensionId,
}) => {
test.slow();
await loginAndFund({ page, extensionId });
await page.getByTestId("nav-link-send").click({ force: true });
await expect(page.getByText("Send")).toBeVisible();
await page
.getByTestId("send-to-input")
.fill(
"MAUPPMNJUS76SG5NA6UXVCSO5HYVAJT422LBISV6LMCX37OIEPDJGAAAAAAAAAAAAF54C",
);
await expect(
page.getByText("The destination account doesn’t exist."),
).toBeVisible();
await page.getByText("Continue").click();
await expect(page.getByTestId("AppHeaderPageTitle")).toContainText("Send");
await page.getByTestId(`SendRow-native`).click({ force: true });
await page.getByTestId("send-amount-amount-input").fill("1");
await page.getByText("Review Send").click({ force: true });
await expect(page.getByText("You are sending")).toBeVisible({
timeout: 200000,
});
});
test("Send can review formatted inputs", async ({ page, extensionId }) => {
test.slow();
await loginAndFund({ page, extensionId });
await page.getByTestId("nav-link-send").click({ force: true });
await expect(page.getByText("Send")).toBeVisible();
await page
.getByTestId("send-to-input")
.fill(
"MAUPPMNJUS76SG5NA6UXVCSO5HYVAJT422LBISV6LMCX37OIEPDJGAAAAAAAAAAAAF54C",
);
await expect(
page.getByText("The destination account doesn’t exist."),
).toBeVisible();
await page.getByText("Continue").click();
await expect(page.getByTestId("AppHeaderPageTitle")).toContainText("Send");
await page.getByTestId(`SendRow-native`).click({ force: true });
await page.getByTestId("send-amount-amount-input").fill("1000");
await page.getByText("Review Send").click({ force: true });
await expect(page.getByText("You are sending")).toBeVisible({
timeout: 200000,
});
});
test("Send XLM payments to recent federated addresses", async ({
page,
extensionId,
}) => {
await stubTokenDetails(page);
await stubAccountBalances(page);
await stubAccountHistory(page);
await stubTokenPrices(page);
test.slow();
await loginToTestAccount({ page, extensionId });
await page.getByTestId("nav-link-send").click({ force: true });
await expect(page.getByText("Send")).toBeVisible();
await page.getByTestId("send-to-input").fill("freighter.pb*lobstr.co");
await expect(page.getByTestId("send-to-identicon")).toBeVisible();
await page.getByText("Continue").click({ force: true });
await expect(page.getByText("Send")).toBeVisible();
await page.getByTestId(`SendRow-native`).click({ force: true });
await page.getByTestId("send-amount-amount-input").fill("1");
await page.getByText("Review Send").click({ force: true });
await expect(page.getByText("You are sending")).toBeVisible();
const submitAction = page.getByTestId("SubmitAction");
await page.waitForTimeout(300);
await submitAction.waitFor({ state: "visible" });
await submitAction.click({ force: true });
await expect(page.getByText("Sent!")).toBeVisible({
timeout: 60000,
});
await page.getByText("Done").click();
await page.getByTestId("nav-link-send").click();
await expect(page.getByText("Send")).toBeVisible();
await expect(page.getByText("Recents")).toBeVisible();
await page.getByTestId("recent-address-button").click();
await page.getByTestId(`SendRow-native`).click({ force: true });
await page.getByTestId("send-amount-amount-input").fill("1");
await page.getByText("Review Send").click({ force: true });
await expect(page.getByText("You are sending")).toBeVisible();
await page.waitForTimeout(300);
await submitAction.waitFor({ state: "visible" });
await submitAction.click({ force: true });
await expect(page.getByText("Sent!")).toBeVisible({
timeout: 60000,
});
});
test("Send XLM payment to C address", async ({ page, extensionId }) => {
await stubTokenDetails(page);
await stubAccountBalances(page);
await stubAccountHistory(page);
await stubTokenPrices(page);
test.slow();
await loginToTestAccount({ page, extensionId });
// send XLM to C address
await page.getByTestId("nav-link-send").click({ force: true });
await expect(page.getByText("Send")).toBeVisible();
await page.getByTestId("send-to-input").fill(TEST_TOKEN_ADDRESS);
await page.getByText("Continue").click({ force: true });
await expect(page.getByText("Send")).toBeVisible();
await page.getByTestId(`SendRow-native`).click({ force: true });
await page.getByTestId("send-amount-amount-input").fill(".001");
await page.getByText("Review Send").click({ force: true });
await expect(page.getByText("You are sending")).toBeVisible({
timeout: 60000,
});
await page.getByTestId(`SubmitAction`).click({ force: true });
await expect(page.getByText("Sent!")).toBeVisible({
timeout: 60000,
});
});
test("Send XLM payment to M address", async ({ page, extensionId }) => {
await stubTokenDetails(page);
await stubAccountBalances(page);
await stubAccountHistory(page);
await stubTokenPrices(page);
test.slow();
await loginToTestAccount({ page, extensionId });
// send XLM to C address
await page.getByTestId("nav-link-send").click({ force: true });
await expect(page.getByText("Send")).toBeVisible();
await page.getByTestId("send-to-input").fill(TEST_M_ADDRESS);
await page.getByText("Continue").click({ force: true });
await expect(page.getByText("Send")).toBeVisible();
await page.getByTestId(`SendRow-native`).click({ force: true });
await page.getByTestId("send-amount-amount-input").fill(".001");
await page.getByText("Review Send").click();
await expect(page.getByText("You are sending")).toBeVisible({
timeout: 60000,
});
const submitButton = page.getByTestId("SubmitAction");
await submitButton.scrollIntoViewIfNeeded();
await submitButton.click();
await expect(page.getByText("Sent!")).toBeVisible({
timeout: 60000,
});
});
test.skip("Send SAC to C address", async ({ page, extensionId }) => {
test.slow();
await loginToTestAccount({ page, extensionId });
// add USDC asset
await page.getByTestId("account-options-dropdown").click();
await page.getByText("Manage assets").click({ force: true });
await page.getByText("Add an asset").click({ force: true });
await page
.getByTestId("search-asset-input")
.fill("GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5");
await expect(page.getByText("USDC")).toBeVisible();
await page.getByTestId("ManageAssetRowButton").click({ force: true });
await expect(page.getByTestId("NewAssetWarningAddButton")).toBeVisible({
timeout: 20000,
});
await page.getByText("Add asset").dispatchEvent("click");
await expect(page.getByTestId("account-view")).toBeVisible({
timeout: 300000,
});
// swap to get some USDC
await page.getByTestId("nav-link-swap").click({ force: true });
await expect(page.getByText("Swap XLM")).toBeVisible();
await expect(
page.getByTestId("AssetSelect").filter({ hasText: "USDC" }),
).toBeVisible({
timeout: 20000,
});
await page.getByTestId("send-amount-amount-input").fill(".001");
await expect(page.getByTestId("SendAmountRateAmount")).toBeVisible({
timeout: 20000,
});
await page.getByText("Continue").click({ force: true });
await expect(page.getByText("Swap Settings")).toBeVisible();
await expect(page.getByTestId("SendSettingsTransactionFee")).toHaveText(
/[0-9]/,
);
await page.getByText("Review Swap").click({ force: true });
await expect(page.getByText("Confirm Swap")).toBeVisible();
await page.getByTestId("transaction-details-btn-send").click({ force: true });
await expect(page.getByText("Successfully swapped")).toBeVisible({
timeout: 40000,
});
await page.getByText("Done").click({ force: true });
// send SAC to C address
await page.getByTestId("nav-link-send").click({ force: true });
await page.getByTestId("send-to-input").fill(TEST_TOKEN_ADDRESS);
await page.getByText("Continue").click({ force: true });
await page.getByTestId("send-amount-asset-select").click({ force: true });
await page.getByTestId("Select-assets-row-USDC").click({ force: true });
await expect(page.getByText("Send USDC")).toBeVisible();
await page.getByTestId("SendAmountSetMax").click({ force: true });
await page.getByText("Continue").click({ force: true });
await expect(page.getByText("Send Settings")).toBeVisible();
await expect(page.getByText("Review Send")).toBeEnabled();
await page.getByText("Review Send").click();
await expect(page.getByText("Confirm Send")).toBeVisible();
await page.getByTestId("transaction-details-btn-send").click({ force: true });
await expect(page.getByText("Successfully sent")).toBeVisible({
timeout: 40000,
});
await page.getByText("Details").click({ force: true });
await expect(page.getByText("Sent USDC")).toBeVisible();
await page.getByTestId("BackButton").click({ force: true });
await page.getByTestId("BackButton").click({ force: true });
await page.getByTestId("BackButton").click({ force: true });
await expect(page.getByTestId("account-view")).toBeVisible({
timeout: 30000,
});
// remove USDC
await page.getByTestId("account-options-dropdown").click();
await page.getByText("Manage assets").click({ force: true });
await page.getByTestId("ManageAssetRowButton__ellipsis-USDC").click();
await page.getByText("Remove asset").click({ force: true });
await expect(page.getByTestId("account-view")).toBeVisible({
timeout: 30000,
});
});
test("Send token payment to C address", async ({ page, extensionId }) => {
await stubTokenDetails(page);
await stubAccountBalancesE2e(page);
await stubAccountHistory(page);
await stubTokenPrices(page);
test.slow();
await loginToTestAccount({ page, extensionId });
// send E2E token to C address
await page.getByTestId("nav-link-send").click({ force: true });
await page.getByTestId("send-to-input").fill(TEST_TOKEN_ADDRESS);
await page.getByText("Continue").click({ force: true });
await expect(page.getByText("Send")).toBeVisible();
await page
.getByTestId(`SendRow-E2E:${TEST_TOKEN_ADDRESS}`)
.click({ force: true });
await page.getByTestId("send-amount-amount-input").fill(".001");
await page.getByText("Review Send").click({ force: true });
await expect(page.getByText("You are sending")).toBeVisible({
timeout: 60000,
});
await page.getByTestId(`SubmitAction`).click({ force: true });
await expect(page.getByText("Sent!")).toBeVisible({
timeout: 60000,
});
});
test.afterAll(async ({ page, extensionId }) => {
if (
test.info().status !== test.info().expectedStatus &&
test.info().title === "Send SAC to C address"
) {
// remove trustline in cleanup if Send SAC to C address test failed
test.slow();
await loginToTestAccount({ page, extensionId });
await page.getByTestId("account-options-dropdown").click();
await page.getByText("Manage assets").click({ force: true });
await page.getByTestId("ManageAssetRowButton__ellipsis-USDC").click();
await page.getByText("Remove asset").click();
await expect(page.getByTestId("account-view")).toBeVisible({
timeout: 30000,
});
}
});