SPB Git forge

spb/auto-ka

Public
61commits 1branches 0releases
14.4 MBsize
maindefault branch
12 days agolast push
Python 61.6% TypeScript 20.9% CSS 11.4% JavaScript 5.1% HTML 1.1%
3.9 KB · 85 lines javascript
Raw Blame History
1// Vérification UI du système de filtres (barre compacte + FilterSheet) — mobile iPhone.2import { chromium } from "playwright";3const browser = await chromium.launch();4const page = await browser.newPage({5  viewport: { width: 390, height: 844 },6  hasTouch: true,7  isMobile: true,8  deviceScaleFactor: 2,9});10const errors = [];11page.on("pageerror", (e) => errors.push(String(e)));12page.on("console", (m) => { if (m.type() === "error") errors.push(m.text()); });1314await page.goto("http://localhost:8095/", { waitUntil: "networkidle" });15await page.waitForSelector(".vcard", { timeout: 15000 });1617const checks = {};18checks.ancien_panneau_absent = (await page.locator(".filters").count()) === 0;19checks.bouton_filtres = await page.locator(".filters-btn").textContent();20checks.compteur = await page.locator(".result-bar .count").textContent();21// la 1re carte véhicule doit être proche du haut de page (pas 2000px plus bas)22checks.y_premiere_carte = Math.round(await page.locator(".vcard").first().evaluate((el) => el.getBoundingClientRect().top + window.scrollY));23await page.screenshot({ path: "/tmp/autoka-filtres-1-accueil.png" });2425// — ouverture du bottom sheet —26await page.locator(".filters-btn").tap();27await page.waitForSelector(".fsheet", { timeout: 5000 });28checks.sheet_ouvert = true;29checks.scroll_verrouille = await page.evaluate(() => document.documentElement.classList.contains("ka-scroll-lock"));30checks.sliders = await page.locator(".dr").count(); // prix + année + km = 33132// marque via select natif (attendre le chargement des facettes)33await page.waitForFunction(() => {34  const s = document.querySelector(".fsheet select");35  return s && s.options.length > 1;36}, { timeout: 10000 });37await page.locator(".fsheet select").first().evaluate((el) => {38  const opt = [...el.options].find((o) => o.value === "Honda");39  el.value = opt ? "Honda" : el.options[1].value;40  el.dispatchEvent(new Event("change", { bubbles: true }));41});42// prix max via clavier sur la poignée max du 1er slider (2 crans = -5 000 $)43const pmax = page.locator(".fs-field:has(.fs-label:text('Prix')) .dr input").nth(1);44await pmax.focus();45await page.keyboard.press("ArrowLeft");46await page.keyboard.press("ArrowLeft");47checks.readout_prix = await page.locator(".fs-field:has(.fs-label:text('Prix')) .dr-readout").textContent();48// « Plus de filtres »49await page.locator(".fs-more").tap();50checks.plus_de_filtres = (await page.locator(".fsheet select").count()) >= 6;51// compteur en direct dans le CTA52await page.waitForTimeout(900);53checks.cta = (await page.locator(".fs-apply").textContent())?.trim();54await page.screenshot({ path: "/tmp/autoka-filtres-2-sheet.png" });5556// — appliquer —57await page.locator(".fs-apply").tap();58await page.waitForTimeout(1200);59checks.url_apres_apply = page.url();60checks.chips = await page.locator(".fchip").allTextContents();61checks.badge_nb_filtres = await page.locator(".fb-n").textContent().catch(() => "ABSENT");62await page.screenshot({ path: "/tmp/autoka-filtres-3-applique.png" });6364// — retirer un chip —65await page.locator(".fchip").first().tap();66await page.waitForTimeout(800);67checks.url_apres_retrait_chip = page.url();68checks.chips_restants = await page.locator(".fchip").allTextContents();6970// — réouverture + réinitialiser —71await page.locator(".filters-btn").tap();72await page.waitForSelector(".fsheet");73await page.locator(".fs-reset").tap();74await page.waitForTimeout(700);75checks.cta_apres_reset = (await page.locator(".fs-apply").textContent())?.trim();76// fermeture par le voile77await page.locator(".fsheet-veil").tap({ position: { x: 20, y: 60 } });78await page.waitForTimeout(300);79checks.sheet_ferme = (await page.locator(".fsheet").count()) === 0;80checks.scroll_deverrouille = await page.evaluate(() => !document.documentElement.classList.contains("ka-scroll-lock"));8182console.log(JSON.stringify(checks, null, 2));83console.log("JS errors:", errors.length ? errors : "aucune");84await browser.close();85