| 1 | import { chromium } from "playwright"; import fs from "node:fs"; |
1 | import { chromium } from "playwright"; import fs from "node:fs"; |
| 2 | const BASE = process.env.BASE ?? "http://localhost:8500"; |
2 | const BASE = process.env.BASE ?? "http://localhost:8500"; |
| 3 | −const PW = fs.readFileSync(process.env.HOME + "/Desktop/Cluster/secrets/chat-spboucher-ai.devpassword", "utf8").trim(); |
3 | +const PW = fs.readFileSync(process.env.PWFILE ?? (process.env.HOME + "/Desktop/Cluster/secrets/chat-spboucher-ai.devpassword"), "utf8").trim(); |
| 4 | const browser = await chromium.launch(); const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } }); const page = await ctx.newPage(); |
4 | const browser = await chromium.launch(); const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } }); const page = await ctx.newPage(); |
| 5 | const errors = []; page.on("pageerror", e => errors.push(e.message)); page.on("console", m => { if (m.type() === "error") errors.push(m.text().slice(0, 200)); }); |
5 | const errors = []; page.on("pageerror", e => errors.push(e.message)); page.on("console", m => { if (m.type() === "error") errors.push(m.text().slice(0, 200)); }); |
| 6 | await 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 + "/"); |
6 | await 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 + "/"); |