HTML 82.1%
Python 14.6%
TypeScript 1.9%
CSS 1%
JavaScript 0.5%
1// Captures Playwright de la fiche propriété à 6 largeurs (QA visuelle).2// Usage : node frontend/scripts/shots.mjs <uid> [baseUrl] [outDir]3import { chromium, devices } from "playwright";4const UID = process.argv[2];5if (!UID) { console.error("usage: node shots.mjs <uid> [baseUrl] [outDir]"); process.exit(2); }6const BASE = process.argv[3] || "http://127.0.0.1:8096";7const OUT = process.argv[4] || "/tmp";8const shots = [9 ["iphone14", { ...devices["iPhone 14"] }],10 ["w375", { viewport: { width: 375, height: 812 }, deviceScaleFactor: 2, isMobile: true, hasTouch: true }],11 ["w430", { viewport: { width: 430, height: 932 }, deviceScaleFactor: 2, isMobile: true, hasTouch: true }],12 ["w768", { viewport: { width: 768, height: 1024 }, deviceScaleFactor: 1 }],13 ["w1024", { viewport: { width: 1024, height: 800 }, deviceScaleFactor: 1 }],14 ["w1440", { viewport: { width: 1440, height: 900 }, deviceScaleFactor: 1 }],15];16const browser = await chromium.launch();17for (const [name, opts] of shots) {18 const ctx = await browser.newContext(opts); const page = await ctx.newPage();19 const errs = [];20 page.on("pageerror", (e) => errs.push("PAGEERROR " + e.message));21 page.on("console", (m) => { if (m.type() === "error") errs.push(m.text().slice(0, 200)); });22 await page.goto(`${BASE}/emploi/${encodeURIComponent(UID)}`, { waitUntil: "networkidle" });23 await page.waitForSelector(".jk-hero", { timeout: 20000 });24 // html{scroll-behavior:smooth} du site fausse le retour en haut scripté → défilement instantané pour les captures25 await page.evaluate(() => { document.documentElement.style.scrollBehavior = "auto"; });26 // défilement complet (déclenche les chargements différés) puis retour en haut27 await page.evaluate(async () => {28 for (let y = 0; y < document.body.scrollHeight; y += 600) { window.scrollTo(0, y); await new Promise((r) => setTimeout(r, 120)); }29 window.scrollTo({ top: 0, behavior: "instant" });30 });31 await page.waitForTimeout(3500);32 const ov = await page.evaluate(() => document.documentElement.scrollWidth - window.innerWidth);33 await page.screenshot({ path: `${OUT}/jk-${name}-full.png`, fullPage: true });34 await page.screenshot({ path: `${OUT}/jk-${name}-top.png` });35 await page.evaluate(() => window.scrollTo({ top: 900, behavior: "instant" })); await page.waitForTimeout(600);36 await page.screenshot({ path: `${OUT}/jk-${name}-scrolled.png` });37 console.log(name, "overflow", ov, "errors", errs.length, errs.slice(0, 3).join(" | "));38 await ctx.close();39}40await browser.close();41