SPB Git forge

spb/house-ka

Public
18commits 1branches 0releases
1.9 MBsize
maindefault branch
19 days agolast push
Python 67% TypeScript 18.2% CSS 14.4%
2.1 KB · 42 lines javascript
Raw Blame History
1// Validation ordre des sections — fiche Immo-Ka (ordre DOM = ordre visuel)2import { chromium, devices } from "playwright";34const BASE = process.env.BASE || "http://localhost:18096";5const UID = process.argv[2];6const URL = `${BASE}/property/${encodeURIComponent(UID)}`;7const SEL = [".f-galerie", ".f-hero", ".f-desc", "#caracteristiques", "#pieces", "#inclusions", "#carte", ".quartier"];89async function check(name, ctxOpts) {10  const browser = await chromium.launch();11  const ctx = await browser.newContext(ctxOpts);12  const page = await ctx.newPage();13  await page.goto(URL, { waitUntil: "networkidle" });14  await page.waitForSelector(".f-galerie", { timeout: 15000 });15  await page.waitForTimeout(1200);16  const data = await page.evaluate((sel) => {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      out.push({ s, hidden: r.height === 0 && r.width === 0, top: Math.round(r.top + window.scrollY), left: Math.round(r.left), order: getComputedStyle(el).order });23    }24    return { out, scrollY: window.scrollY };25  }, SEL);26  console.log(`\n=== ${name} ===  scrollY: ${data.scrollY}`);27  for (const b of data.out)28    console.log(b.missing ? `${b.s.padEnd(18)} (non rendue)` : b.hidden ? `${b.s.padEnd(18)} (vide/masquée)` :29      `${b.s.padEnd(18)} top=${String(b.top).padStart(6)}  left=${String(b.left).padStart(4)}  order=${b.order}`);30  await browser.close();31  return data;32}3334const mob = await check("iPhone 14 (mobile)", { ...devices["iPhone 14"] });35await check("Desktop 1440px", { viewport: { width: 1440, height: 900 } });36const vis = mob.out.filter(b => !b.missing && !b.hidden);37const sorted = vis.every((b, i) => i === 0 || b.top >= vis[i - 1].top);38const ok = sorted && mob.scrollY === 0 && vis[0].s === ".f-galerie" && vis.every(b => b.order === "0");39console.log(`\nMOBILE: ordre ${sorted ? "CROISSANT ✓" : "DÉSORDONNÉ ✗"} · scrollY=${mob.scrollY} · 1re=${vis[0].s} · sans order=${vis.every(b => b.order === "0")}`);40console.log(ok ? "VALIDATION OK" : "VALIDATION ÉCHEC");41process.exit(ok ? 0 : 1);42