aboutsummaryrefslogtreecommitdiffstats
path: root/test/e2e/ark-send-custodial.spec.ts
blob: ab5d2141d476b9c76af29f47a08802eff9aac029 (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
57
58
59
60
61
62
63
64
65
66
67
import { expect, test } from "@playwright/test";
import {
  aliceUsername,
  alicePassword,
  bobUsername,
  bobPassword,
  testSecret,
  arkWalletPassword,
  loginNewContext,
  ensureArkAccount,
  createArkInvoiceViaUI,
  pasteAndSend,
  fillNumpadAmount,
  waitForSentRedirect,
} from "./helpers";

test("custodial sends to external ark address", async ({ browser }) => {
  test.setTimeout(120_000);
  test.skip(!testSecret, "E2E_TEST_SECRET is required for ark tests");

  // --- Alice: log in, ensure ark account, get her ark vault address ---
  const { context: aliceContext, page: alicePage } = await loginNewContext(
    browser,
    aliceUsername,
    alicePassword,
  );

  await ensureArkAccount(alicePage, arkWalletPassword);
  await alicePage.goto(`/${aliceUsername}`);
  await alicePage.waitForLoadState("networkidle");

  const { address: arkAddress } = await createArkInvoiceViaUI(alicePage, arkWalletPassword);
  console.log(`[e2e] Alice ark address: ${arkAddress}`);

  await aliceContext.close();

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

  await pasteAndSend(bobPage, arkAddress);

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

  // Should route to /send/ark/{address}
  expect(bobUrl).toContain("/send/ark/");

  // Enter amount on numpad
  await fillNumpadAmount(bobPage, 100);

  // Now on the confirmation page with Send button
  await bobPage.waitForURL(/\/send\/ark\/[^/]+\/\d+/, { timeout: 10_000 });
  console.log(`[e2e] Bob on ark send confirmation: ${bobPage.url()}`);

  const sendButton = bobPage.locator('button[type="submit"]');
  await expect(sendButton).toBeVisible({ timeout: 5_000 });
  await sendButton.click();

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

  await bobContext.close();
});