SPB Git forge

spb/job-ka

Public
226commits 1branches 0releases
37.5 MBsize
maindefault branch
11 h agolast push
HTML 82.1% Python 14.6% TypeScript 1.9% CSS 1% JavaScript 0.5%
2.3 KB · 35 lines javascript
Raw Blame History
1// Parcours d'interactions Playwright sur la fiche (mobile) : galerie plein2// écran, panneau « Voir les N lieux », « Demander à Ka », accordéons — vérifie3// l'absence d'erreur JS et que chaque panneau s'ouvre puis se ferme.4// Usage : node frontend/scripts/interactions.mjs <uid> [baseUrl]5import { chromium, devices } from "playwright";6const UID = process.argv[2]; const BASE = process.argv[3] || "http://127.0.0.1:8096";7if (!UID) { console.error("usage: node interactions.mjs <uid> [baseUrl]"); process.exit(2); }8const browser = await chromium.launch();9const ctx = await browser.newContext({ ...devices["iPhone 14"] }); const page = await ctx.newPage();10const errs = [];11page.on("pageerror", (e) => errs.push("PAGEERROR " + e.message));12page.on("console", (m) => { if (m.type() === "error") errs.push(m.text().slice(0, 160)); });13await page.goto(`${BASE}/emploi/${encodeURIComponent(UID)}`, { waitUntil: "networkidle" });14await page.waitForSelector(".jk-hero");15const step = async (name, fn) => { try { await fn(); console.log("OK  ", name); } catch (e) { console.log("FAIL", name, String(e).split("\n")[0]); } };16await step("accordéon méthodologie salaire", async () => {17  const b = page.locator("#salaire .jk-acc-btn").first(); await b.scrollIntoViewIfNeeded(); await b.click();18  await page.waitForSelector("#salaire .jk-acc-body.open", { timeout: 2000 });19});20await step("accordéon dossier", async () => {21  const b = page.locator("#dossier .jk-acc-btn").first(); await b.scrollIntoViewIfNeeded(); await b.click();22  await page.waitForSelector("#dossier .jk-acc-body.open", { timeout: 2000 });23});24await step("Demander à Ka : sheet", async () => {25  await page.evaluate(() => window.scrollTo(0, 1200)); await page.waitForTimeout(500);26  await page.click(".jk-ka-btn"); await page.waitForSelector(".jk-sheet", { timeout: 3000 });27  await page.click(".jk-sheet-x"); await page.waitForSelector(".jk-sheet", { state: "detached", timeout: 3000 });28});29await step("404", async () => {30  await page.goto(`${BASE}/emploi/inexistant:0`, { waitUntil: "networkidle" }); await page.waitForSelector(".jk-page-error", { timeout: 8000 });31});32console.log("erreurs console:", errs.length, errs.slice(0, 5));33await browser.close();34process.exit(errs.filter((e) => !/Failed to fetch|api-ka|kaa/.test(e)).length ? 1 : 0);35