SPB Git forge

spb/rent-ka

Public
8commits 1branches 0releases
7.4 MBsize
maindefault branch
20 days agolast push
Python 68.8% TypeScript 18.6% CSS 8.7% JavaScript 3.3% HTML 0.6%
2.3 KB · 45 lines javascript
Raw Blame History
1// Validation ordre des sections — fiche Lou-Ka (ordre DOM = ordre visuel)2import { chromium, devices } from "playwright";34const UID = process.argv[2] || "lespac:225560010";5const URL = `http://localhost:8095/logement/${encodeURIComponent(UID)}`;67async function check(name, ctxOpts) {8  const browser = await chromium.launch();9  const ctx = await browser.newContext(ctxOpts);10  const page = await ctx.newPage();11  await page.goto(URL, { waitUntil: "networkidle" });12  await page.waitForSelector(".f-galerie", { timeout: 15000 });13  await page.waitForTimeout(1500); // laisse PriceAnalysis/carte se charger14  const data = await page.evaluate(() => {15    const sel = [".f-galerie", ".f-hero", ".f-desc", ".f-incl", ".f-pratique",16                 ".f-fairvalue", ".f-carte", ".f-kascores", ".f-quartier", ".f-poi"];17    const out = [];18    for (const s of sel) {19      const el = document.querySelector(s);20      if (!el) { out.push({ s, missing: true }); continue; }21      const r = el.getBoundingClientRect();22      const hidden = r.height === 0 && r.width === 0;23      out.push({ s, hidden, top: Math.round(r.top + window.scrollY), left: Math.round(r.left), order: getComputedStyle(el).order });24    }25    return { out, scrollY: window.scrollY };26  });27  console.log(`\n=== ${name} ===  scrollY initial: ${data.scrollY}`);28  for (const b of data.out)29    console.log(b.missing ? `${b.s.padEnd(14)} (non rendue)` : b.hidden ? `${b.s.padEnd(14)} (vide/masquée)` :30      `${b.s.padEnd(14)} top=${String(b.top).padStart(6)}  left=${String(b.left).padStart(4)}  order=${b.order}`);31  await browser.close();32  return data;33}3435const mob = await check("iPhone 14 (mobile)", { ...devices["iPhone 14"] });36await check("Desktop 1440px", { viewport: { width: 1440, height: 900 } });3738const vis = mob.out.filter(b => !b.missing && !b.hidden);39const sorted = vis.every((b, i) => i === 0 || b.top >= vis[i - 1].top);40const noOrder = vis.every(b => b.order === "0");41const ok = sorted && mob.scrollY === 0 && vis[0].s === ".f-galerie" && vis[0].top < 300 && noOrder;42console.log(`\nMOBILE: ordre visuel ${sorted ? "CROISSANT ✓" : "DÉSORDONNÉ ✗"} · scrollY=${mob.scrollY} ✓ · 1re section=${vis[0].s} top=${vis[0].top} · sans order CSS=${noOrder}`);43console.log(ok ? "VALIDATION OK" : "VALIDATION ÉCHEC");44process.exit(ok ? 0 : 1);45