aboutsummaryrefslogtreecommitdiffstats
path: root/test/e2e/vault-send-bitcoin.spec.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-15 16:58:17 -0800
committerAdam Soltys <[email protected]>2026-02-15 16:58:17 -0800
commitc7e8f628aa215caaa999f06d7fccb910fd5cc099 (patch)
tree86af97b298f4d4023b5b00a4c2498b218ecda628 /test/e2e/vault-send-bitcoin.spec.ts
parent5323057a68c1e2607128a3b216a767802725c52c (diff)
downloadcoinos-ui-c7e8f628aa215caaa999f06d7fccb910fd5cc099.tar.gz
coinos-ui-c7e8f628aa215caaa999f06d7fccb910fd5cc099.zip
fix custodial bitcoin sends
Diffstat (limited to 'test/e2e/vault-send-bitcoin.spec.ts')
-rw-r--r--test/e2e/vault-send-bitcoin.spec.ts98
1 files changed, 98 insertions, 0 deletions
diff --git a/test/e2e/vault-send-bitcoin.spec.ts b/test/e2e/vault-send-bitcoin.spec.ts
new file mode 100644
index 00000000..d08d5d5f
--- /dev/null
+++ b/test/e2e/vault-send-bitcoin.spec.ts
@@ -0,0 +1,98 @@
+import { expect, test } from "@playwright/test";
+
+const aliceUsername = process.env.E2E_ALICE_USERNAME || "alice";
+const alicePassword = process.env.E2E_ALICE_PASSWORD || "pw";
+const bobUsername = process.env.E2E_BOB_USERNAME || "bob";
+const bobPassword = process.env.E2E_BOB_PASSWORD || "pw";
+
+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 aliceContext = await browser.newContext();
+ const alicePage = await aliceContext.newPage();
+
+ await alicePage.goto("/login");
+ await alicePage.getByTestId("login-username").fill(aliceUsername);
+ await alicePage.locator('input[name="password"]').first().fill(alicePassword);
+ await alicePage.getByTestId("login-submit").click();
+ await expect(alicePage).toHaveURL(
+ new RegExp(`/${aliceUsername}(?:[/?#]|$)`),
+ );
+
+ // 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 bobContext = await browser.newContext();
+ const bobPage = await bobContext.newPage();
+
+ await bobPage.goto("/login");
+ await bobPage.waitForLoadState("networkidle");
+ await bobPage.getByTestId("login-username").fill(bobUsername);
+ await bobPage.locator('input[name="password"]').first().fill(bobPassword);
+ await bobPage.getByTestId("login-submit").click();
+ await expect(bobPage).toHaveURL(new RegExp(`/${bobUsername}(?:[/?#]|$)`), {
+ timeout: 15_000,
+ });
+
+ // Navigate to send page
+ await bobPage.goto("/send");
+ await bobPage.waitForURL(/\/send/);
+
+ // Fill the textarea with Alice's vault address and submit
+ const textarea = bobPage.locator('textarea[name="text"]');
+ await expect(textarea).toBeVisible({ timeout: 5_000 });
+ await textarea.fill(vaultAddress);
+
+ // Click the submit button and wait for navigation away from /send
+ await bobPage.locator('button[type="submit"]').first().click();
+
+ // Wait for navigation to leave /send (goes to /send/bitcoin, /pay, or /invoice)
+ await bobPage.waitForURL(
+ (url) => url.pathname !== "/send" && url.pathname !== "/send/",
+ { timeout: 15_000 },
+ );
+
+ 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();
+});