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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
import { expect, test } from "@playwright/test";
import { ensureArkAccount } from "./helpers";
/**
* Registers a brand-new user via the two-step register flow,
* creates an Ark vault, then clicks Receive on the Ark card
* and verifies navigation to /invoice.
*/
test("register new user, create ark vault, click Receive", async ({ page }) => {
test.setTimeout(90_000);
page.on("console", (msg) => {
if (msg.type() === "error" || msg.text().includes("fail") || msg.text().includes("Fail"))
console.log(`[page] ${msg.text()}`);
});
page.on("pageerror", (err) => console.log(`[page-error] ${err.message}`));
const username = `test${Date.now()}`;
const password = "testpass123";
console.log(`[e2e] Registering user: ${username}`);
// ── Step 1: /register — pick username ──
await page.goto("/register");
await page.waitForLoadState("load");
const usernameInput = page.locator('input[name="username"]');
await expect(usernameInput).toBeVisible({ timeout: 5_000 });
await usernameInput.fill(username);
// Click Continue — retry once if hydration wasn't ready
const continueBtn = page.locator("button.btn-accent", { hasText: "Continue" });
await continueBtn.click();
const navigated = await page
.waitForURL(/\/register\/auth\?/, { timeout: 5_000 })
.then(() => true)
.catch(() => false);
if (!navigated) {
// Hydration may not have been ready — retry
await continueBtn.click();
await page.waitForURL(/\/register\/auth\?/, { timeout: 10_000 });
}
// ── Step 2: /register/auth — register with password ──
const passwordInput = page.locator('input[name="password"]');
await expect(passwordInput).toBeVisible({ timeout: 5_000 });
await passwordInput.fill(password);
const registerBtn = page.locator("button.btn-accent[type='submit']");
await registerBtn.click();
// Wait for redirect or detect registration error
const registered = await page
.waitForURL(new RegExp(`/${username}(?:[/?#]|$)`), { timeout: 30_000 })
.then(() => true)
.catch(() => false);
if (!registered) {
console.log(`[e2e] Registration didn't redirect, current URL: ${page.url()}`);
// Check if there's a form error message
const errorText = await page
.locator(".text-red-600")
.first()
.innerText({ timeout: 1000 })
.catch(() => "");
if (errorText) {
console.log(`[e2e] Registration error: ${errorText}`);
test.skip(true, `Registration failed: ${errorText}`);
return;
}
// If no error but still on register page, skip with info
test.skip(true, `Registration redirect timed out (still on ${page.url()})`);
return;
}
console.log(`[e2e] Registration successful, now on: ${page.url()}`);
// ── Step 3: Create Ark vault using the standard helper ──
await ensureArkAccount(page, password);
// ── Step 4: Click Receive on Ark card ──
await page.goto(`/${username}`);
await page.waitForLoadState("domcontentloaded");
const arkCard = page.locator('[data-testid="account-card"][data-account-type="ark"]');
await expect(arkCard.first()).toBeVisible({ timeout: 15_000 });
const receiveBtn = arkCard.first().getByTestId("account-receive");
await receiveBtn.click({ force: true });
// Handle wallet password dialog if it appears
const walletPassInput = page.getByTestId("walletpass-input");
if (await walletPassInput.isVisible({ timeout: 3_000 }).catch(() => false)) {
await walletPassInput.fill(password);
await page.getByTestId("walletpass-submit").click();
}
await page.waitForURL(/\/invoice\/[^/?#]+/, { timeout: 15_000 });
expect(page.url()).toContain("/invoice/");
});
|