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
|
import { expect, test } from "@playwright/test";
import {
aliceUsername,
alicePassword,
bobUsername,
bobPassword,
loginNewContext,
pasteAndSend,
} from "./helpers";
test("pasting vault bitcoin address redirects to /send/bitcoin, not /pay", async ({
browser,
}) => {
test.setTimeout(60_000);
// --- Alice: generate a vault invoice and grab the address ---
const { context: aliceContext, page: alicePage } = await loginNewContext(
browser,
aliceUsername,
alicePassword,
);
// Find the bitcoin vault account card and click Receive
const vaultCard = alicePage.locator(
'[data-testid="account-card"][data-account-type="bitcoin"]',
);
await expect(vaultCard.first()).toBeVisible({ timeout: 10_000 });
const receiveBtn = vaultCard
.first()
.getByTestId("account-receive");
await receiveBtn.click();
// Wait for the invoice page
await alicePage.waitForURL(/\/invoice\/[^/?#]+/, { timeout: 10_000 });
// Grab the bitcoin address from the invoice text
const invoiceText = await alicePage
.getByTestId("invoice-text")
.first()
.innerText();
const vaultAddress = invoiceText.trim().replace(/\s+/g, "");
expect(
vaultAddress.startsWith("bcrt1") || vaultAddress.startsWith("bc1"),
`Expected bitcoin address, got: ${vaultAddress}`,
).toBeTruthy();
console.log(`[e2e] Alice vault address: ${vaultAddress}`);
await aliceContext.close();
// --- Bob: paste the vault address and verify redirect ---
const { context: bobContext, page: bobPage } = await loginNewContext(
browser,
bobUsername,
bobPassword,
);
// Paste Alice's vault address
await pasteAndSend(bobPage, vaultAddress);
const finalUrl = bobPage.url();
console.log(`[e2e] After paste, Bob navigated to: ${finalUrl}`);
// Should go to /send/bitcoin, NOT /pay/alice
expect(
finalUrl,
`Expected /send/bitcoin/ URL but got: ${finalUrl}`,
).toContain("/send/bitcoin/");
expect(
finalUrl,
`Should NOT redirect to /pay/ but got: ${finalUrl}`,
).not.toContain("/pay/");
await bobContext.close();
});
|