// Captures d'écran QA : node scripts/screenshots.mjs import { chromium, devices } from "playwright"; const [base = "https://www.toveli.ca", out = "/tmp/toveli-shots"] = process.argv.slice(2); import { mkdirSync } from "node:fs"; mkdirSync(out, { recursive: true }); const pages = ["/", "/recherche?marche=achat&ville=Qu%C3%A9bec", "/carte", "/estimer?q=1234+erables", "/marche", "/financement", "/assistant", "/favoris", "/connexion"]; const browser = await chromium.launch(); for (const [name, ctxOpts] of [["mobile", { ...devices["iPhone 14"] }], ["android", { ...devices["Pixel 7"] }], ["desktop", { viewport: { width: 1440, height: 900 } }]]) { const ctx = await browser.newContext(ctxOpts); const page = await ctx.newPage(); const errors = []; page.on("pageerror", (e) => errors.push(`${name} pageerror: ${e.message}`)); page.on("console", (m) => { if (m.type() === "error") errors.push(`${name} console: ${m.text().slice(0, 160)}`); }); for (const p of pages) { try { await page.goto(base + p, { waitUntil: "networkidle", timeout: 45000 }); await page.waitForTimeout(800); await page.screenshot({ path: `${out}/${name}${p.replace(/[^a-z0-9]+/gi, "_") || "_home"}.png`, fullPage: !p.startsWith("/carte") }); console.log("ok", name, p); } catch (e) { console.log("ERR", name, p, e.message.slice(0, 120)); } } if (errors.length) console.log(errors.slice(0, 12).join("\n")); await ctx.close(); } await browser.close();