SPB Git
1.2 KB · 12 lines javascript
1import { chromium } from "playwright"; import fs from "node:fs";2const BASE = process.env.BASE ?? "http://localhost:8500";3const PW = fs.readFileSync(process.env.PWFILE ?? (process.env.HOME + "/Desktop/Cluster/secrets/chat-spboucher-ai.devpassword"), "utf8").trim();4const browser = await chromium.launch(); const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } }); const page = await ctx.newPage();5const errors = []; page.on("pageerror", e => errors.push(e.message)); page.on("console", m => { if (m.type() === "error") errors.push(m.text().slice(0, 200)); });6await page.goto(BASE + "/login"); await page.fill('input[autocomplete="username"]', "simon"); await page.fill('input[type="password"]', PW); await page.click('button[type="submit"]'); await page.waitForURL(BASE + "/");7for (const p of ["models", "compare", "research", "memory", "images", "usage", "settings", "projects/new"]) {8  await page.goto(`${BASE}/${p}`); await page.waitForLoadState("networkidle").catch(() => {}); await page.waitForTimeout(1200);9  await page.screenshot({ path: `e2e-shots/page-${p.replace("/", "-")}.png` }); console.log("shot", p);10}11console.log("errors:", JSON.stringify(errors.slice(0, 8), null, 1)); await browser.close();12
Files · e271e75196f58c092c7f0be7ddb52ff27d11b54f
Menu

Theme