aboutsummaryrefslogtreecommitdiffstats
path: root/test/e2e/custodial-send-external-ln.spec.ts
blob: baaa4c1bcbf4f6bb6fcc0bbe2b8c9fc77953a537 (plain) (blame)
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
import { expect, test } from "@playwright/test";
import {
  bobUsername,
  bobPassword,
  loginNewContext,
  lightningInvoice,
  pasteAndSend,
  waitForSentRedirect,
} from "./helpers";

test("custodial sends to external lightning node (clb) via bolt11", async ({ browser }) => {
  test.setTimeout(90_000);

  // --- Create bolt11 on external node (clb) ---
  const label = `e2e-ext-ln-${Date.now()}`;
  const bolt11 = lightningInvoice(1000_000, label); // 1000 sats in msats
  console.log(`[e2e] External bolt11: ${bolt11.substring(0, 40)}...`);

  // --- Bob: paste bolt11 and send ---
  const { context: bobContext, page: bobPage } = await loginNewContext(
    browser,
    bobUsername,
    bobPassword,
  );

  await pasteAndSend(bobPage, bolt11);

  const bobUrl = bobPage.url();
  console.log(`[e2e] Bob navigated to: ${bobUrl}`);

  // Should go to /send/lightning/{bolt11} for external lightning
  expect(bobUrl).toContain("/send/lightning/");

  // Lightning invoice has amount embedded — Send button should be visible
  // The page may show an error or advanced settings (maxfee)
  // Click Send (the main submit button)
  const sendButton = bobPage.locator('button[type="submit"]');
  await expect(sendButton).toBeVisible({ timeout: 5_000 });

  // Check for error message before clicking Send
  const errorText = await bobPage
    .locator(".text-red-600")
    .first()
    .innerText({ timeout: 1000 })
    .catch(() => "");
  if (errorText) {
    console.log(`[e2e] Page error before send: ${errorText}`);
  }

  await sendButton.click();

  await waitForSentRedirect(bobPage, 60_000);
  console.log(`[e2e] Bob external LN payment sent: ${bobPage.url()}`);

  await bobContext.close();
});