aboutsummaryrefslogtreecommitdiffstats
path: root/test/e2e/helpers.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-03-05 15:05:37 -0800
committerAdam Soltys <[email protected]>2026-03-05 15:51:36 -0800
commit4c519faaf748cea25f9d0be87dd0f3e09d7bae4c (patch)
tree1fbda1930d8a8f8d6d03871274105dbfb7e1caa8 /test/e2e/helpers.ts
parent4a74d51e92365a731a2e5322783b88a39e14f046 (diff)
downloadcoinos-ui-4c519faaf748cea25f9d0be87dd0f3e09d7bae4c.tar.gz
coinos-ui-4c519faaf748cea25f9d0be87dd0f3e09d7bae4c.zip
android hce nfc
Diffstat (limited to 'test/e2e/helpers.ts')
-rw-r--r--test/e2e/helpers.ts18
1 files changed, 14 insertions, 4 deletions
diff --git a/test/e2e/helpers.ts b/test/e2e/helpers.ts
index 7a36d3f0..28b2d4c4 100644
--- a/test/e2e/helpers.ts
+++ b/test/e2e/helpers.ts
@@ -85,7 +85,7 @@ export async function apiGetInvoice(page: Page, invoiceId: string) {
// --- Invoice creation via UI ---
export async function createBitcoinInvoiceViaUI(page: Page, username: string) {
- await page.goto(`/invoice?address_type=bech32`);
+ await page.goto(`/invoice?type=bitcoin&address_type=bech32`);
await page.waitForURL(/\/invoice\/[^/?#]+/, { timeout: 15_000 });
const invoiceId = page.url().match(/\/invoice\/([^/?#]+)/)?.[1];
@@ -454,7 +454,7 @@ export async function setActiveAccount(page: Page, accountId: string) {
}, accountId);
}
-export async function ensureArkAccount(page: Page, _password: string) {
+export async function ensureArkAccount(page: Page, _password: string, token?: string) {
// Wait for autoUnlockArk() to derive the arkkey and write it to localStorage.
// This happens in onMount of the app layout after login() navigates to the dashboard.
// IMPORTANT: We must use THIS key (not re-derive) because Schnorr signing uses random
@@ -487,9 +487,16 @@ export async function ensureArkAccount(page: Page, _password: string) {
console.log(`[e2e] Client ark address: ...${clientAddress.slice(-30)}`);
+ // Get auth token from page cookies if not provided
+ if (!token) {
+ const cookies = await page.context().cookies();
+ token = cookies.find((c) => c.name === "token")?.value;
+ }
+ const authHeaders = token ? { authorization: `Bearer ${token}` } : {};
+
// Check/create ark account — retry to handle race conditions with parallel tests
for (let attempt = 0; attempt < 3; attempt++) {
- const accountsRes = await page.request.get(`${apiBaseUrl}/accounts`);
+ const accountsRes = await page.request.get(`${apiBaseUrl}/accounts`, { headers: authHeaders });
if (accountsRes.ok()) {
const accounts = await accountsRes.json();
const arkAccount = accounts.find((a: any) => a.type === "ark");
@@ -503,12 +510,14 @@ export async function ensureArkAccount(page: Page, _password: string) {
console.log(`[e2e] Ark address mismatch, deleting stale account`);
await page.request.post(`${apiBaseUrl}/account/delete`, {
data: { id: arkAccount.id },
+ headers: authHeaders,
});
}
}
const createRes = await page.request.post(`${apiBaseUrl}/accounts`, {
data: { name: "ark", type: "ark", arkAddress: clientAddress },
+ headers: authHeaders,
});
if (createRes.ok()) {
@@ -517,7 +526,8 @@ export async function ensureArkAccount(page: Page, _password: string) {
}
// "Already have an Ark vault" means another test created one — retry to check/update
- console.log(`[e2e] Account creation attempt ${attempt + 1} failed, retrying...`);
+ const errText = await createRes.text().catch(() => "");
+ console.log(`[e2e] Account creation attempt ${attempt + 1} failed (${createRes.status()}): ${errText}`);
await page.waitForTimeout(1_000);
}
}