aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-25 13:26:19 -0800
committerAdam Soltys <[email protected]>2026-02-25 13:26:19 -0800
commitb137cdfca84cf68a2b8a620ba1c55337e88a0050 (patch)
treec3f5482b08ce175fc4335d3f99838c06bb510877 /test
parent75bc8ecc68362616a233f0852361b2dc79bcdbba (diff)
downloadcoinos-ui-b137cdfca84cf68a2b8a620ba1c55337e88a0050.tar.gz
coinos-ui-b137cdfca84cf68a2b8a620ba1c55337e88a0050.zip
fix lightning receive redirect
Diffstat (limited to 'test')
-rw-r--r--test/e2e/receive-lightning-redirect.spec.ts53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/e2e/receive-lightning-redirect.spec.ts b/test/e2e/receive-lightning-redirect.spec.ts
new file mode 100644
index 00000000..d6670dca
--- /dev/null
+++ b/test/e2e/receive-lightning-redirect.spec.ts
@@ -0,0 +1,53 @@
+import { expect, test } from "@playwright/test";
+import { apiBaseUrl, bobUsername, bobPassword, login, lightningPay } from "./helpers";
+
+test("redirects from /receive to /paid when lightning address payment arrives", async ({
+ page,
+}) => {
+ test.setTimeout(90_000);
+
+ // --- Bob: log in and navigate to receive page ---
+ await login(page, bobUsername, bobPassword);
+ await page.goto(`/${bobUsername}/receive`);
+ await page.waitForLoadState("networkidle");
+ console.log(`[e2e] Bob on receive page: ${page.url()}`);
+
+ // Ensure we're on the receive page (not redirected to an invoice)
+ expect(page.url()).toContain(`/${bobUsername}/receive`);
+
+ // Small delay to ensure websocket is connected
+ await page.waitForTimeout(1000);
+
+ // --- External: create and pay LNURL invoice ---
+ // Step 1: Fetch LNURL pay request
+ const lnurlRes = await page.request.get(`${apiBaseUrl}/lnurlp/${bobUsername}`);
+ const lnurlData = await lnurlRes.json();
+ expect(lnurlData.callback).toBeTruthy();
+ console.log(`[e2e] LNURL callback: ${lnurlData.callback}`);
+
+ // Step 2: Call callback with 100 sat (100000 msat) to get bolt11
+ const callbackUrl = lnurlData.callback.replace("https://dev.coinos.io/api", apiBaseUrl);
+ const callbackRes = await page.request.get(`${callbackUrl}?amount=100000`);
+ const callbackData = await callbackRes.json();
+ const bolt11 = callbackData.pr;
+ expect(bolt11).toBeTruthy();
+ console.log(`[e2e] Got bolt11: ${bolt11.substring(0, 40)}...`);
+
+ // Step 3: Pay from external lightning node
+ console.log("[e2e] Paying from external lightning node (clb)...");
+ const payResult = lightningPay(bolt11);
+ console.log(`[e2e] Lightning pay result: ${payResult.substring(0, 100)}`);
+
+ // --- Bob: should be redirected to /paid ---
+ await page.waitForURL(/\/invoice\/[^/]+\/paid/, { timeout: 15_000 });
+ console.log(`[e2e] Bob redirected to: ${page.url()}`);
+
+ // Verify success UI is shown
+ const heading = await page.locator("h1").first().innerText({ timeout: 5_000 });
+ expect(
+ heading.toLowerCase().includes("payment") || heading.toLowerCase().includes("success"),
+ `Expected payment success/detected text, got: ${heading}`,
+ ).toBeTruthy();
+
+ if (process.env.E2E_PAUSE_AT_END === "true") await page.pause();
+});