diff options
Diffstat (limited to 'test-ark-create.mjs')
| -rw-r--r-- | test-ark-create.mjs | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/test-ark-create.mjs b/test-ark-create.mjs index 7db6c79b..7fc9b24e 100644 --- a/test-ark-create.mjs +++ b/test-ark-create.mjs @@ -9,19 +9,28 @@ const API_KEY = "test-playwright-key"; const context = await browser.newContext({ ignoreHTTPSErrors: true }); const page = await context.newPage(); - page.on("console", (msg) => console.log(`[browser:${msg.type()}]`, msg.text())); + page.on("console", (msg) => + console.log(`[browser:${msg.type()}]`, msg.text()), + ); page.on("pageerror", (err) => console.log("[page error]", err.message)); page.on("request", (req) => { const u = req.url(); if (u.includes("account") || u.includes("arkade.computer")) { - console.log(`[req] ${req.method()} ${u} ${req.postData()?.substring(0, 500) || ""}`); + console.log( + `[req] ${req.method()} ${u} ${req.postData()?.substring(0, 500) || ""}`, + ); } }); page.on("response", (resp) => { const u = resp.url(); if (u.includes("account") && !u.includes("__data")) { - resp.text().then((t) => console.log(`[resp] ${resp.status()} ${u} -> ${t.substring(0, 500)}`)).catch(() => {}); + resp + .text() + .then((t) => + console.log(`[resp] ${resp.status()} ${u} -> ${t.substring(0, 500)}`), + ) + .catch(() => {}); } }); @@ -35,7 +44,10 @@ const API_KEY = "test-playwright-key"; for (const h of await loginResp.headersArray()) { if (h.name.toLowerCase() === "set-cookie") { const m = h.value.match(/token=([^;]+)/); - if (m) await context.addCookies([{ name: "token", value: m[1], domain: "172.18.0.9", path: "/" }]); + if (m) + await context.addCookies([ + { name: "token", value: m[1], domain: "172.18.0.9", path: "/" }, + ]); } } @@ -54,7 +66,10 @@ const API_KEY = "test-playwright-key"; if (await revealBtn.count()) { await revealBtn.click(); await page.waitForTimeout(1000); - const nsecText = await page.locator("button[aria-label='Copy backup key']").innerText().catch(() => "not found"); + const nsecText = await page + .locator("button[aria-label='Copy backup key']") + .innerText() + .catch(() => "not found"); console.log("Backup key:", nsecText.substring(0, 30), "..."); } @@ -91,7 +106,9 @@ const API_KEY = "test-playwright-key"; console.log("\n--- Checking accounts ---"); const acctResp = await page.request.get(`${API}/accounts`, { headers: { - cookie: (await context.cookies()).map((c) => `${c.name}=${c.value}`).join("; "), + cookie: (await context.cookies()) + .map((c) => `${c.name}=${c.value}`) + .join("; "), }, }); const accounts = await acctResp.json(); |
