diff options
| author | Adam Soltys <[email protected]> | 2026-02-24 13:01:02 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-24 13:01:02 -0800 |
| commit | db59579a2efa8416f78c855faa7d7e62048447e5 (patch) | |
| tree | 28444081de0120f21f7596198937bdd52fe43495 /test | |
| parent | 7eec7ac0b322b510b4e2cedef62422b6043d6405 (diff) | |
| download | coinos-ui-db59579a2efa8416f78c855faa7d7e62048447e5.tar.gz coinos-ui-db59579a2efa8416f78c855faa7d7e62048447e5.zip | |
lint
Diffstat (limited to 'test')
| -rw-r--r-- | test/e2e/ark-custodial-receive.spec.ts | 17 | ||||
| -rw-r--r-- | test/e2e/ark-send-custodial.spec.ts | 5 | ||||
| -rw-r--r-- | test/e2e/custodial-bitcoin-send.spec.ts | 20 | ||||
| -rw-r--r-- | test/e2e/custodial-receive-bitcoin.spec.ts | 18 | ||||
| -rw-r--r-- | test/e2e/custodial-receive-lightning.spec.ts | 26 | ||||
| -rw-r--r-- | test/e2e/custodial-send-external-btc.spec.ts | 4 | ||||
| -rw-r--r-- | test/e2e/custodial-send-external-ln.spec.ts | 4 | ||||
| -rw-r--r-- | test/e2e/custodial-send-lightning.spec.ts | 18 | ||||
| -rw-r--r-- | test/e2e/custodial-send-username.spec.ts | 10 | ||||
| -rw-r--r-- | test/e2e/helpers.ts | 92 | ||||
| -rw-r--r-- | test/e2e/vault-receive-bitcoin.spec.ts | 12 | ||||
| -rw-r--r-- | test/e2e/vault-send-bitcoin.spec.ts | 27 | ||||
| -rw-r--r-- | test/e2e/vault-send-external-btc.spec.ts | 24 | ||||
| -rw-r--r-- | test/e2e/vault-send-to-custodial-btc.spec.ts | 20 |
14 files changed, 74 insertions, 223 deletions
diff --git a/test/e2e/ark-custodial-receive.spec.ts b/test/e2e/ark-custodial-receive.spec.ts index d50cda55..41b63733 100644 --- a/test/e2e/ark-custodial-receive.spec.ts +++ b/test/e2e/ark-custodial-receive.spec.ts @@ -9,9 +9,7 @@ import { sendArkFromTestEndpoint, } from "./helpers"; -test("custodial account receives ark payment via vault forward", async ({ - page, -}) => { +test("custodial account receives ark payment via vault forward", async ({ page }) => { test.setTimeout(120_000); test.skip(!testSecret, "E2E_TEST_SECRET is required"); @@ -20,9 +18,7 @@ test("custodial account receives ark payment via vault forward", async ({ // 2. Create ark invoice via the vault account (needs wallet unlock) const { invoiceId, address } = await createArkInvoiceViaUI(page, bobPassword); - console.log( - `[e2e] Created ark invoice ${invoiceId} on vault account, address: ${address}`, - ); + console.log(`[e2e] Created ark invoice ${invoiceId} on vault account, address: ${address}`); // 3. Stay on invoice page (subscribe to websocket notifications) await page.goto(`/invoice/${invoiceId}`); @@ -39,9 +35,7 @@ test("custodial account receives ark payment via vault forward", async ({ let status: any; for (let i = 0; i < 60; i++) { - const statusResponse = await page.request.get( - `${apiBaseUrl}/invoice/${invoiceId}`, - ); + const statusResponse = await page.request.get(`${apiBaseUrl}/invoice/${invoiceId}`); if (statusResponse.ok()) { status = await statusResponse.json(); if ((status?.received || 0) >= 1000) { @@ -52,10 +46,7 @@ test("custodial account receives ark payment via vault forward", async ({ await page.waitForTimeout(2000); } - expect( - paid, - `Custodial ark forward did not complete: ${JSON.stringify(status)}`, - ).toBeTruthy(); + expect(paid, `Custodial ark forward did not complete: ${JSON.stringify(status)}`).toBeTruthy(); console.log( `[e2e] Custodial ark receive complete: invoice ${invoiceId} received=${status?.received}`, diff --git a/test/e2e/ark-send-custodial.spec.ts b/test/e2e/ark-send-custodial.spec.ts index 881a7f08..5806ca72 100644 --- a/test/e2e/ark-send-custodial.spec.ts +++ b/test/e2e/ark-send-custodial.spec.ts @@ -24,10 +24,7 @@ test("custodial sends to external ark address", async ({ browser }) => { alicePassword, ); - const { address: arkAddress } = await createArkInvoiceViaUI( - alicePage, - alicePassword, - ); + const { address: arkAddress } = await createArkInvoiceViaUI(alicePage, alicePassword); console.log(`[e2e] Alice ark address: ${arkAddress}`); await aliceContext.close(); diff --git a/test/e2e/custodial-bitcoin-send.spec.ts b/test/e2e/custodial-bitcoin-send.spec.ts index 8b4c8be9..c8543dac 100644 --- a/test/e2e/custodial-bitcoin-send.spec.ts +++ b/test/e2e/custodial-bitcoin-send.spec.ts @@ -21,8 +21,10 @@ test("custodial-to-custodial via bitcoin address sends internally and notifies r alicePassword, ); - const { invoiceId, address: bitcoinAddress } = - await createBitcoinInvoiceViaUI(alicePage, aliceUsername); + const { invoiceId, address: bitcoinAddress } = await createBitcoinInvoiceViaUI( + alicePage, + aliceUsername, + ); console.log(`[e2e] Alice custodial bitcoin address: ${bitcoinAddress}`); console.log(`[e2e] Alice invoice ID: ${invoiceId}`); @@ -43,14 +45,8 @@ test("custodial-to-custodial via bitcoin address sends internally and notifies r console.log(`[e2e] Bob navigated to: ${bobUrl}`); // Verify it went to /send/invoice/ (internal send via original invoice) - expect( - bobUrl, - `Expected /send/invoice/ URL but got: ${bobUrl}`, - ).toContain("/send/invoice/"); - expect( - bobUrl, - `Should NOT redirect to /pay/ but got: ${bobUrl}`, - ).not.toContain("/pay/"); + expect(bobUrl, `Expected /send/invoice/ URL but got: ${bobUrl}`).toContain("/send/invoice/"); + expect(bobUrl, `Should NOT redirect to /pay/ but got: ${bobUrl}`).not.toContain("/pay/"); // Bob should see the Numpad (no amount set on the invoice) const amountInput = bobPage.locator('[aria-label="Amount input"]'); @@ -89,7 +85,9 @@ test("custodial-to-custodial via bitcoin address sends internally and notifies r // Verify Alice sees the payment success page const successText = await alicePage.locator("h1").first().innerText({ timeout: 5_000 }); expect( - successText.toLowerCase().includes("payment") || successText.toLowerCase().includes("success") || successText.toLowerCase().includes("detected"), + successText.toLowerCase().includes("payment") || + successText.toLowerCase().includes("success") || + successText.toLowerCase().includes("detected"), `Expected payment success text, got: ${successText}`, ).toBeTruthy(); diff --git a/test/e2e/custodial-receive-bitcoin.spec.ts b/test/e2e/custodial-receive-bitcoin.spec.ts index 11ccd3be..934f76a7 100644 --- a/test/e2e/custodial-receive-bitcoin.spec.ts +++ b/test/e2e/custodial-receive-bitcoin.spec.ts @@ -10,18 +10,13 @@ import { waitForPaidRedirect, } from "./helpers"; -test("custodial receives external bitcoin payment from bitcoind", async ({ - page, -}) => { +test("custodial receives external bitcoin payment from bitcoind", async ({ page }) => { test.setTimeout(120_000); // --- Alice: log in and create bitcoin invoice --- await login(page, aliceUsername, alicePassword); - const { invoiceId, address } = await createBitcoinInvoiceViaUI( - page, - aliceUsername, - ); + const { invoiceId, address } = await createBitcoinInvoiceViaUI(page, aliceUsername); console.log(`[e2e] Alice bitcoin address: ${address}`); console.log(`[e2e] Alice invoice ID: ${invoiceId}`); @@ -40,18 +35,13 @@ test("custodial receives external bitcoin payment from bitcoind", async ({ interval: 2000, maxAttempts: 30, }); - console.log( - `[e2e] Invoice paid: received=${status?.received}, pending=${status?.pending}`, - ); + console.log(`[e2e] Invoice paid: received=${status?.received}, pending=${status?.pending}`); // --- Alice: should be redirected to /paid --- await waitForPaidRedirect(page, invoiceId, 30_000); console.log(`[e2e] Alice redirected to paid: ${page.url()}`); - const successText = await page - .locator("h1") - .first() - .innerText({ timeout: 5_000 }); + const successText = await page.locator("h1").first().innerText({ timeout: 5_000 }); expect( successText.toLowerCase().includes("payment") || successText.toLowerCase().includes("success") || diff --git a/test/e2e/custodial-receive-lightning.spec.ts b/test/e2e/custodial-receive-lightning.spec.ts index 545ea24e..5c35b557 100644 --- a/test/e2e/custodial-receive-lightning.spec.ts +++ b/test/e2e/custodial-receive-lightning.spec.ts @@ -9,9 +9,7 @@ import { waitForPaidRedirect, } from "./helpers"; -test("custodial receives external lightning payment from clb", async ({ - page, -}) => { +test("custodial receives external lightning payment from clb", async ({ page }) => { test.setTimeout(90_000); // --- Alice: log in and create a lightning invoice with amount via API --- @@ -35,15 +33,11 @@ test("custodial receives external lightning payment from clb", async ({ expect(invoiceId).toBeTruthy(); // Get the bolt11 payreq - const invDetailRes = await page.request.get( - `${apiBaseUrl}/invoice/${invoiceId}`, - ); + const invDetailRes = await page.request.get(`${apiBaseUrl}/invoice/${invoiceId}`); const invDetail = await invDetailRes.json(); const bolt11 = invDetail.text; expect(bolt11).toBeTruthy(); - console.log( - `[e2e] Alice lightning invoice: ${invoiceId}, bolt11: ${bolt11.substring(0, 40)}...`, - ); + console.log(`[e2e] Alice lightning invoice: ${invoiceId}, bolt11: ${bolt11.substring(0, 40)}...`); // Navigate to the invoice page (Alice subscribes to websocket notifications) await page.goto(`/invoice/${invoiceId}`); @@ -62,25 +56,17 @@ test("custodial receives external lightning payment from clb", async ({ interval: 1000, maxAttempts: 15, }); - console.log( - `[e2e] Invoice paid: received=${status?.received}, pending=${status?.pending}`, - ); + console.log(`[e2e] Invoice paid: received=${status?.received}, pending=${status?.pending}`); // --- Alice: wait for redirect to /paid (with fallback) --- const paidReached = await page - .waitForURL( - new RegExp(`/invoice/${invoiceId}/paid(?:[/?#]|$)`), - { timeout: 10_000 }, - ) + .waitForURL(new RegExp(`/invoice/${invoiceId}/paid(?:[/?#]|$)`), { timeout: 10_000 }) .then(() => true) .catch(() => false); if (paidReached) { console.log(`[e2e] Alice redirected to paid: ${page.url()}`); - const successText = await page - .locator("h1") - .first() - .innerText({ timeout: 5_000 }); + const successText = await page.locator("h1").first().innerText({ timeout: 5_000 }); expect( successText.toLowerCase().includes("payment") || successText.toLowerCase().includes("success") || diff --git a/test/e2e/custodial-send-external-btc.spec.ts b/test/e2e/custodial-send-external-btc.spec.ts index f03aa81e..a19e3dea 100644 --- a/test/e2e/custodial-send-external-btc.spec.ts +++ b/test/e2e/custodial-send-external-btc.spec.ts @@ -9,9 +9,7 @@ import { waitForSentRedirect, } from "./helpers"; -test("custodial sends to external bitcoin address (bitcoind)", async ({ - browser, -}) => { +test("custodial sends to external bitcoin address (bitcoind)", async ({ browser }) => { test.setTimeout(90_000); // --- Get external bitcoin address from 'external' wallet (NOT 'coinos' hot wallet) --- diff --git a/test/e2e/custodial-send-external-ln.spec.ts b/test/e2e/custodial-send-external-ln.spec.ts index 34e14c65..6142d9c8 100644 --- a/test/e2e/custodial-send-external-ln.spec.ts +++ b/test/e2e/custodial-send-external-ln.spec.ts @@ -9,9 +9,7 @@ import { waitForSentRedirect, } from "./helpers"; -test("custodial sends to external lightning node (clb) via bolt11", async ({ - browser, -}) => { +test("custodial sends to external lightning node (clb) via bolt11", async ({ browser }) => { test.setTimeout(90_000); // --- Create bolt11 on external node (clb) --- diff --git a/test/e2e/custodial-send-lightning.spec.ts b/test/e2e/custodial-send-lightning.spec.ts index bddff32a..885da1ae 100644 --- a/test/e2e/custodial-send-lightning.spec.ts +++ b/test/e2e/custodial-send-lightning.spec.ts @@ -42,15 +42,11 @@ test("custodial-to-custodial via lightning bolt11 sends internally and notifies expect(invoiceId).toBeTruthy(); // Get the bolt11 payreq - const invDetailRes = await alicePage.request.get( - `${apiBaseUrl}/invoice/${invoiceId}`, - ); + const invDetailRes = await alicePage.request.get(`${apiBaseUrl}/invoice/${invoiceId}`); const invDetail = await invDetailRes.json(); const bolt11 = invDetail.text; expect(bolt11).toBeTruthy(); - console.log( - `[e2e] Alice bolt11 invoice: ${invoiceId}, bolt11: ${bolt11.substring(0, 40)}...`, - ); + console.log(`[e2e] Alice bolt11 invoice: ${invoiceId}, bolt11: ${bolt11.substring(0, 40)}...`); // Alice navigates to invoice page (subscribes to websocket notifications) await alicePage.goto(`/invoice/${invoiceId}`); @@ -76,10 +72,7 @@ test("custodial-to-custodial via lightning bolt11 sends internally and notifies await noTipButton.click(); // After skipping tip, redirects to /invoice/{id} → then to /send/invoice/{id} - await bobPage.waitForURL( - (url) => !url.pathname.includes("/tip"), - { timeout: 15_000 }, - ); + await bobPage.waitForURL((url) => !url.pathname.includes("/tip"), { timeout: 15_000 }); bobUrl = bobPage.url(); console.log(`[e2e] After tip skip: ${bobUrl}`); } @@ -114,10 +107,7 @@ test("custodial-to-custodial via lightning bolt11 sends internally and notifies await waitForPaidRedirect(alicePage, invoiceId, 30_000); console.log(`[e2e] Alice redirected to: ${alicePage.url()}`); - const successText = await alicePage - .locator("h1") - .first() - .innerText({ timeout: 5_000 }); + const successText = await alicePage.locator("h1").first().innerText({ timeout: 5_000 }); expect( successText.toLowerCase().includes("payment") || successText.toLowerCase().includes("success") || diff --git a/test/e2e/custodial-send-username.spec.ts b/test/e2e/custodial-send-username.spec.ts index 8dff65ab..f8b4a002 100644 --- a/test/e2e/custodial-send-username.spec.ts +++ b/test/e2e/custodial-send-username.spec.ts @@ -54,10 +54,7 @@ test("custodial-to-custodial via username (/pay/) sends and notifies recipient", // The form creates an invoice. If Alice has tip prompt, we go to /invoice/{id}/tip // Otherwise we go to /invoice/{id} which loads the send page - await bobPage.waitForURL( - (url) => !url.pathname.startsWith("/pay/"), - { timeout: 15_000 }, - ); + await bobPage.waitForURL((url) => !url.pathname.startsWith("/pay/"), { timeout: 15_000 }); const afterPayUrl = bobPage.url(); console.log(`[e2e] After /pay/ submit: ${afterPayUrl}`); @@ -71,10 +68,7 @@ test("custodial-to-custodial via username (/pay/) sends and notifies recipient", // After skipping tip, we get redirected to /invoice/{id} // which should then load as /send/invoice/{id} for the payer - await bobPage.waitForURL( - (url) => !url.pathname.includes("/tip"), - { timeout: 15_000 }, - ); + await bobPage.waitForURL((url) => !url.pathname.includes("/tip"), { timeout: 15_000 }); console.log(`[e2e] After tip skip: ${bobPage.url()}`); } diff --git a/test/e2e/helpers.ts b/test/e2e/helpers.ts index 1d85825a..08d19810 100644 --- a/test/e2e/helpers.ts +++ b/test/e2e/helpers.ts @@ -8,8 +8,7 @@ export const alicePassword = process.env.E2E_ALICE_PASSWORD || "pw"; export const bobUsername = process.env.E2E_BOB_USERNAME || "bob"; export const bobPassword = process.env.E2E_BOB_PASSWORD || "pw"; export const testSecret = process.env.E2E_TEST_SECRET; -export const apiBaseUrl = - process.env.E2E_API_BASE_URL || "http://localhost:3119"; +export const apiBaseUrl = process.env.E2E_API_BASE_URL || "http://localhost:3119"; export const pauseAtEnd = process.env.E2E_PAUSE_AT_END === "true"; // --- Login helpers --- @@ -32,11 +31,7 @@ export async function login(page: Page, username: string, password: string) { throw new Error(`Login failed for ${username} after 5 attempts`); } -export async function loginNewContext( - browser: Browser, - username: string, - password: string, -) { +export async function loginNewContext(browser: Browser, username: string, password: string) { const context = await browser.newContext(); const page = await context.newPage(); await login(page, username, password); @@ -66,20 +61,14 @@ export async function apiGetInvoice(page: Page, invoiceId: string) { // --- Invoice creation via UI --- -export async function createBitcoinInvoiceViaUI( - page: Page, - username: string, -) { +export async function createBitcoinInvoiceViaUI(page: Page, username: string) { await page.goto(`/${username}/receive?address_type=bech32`); await page.waitForURL(/\/invoice\/[^/?#]+/, { timeout: 15_000 }); const invoiceId = page.url().match(/\/invoice\/([^/?#]+)/)?.[1]; expect(invoiceId, "Should have invoice ID in URL").toBeTruthy(); - const invoiceText = await page - .getByTestId("invoice-text") - .first() - .innerText({ timeout: 10_000 }); + const invoiceText = await page.getByTestId("invoice-text").first().innerText({ timeout: 10_000 }); const address = invoiceText.trim().replace(/\s+/g, ""); expect( address.startsWith("bcrt1") || address.startsWith("bc1"), @@ -89,10 +78,7 @@ export async function createBitcoinInvoiceViaUI( return { invoiceId: invoiceId!, address }; } -export async function createLightningInvoiceViaUI( - page: Page, - username: string, -) { +export async function createLightningInvoiceViaUI(page: Page, username: string) { await page.goto(`/${username}/receive`); await page.waitForURL(/\/invoice\/[^/?#]+/, { timeout: 15_000 }); @@ -118,8 +104,7 @@ export async function createLightningInvoiceViaUI( const bolt11 = invoiceText.replace(/\s+/g, ""); expect( - bolt11.toLowerCase().startsWith("lnbcrt") || - bolt11.toLowerCase().startsWith("lnbc"), + bolt11.toLowerCase().startsWith("lnbcrt") || bolt11.toLowerCase().startsWith("lnbc"), `Expected bolt11, got: ${bolt11.substring(0, 30)}`, ).toBeTruthy(); @@ -127,9 +112,7 @@ export async function createLightningInvoiceViaUI( } export async function createArkInvoiceViaUI(page: Page, password: string) { - const arkCard = page.locator( - '[data-testid="account-card"][data-account-type="ark"]', - ); + const arkCard = page.locator('[data-testid="account-card"][data-account-type="ark"]'); await expect(arkCard.first()).toBeVisible({ timeout: 10_000 }); const walletPassInput = page.getByTestId("walletpass-input"); @@ -140,10 +123,7 @@ export async function createArkInvoiceViaUI(page: Page, password: string) { const card = arkCard.nth(i); await card.scrollIntoViewIfNeeded(); - const accountHref = await card - .locator('a[href^="/account/"]') - .first() - .getAttribute("href"); + const accountHref = await card.locator('a[href^="/account/"]').first().getAttribute("href"); const accountId = accountHref?.split("/account/")[1]; await card.locator('a[href="/invoice"]').first().click(); @@ -188,9 +168,7 @@ export async function createArkInvoiceViaUI(page: Page, password: string) { expect(invoiceOpened).toBeTruthy(); - const invoiceText = ( - await page.getByTestId("invoice-text").first().innerText() - ).trim(); + const invoiceText = (await page.getByTestId("invoice-text").first().innerText()).trim(); const addressMatch = invoiceText.match(/t?ark1[a-z0-9]+/i); expect(addressMatch).toBeTruthy(); @@ -201,18 +179,13 @@ export async function createArkInvoiceViaUI(page: Page, password: string) { } export async function createVaultBitcoinInvoiceViaUI(page: Page) { - const vaultCard = page.locator( - '[data-testid="account-card"][data-account-type="bitcoin"]', - ); + const vaultCard = page.locator('[data-testid="account-card"][data-account-type="bitcoin"]'); await expect(vaultCard.first()).toBeVisible({ timeout: 10_000 }); await vaultCard.first().getByTestId("account-receive").click(); await page.waitForURL(/\/invoice\/[^/?#]+/, { timeout: 10_000 }); - const invoiceText = await page - .getByTestId("invoice-text") - .first() - .innerText({ timeout: 10_000 }); + const invoiceText = await page.getByTestId("invoice-text").first().innerText({ timeout: 10_000 }); const address = invoiceText.trim().replace(/\s+/g, ""); expect( address.startsWith("bcrt1") || address.startsWith("bc1"), @@ -237,10 +210,9 @@ export async function pasteAndSend(page: Page, text: string) { await page.locator('button[type="submit"]').first().click(); // Wait for navigation away from /send - await page.waitForURL( - (url) => url.pathname !== "/send" && url.pathname !== "/send/", - { timeout: 15_000 }, - ); + await page.waitForURL((url) => url.pathname !== "/send" && url.pathname !== "/send/", { + timeout: 15_000, + }); } export async function fillNumpadAmount(page: Page, amount: number) { @@ -265,15 +237,8 @@ export async function waitForSentRedirect(page: Page, timeout = 15_000) { await page.waitForURL(/\/sent\//, { timeout }); } -export async function waitForPaidRedirect( - page: Page, - invoiceId: string, - timeout = 30_000, -) { - await page.waitForURL( - new RegExp(`/invoice/${invoiceId}/paid(?:[/?#]|$)`), - { timeout }, - ); +export async function waitForPaidRedirect(page: Page, invoiceId: string, timeout = 30_000) { + await page.waitForURL(new RegExp(`/invoice/${invoiceId}/paid(?:[/?#]|$)`), { timeout }); } // --- Docker helpers --- @@ -290,18 +255,12 @@ export function lightningPay(bolt11: string): string { } export function lightningInvoice(amountMsat: number, label: string): string { - const result = dockerExec( - "clb", - `lightning-cli invoice ${amountMsat} "${label}" "${label}"`, - ); + const result = dockerExec("clb", `lightning-cli invoice ${amountMsat} "${label}" "${label}"`); return JSON.parse(result).bolt11 as string; } export function getBitcoinAddress(): string { - return dockerExec( - "bc", - "bitcoin-cli -regtest -rpcwallet=external getnewaddress", - ); + return dockerExec("bc", "bitcoin-cli -regtest -rpcwallet=external getnewaddress"); } export function bitcoinSend(address: string, amountBtc: string): string { @@ -312,14 +271,8 @@ export function bitcoinSend(address: string, amountBtc: string): string { } export function mineBlocks(n: number): void { - const minerAddr = dockerExec( - "bc", - "bitcoin-cli -regtest -rpcwallet=coinos getnewaddress", - ); - dockerExec( - "bc", - `bitcoin-cli -regtest -rpcwallet=coinos generatetoaddress ${n} "${minerAddr}"`, - ); + const minerAddr = dockerExec("bc", "bitcoin-cli -regtest -rpcwallet=coinos getnewaddress"); + dockerExec("bc", `bitcoin-cli -regtest -rpcwallet=coinos generatetoaddress ${n} "${minerAddr}"`); } // --- Polling helpers --- @@ -335,10 +288,7 @@ export async function waitForInvoicePaid( const res = await page.request.get(`${apiBaseUrl}/invoice/${invoiceId}`); if (res.ok()) { status = await res.json(); - if ( - (status?.received || 0) >= amount || - (status?.pending || 0) >= amount - ) { + if ((status?.received || 0) >= amount || (status?.pending || 0) >= amount) { return status; } } diff --git a/test/e2e/vault-receive-bitcoin.spec.ts b/test/e2e/vault-receive-bitcoin.spec.ts index e1be643a..013bb562 100644 --- a/test/e2e/vault-receive-bitcoin.spec.ts +++ b/test/e2e/vault-receive-bitcoin.spec.ts @@ -10,9 +10,7 @@ import { waitForPaidRedirect, } from "./helpers"; -test("bitcoin vault receives external bitcoin payment from bitcoind", async ({ - page, -}) => { +test("bitcoin vault receives external bitcoin payment from bitcoind", async ({ page }) => { test.setTimeout(120_000); // --- Alice: log in and create vault bitcoin invoice --- @@ -37,9 +35,7 @@ test("bitcoin vault receives external bitcoin payment from bitcoind", async ({ interval: 2000, maxAttempts: 30, }); - console.log( - `[e2e] Vault invoice paid: received=${status?.received}, pending=${status?.pending}`, - ); + console.log(`[e2e] Vault invoice paid: received=${status?.received}, pending=${status?.pending}`); // --- Alice: should be redirected to /paid --- const paidReached = await page @@ -52,9 +48,7 @@ test("bitcoin vault receives external bitcoin payment from bitcoind", async ({ if (paidReached) { console.log(`[e2e] Alice redirected to paid: ${page.url()}`); } else { - console.log( - `[e2e] No /paid redirect (vault may not auto-redirect), current: ${page.url()}`, - ); + console.log(`[e2e] No /paid redirect (vault may not auto-redirect), current: ${page.url()}`); } // Vault payments may show as pending — verify the invoice API shows received/pending diff --git a/test/e2e/vault-send-bitcoin.spec.ts b/test/e2e/vault-send-bitcoin.spec.ts index bd3d7172..bfb69f3b 100644 --- a/test/e2e/vault-send-bitcoin.spec.ts +++ b/test/e2e/vault-send-bitcoin.spec.ts @@ -8,9 +8,7 @@ import { pasteAndSend, } from "./helpers"; -test("pasting vault bitcoin address redirects to /send/bitcoin, not /pay", async ({ - browser, -}) => { +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 --- @@ -21,24 +19,17 @@ test("pasting vault bitcoin address redirects to /send/bitcoin, not /pay", async ); // Find the bitcoin vault account card and click Receive - const vaultCard = alicePage.locator( - '[data-testid="account-card"][data-account-type="bitcoin"]', - ); + 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"); + 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 invoiceText = await alicePage.getByTestId("invoice-text").first().innerText(); const vaultAddress = invoiceText.trim().replace(/\s+/g, ""); expect( vaultAddress.startsWith("bcrt1") || vaultAddress.startsWith("bc1"), @@ -62,14 +53,8 @@ test("pasting vault bitcoin address redirects to /send/bitcoin, not /pay", async 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/"); + 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(); }); diff --git a/test/e2e/vault-send-external-btc.spec.ts b/test/e2e/vault-send-external-btc.spec.ts index 01a64716..c8431b59 100644 --- a/test/e2e/vault-send-external-btc.spec.ts +++ b/test/e2e/vault-send-external-btc.spec.ts @@ -10,9 +10,7 @@ import { setActiveAccount, } from "./helpers"; -test("bitcoin vault sends to external bitcoin address with PSBT signing", async ({ - page, -}) => { +test("bitcoin vault sends to external bitcoin address with PSBT signing", async ({ page }) => { test.setTimeout(120_000); // Capture console errors for debugging @@ -30,9 +28,7 @@ test("bitcoin vault sends to external bitcoin address with PSBT signing", async await login(page, aliceUsername, alicePassword); // --- Find the bitcoin vault account and switch to it --- - const vaultCard = page.locator( - '[data-testid="account-card"][data-account-type="bitcoin"]', - ); + const vaultCard = page.locator('[data-testid="account-card"][data-account-type="bitcoin"]'); const vaultCount = await vaultCard.count(); if (vaultCount === 0) { test.skip(true, "No bitcoin vault account found"); @@ -81,9 +77,7 @@ test("bitcoin vault sends to external bitcoin address with PSBT signing", async } // Click Send — this triggers the WalletPass dialog for vault accounts - const sendButton = page.locator( - 'button[type="submit"]:not([data-testid="walletpass-submit"])', - ); + const sendButton = page.locator('button[type="submit"]:not([data-testid="walletpass-submit"])'); await expect(sendButton).toBeVisible({ timeout: 5_000 }); await sendButton.click(); @@ -130,16 +124,12 @@ test("bitcoin vault sends to external bitcoin address with PSBT signing", async // Client-side PSBT signing may fail if esplora/PSBT format is not // properly configured in the test environment const signingError = consoleErrors.some( - (e) => - e.includes("invalid tag") || - e.includes("decrypt") || - e.includes("PSBT"), + (e) => e.includes("invalid tag") || e.includes("decrypt") || e.includes("PSBT"), ); if (signingError) { test.skip( true, - "PSBT signing failed (likely test env issue): " + - consoleErrors.join("; "), + "PSBT signing failed (likely test env issue): " + consoleErrors.join("; "), ); return; } @@ -148,9 +138,7 @@ test("bitcoin vault sends to external bitcoin address with PSBT signing", async } } } else { - console.log( - "[e2e] No WalletPass (cached password), waiting for redirect...", - ); + console.log("[e2e] No WalletPass (cached password), waiting for redirect..."); await waitForSentRedirect(page, 30_000); } diff --git a/test/e2e/vault-send-to-custodial-btc.spec.ts b/test/e2e/vault-send-to-custodial-btc.spec.ts index 7ee522d2..aa52213c 100644 --- a/test/e2e/vault-send-to-custodial-btc.spec.ts +++ b/test/e2e/vault-send-to-custodial-btc.spec.ts @@ -39,9 +39,7 @@ test("vault sending to custodial bitcoin address stays on /send/bitcoin, not /se const { id: invoiceId } = await invoiceRes.json(); expect(invoiceId).toBeTruthy(); - const invDetail = await ( - await bobPage.request.get(`${apiBaseUrl}/invoice/${invoiceId}`) - ).json(); + const invDetail = await (await bobPage.request.get(`${apiBaseUrl}/invoice/${invoiceId}`)).json(); const custodialAddress = invDetail.text; expect(custodialAddress).toBeTruthy(); console.log(`[e2e] Bob custodial bitcoin address: ${custodialAddress}`); @@ -55,9 +53,7 @@ test("vault sending to custodial bitcoin address stays on /send/bitcoin, not /se ); // Find the bitcoin vault account and switch to it - const vaultCard = alicePage.locator( - '[data-testid="account-card"][data-account-type="bitcoin"]', - ); + const vaultCard = alicePage.locator('[data-testid="account-card"][data-account-type="bitcoin"]'); const vaultCount = await vaultCard.count(); if (vaultCount === 0) { test.skip(true, "No bitcoin vault account found"); @@ -83,14 +79,10 @@ test("vault sending to custodial bitcoin address stays on /send/bitcoin, not /se console.log(`[e2e] After paste, Alice navigated to: ${finalUrl}`); // Should stay on /send/bitcoin (on-chain), NOT redirect to /send/invoice (internal) - expect( - finalUrl, - `Expected /send/bitcoin/ URL but got: ${finalUrl}`, - ).toContain("/send/bitcoin/"); - expect( - finalUrl, - `Should NOT redirect to /send/invoice/ but got: ${finalUrl}`, - ).not.toContain("/send/invoice/"); + expect(finalUrl, `Expected /send/bitcoin/ URL but got: ${finalUrl}`).toContain("/send/bitcoin/"); + expect(finalUrl, `Should NOT redirect to /send/invoice/ but got: ${finalUrl}`).not.toContain( + "/send/invoice/", + ); await aliceContext.close(); }); |
