import { chromium } from "@playwright/test"; const ID = process.argv[2] ?? "660dd007-cc6f-4644-a57b-9c32a012e60a";; const b = await chromium.launch(); const ctx = await b.newContext(); await ctx.addCookies([{ name: "qai_s", value: "tokAPI", url: "http://localhost:3117" }]); const page = await ctx.newPage(); const errs = []; page.on("pageerror", (e) => errs.push(String(e.message).slice(0, 140))); await page.goto(`http://localhost:3117/app/${ID}`, { waitUntil: "domcontentloaded" }); await page.waitForSelector("#report", { timeout: 25000 }); const q = async (sel) => page.locator(sel).count(); console.log("QAI report", await q("#report"), "cards", await q("#report .card"), "sql blocks", await q("#report pre.sql"), "copy buttons", await q("#report button"), "tables", await q("#report table"), "bars", await q("#report .bar"), "verdict", await q("[data-verdict]"), "metrics", await q(".grid-metrics .card")); console.log("QAI headline", (await page.locator("#report h2").first().textContent())?.slice(0, 90)); console.log("QAI console errors", errs.length, errs.slice(0, 2)); for (const w of [320, 375, 414, 768]) { await page.setViewportSize({ width: w, height: 800 }); await page.waitForTimeout(250); const over = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth); console.log(`QAI ${w}px overflow ${over}`); } await page.setViewportSize({ width: 1280, height: 900 }); await page.emulateMedia({ media: "print" }); console.log("QAI print rail hidden", await page.locator(".rail").isHidden(), "toolbar hidden", await page.locator(".toolbar").first().isHidden(), "body bg", await page.evaluate(() => getComputedStyle(document.body).backgroundColor)); await b.close();