Add dev/: training and export scripts, GPAI rule tests, browser tests, workspace map
28e3615 verified Download dev/browser-tests/lazy.mjs from Devseis/Caveat: direct link, hf CLI and curl.
- Browser
- Download file 2.98 kB
-
https://huggingface.co/spaces/Devseis/Caveat/resolve/main/dev/browser-tests/lazy.mjs
- Command line
-
hf download hf://spaces/Devseis/Caveat/dev/browser-tests/lazy.mjs
-
curl -L -o lazy.mjs https://huggingface.co/spaces/Devseis/Caveat/resolve/main/dev/browser-tests/lazy.mjs
2.98 kB
| import puppeteer from "puppeteer-core"; | |
| const S = "/Users/umer/Documents/hf/tools/browser-tests/out"; | |
| const URL_ = process.argv[2] || "http://localhost:8766/"; | |
| async function session(name) { | |
| const b = await puppeteer.launch({ executablePath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", headless: true, userDataDir: `${S}/prof_lazy_${name}`, protocolTimeout: 180000 }); | |
| const p = await b.newPage(); await p.setCacheEnabled(false); | |
| const big = []; const errs = []; | |
| p.on("pageerror", (e) => errs.push(e.message)); | |
| p.on("request", (r) => { if (/\.onnx|\.wasm|xet-bridge/.test(r.url())) big.push(Date.now()); }); | |
| await p.setRequestInterception(true); | |
| p.on("request", (r) => /clarity\.ms/.test(r.url()) ? r.abort() : r.continue()); | |
| await p.goto(URL_, { waitUntil: "networkidle2" }); | |
| if (await p.evaluate(() => !document.getElementById("consent").hidden)) await p.click("#consentDecline"); | |
| return { b, p, big, errs }; | |
| } | |
| // A: reader only | |
| let { b, p, big, errs } = await session("reader"); | |
| await new Promise((r) => setTimeout(r, 1500)); | |
| await p.click('[data-tab="story"]'); await new Promise((r) => setTimeout(r, 1000)); await p.click('[data-tab="learn"]'); await new Promise((r) => setTimeout(r, 1500)); | |
| console.log(`A reader (open page, read Story + Learn): model/engine requests = ${big.length} | button: "${await p.$eval("#runBtn", (e) => e.textContent)}" enabled=${await p.$eval("#runBtn", (e) => !e.disabled)}`); | |
| await b.close(); | |
| // B: focus the text box → download starts | |
| ({ b, p, big, errs } = await session("focus")); | |
| await p.click("#scenario"); await new Promise((r) => setTimeout(r, 2500)); | |
| console.log(`B focus text box: model/engine requests started = ${big.length > 0} | hint: "${await p.$eval("#runHint", (e) => e.textContent)}"`); | |
| await b.close(); | |
| // C: press Check immediately on a fresh visit | |
| ({ b, p, big, errs } = await session("cold")); | |
| const t0 = Date.now(); | |
| await p.evaluate(() => { document.getElementById("scenario").value = "A phone-based voice assistant that takes restaurant orders in conversation with callers."; }); | |
| await p.click("#runBtn"); | |
| const seen = new Set(); const poll = setInterval(async () => { try { seen.add(await p.$eval("#p1status", (e) => e.textContent.trim().slice(0, 45))); } catch (e) {} }, 400); | |
| await p.waitForFunction(() => !document.getElementById("p1result").hidden || /Couldn/.test(document.getElementById("p1status").textContent), { timeout: 150000 }); | |
| clearInterval(poll); | |
| const r = await p.evaluate(() => ({ p1: document.getElementById("p1result").hidden ? document.getElementById("p1status").textContent : document.getElementById("p1pill").textContent, hint: document.getElementById("runHint").textContent })); | |
| console.log(`C cold Check: trained model → ${r.p1} after ${((Date.now() - t0) / 1000).toFixed(1)}s | statuses seen: ${[...seen].filter(Boolean).join(" → ")} | hint after: "${r.hint}"`); | |
| console.log("errors:", [...errs].length ? errs.join(" | ") : "none"); await b.close(); | |