// QA interactions de la fiche : bottom sheets, assistant Ka, filtres carte, fiche sans coordonnées. // Usage : node frontend/scripts/interactions.mjs [baseUrl] [outDir] [uidRiche] [uidPauvre] import { chromium, devices } from "playwright"; const BASE = process.argv[2] || "http://127.0.0.1:8095"; const OUT = process.argv[3] || "/tmp"; const RICHE = process.argv[4] || "zumper:60608306"; const PAUVRE = process.argv[5] || "royal_lepage:21803288"; const browser = await chromium.launch(); const ctx = await browser.newContext({ ...devices["iPhone 14"] }); const page = await ctx.newPage(); const errs = []; page.on("pageerror", (e) => errs.push("PAGEERROR " + e.message)); await page.goto(`${BASE}/logement/${encodeURIComponent(RICHE)}`, { waitUntil: "networkidle" }); await page.waitForSelector(".lk-hero"); await page.waitForTimeout(1500); // accepter les témoins pour dégager l'écran const ok = page.locator(".cookie-actions .btn-primary, .cookie-actions button").last(); if (await ok.count()) await ok.click().catch(() => {}); await page.waitForTimeout(400); // 1) sheet des loyers await page.locator("#loyers .lk-more").scrollIntoViewIfNeeded(); await page.locator("#loyers .lk-more").click(); await page.waitForTimeout(600); await page.screenshot({ path: `${OUT}/ix-sheet-loyers.png` }); await page.locator(".lk-sheet-x").click(); await page.waitForTimeout(300); // 2) sheet lieux await page.locator("#proximite .lk-more").scrollIntoViewIfNeeded(); await page.locator("#proximite .lk-more").click(); await page.waitForTimeout(600); await page.screenshot({ path: `${OUT}/ix-sheet-lieux.png` }); await page.locator(".lk-sheet-x").click(); await page.waitForTimeout(300); // 3) filtres carte await page.locator("#carte").scrollIntoViewIfNeeded(); await page.waitForTimeout(2500); await page.locator("#carte .lk-chip", { hasText: "Transport" }).click(); await page.locator("#carte .lk-chip", { hasText: "Épiceries" }).click(); await page.waitForTimeout(2500); await page.screenshot({ path: `${OUT}/ix-carte-filtres.png` }); // 4) assistant Ka await page.locator(".lk-ka-btn").click(); await page.waitForTimeout(600); await page.screenshot({ path: `${OUT}/ix-ka-sheet.png` }); await page.locator(".lk-ka-sug").first().click(); await page.waitForTimeout(1500); await page.screenshot({ path: `${OUT}/ix-ka-agent.png` }); const kaOpen = await page.evaluate(() => !!document.querySelector(".kaa-panel.kaa-open")); console.log("KA Agent ouvert :", kaOpen); // 5) accordéon dossier await page.keyboard.press("Escape"); await page.waitForTimeout(400); await page.locator("#dossier .lk-acc-btn").first().scrollIntoViewIfNeeded(); await page.locator("#dossier .lk-acc-btn").first().click(); await page.waitForTimeout(800); await page.screenshot({ path: `${OUT}/ix-dossier.png` }); // 6) fiche pauvre (sans chambres/KA Score) await page.goto(`${BASE}/logement/${encodeURIComponent(PAUVRE)}`, { waitUntil: "networkidle" }); await page.waitForSelector(".lk-hero"); await page.waitForTimeout(3000); await page.screenshot({ path: `${OUT}/ix-pauvre-top.png` }); await page.screenshot({ path: `${OUT}/ix-pauvre-full.png`, fullPage: true }); // 7) 404 const r = await page.goto(`${BASE}/logement/inexistant:0`, { waitUntil: "networkidle" }); await page.waitForTimeout(800); await page.screenshot({ path: `${OUT}/ix-404.png` }); console.log("404 status", r?.status(), "errors", errs); await browser.close();