Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/live-demo-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Live demo check

# Loads genclass.dev in headless Chromium (a visible tab, which the runtime requires for held decisions) and asserts
# that the double-click demo coalesces the duplicate. Run after every site deploy and daily.
on:
workflow_dispatch:
inputs:
url:
description: "Page to check"
default: "https://genclass.dev/"
required: false
schedule:
- cron: "17 6 * * *"

permissions:
contents: read

jobs:
demo:
name: "genclass.dev: double-click demo"
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Install Playwright (Chromium only)
run: |
mkdir -p /tmp/pw && cd /tmp/pw && npm init -y >/dev/null && npm i --no-audit --no-fund playwright
cd /tmp/pw && npx playwright install --with-deps chromium
- name: Check the live demo
env:
DEMO_URL: ${{ github.event.inputs.url || 'https://genclass.dev/' }}
NODE_PATH: /tmp/pw/node_modules
run: node site/check/live-demo.mjs
60 changes: 60 additions & 0 deletions site/check/live-demo.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Live demo check for genclass.dev: loads the home page in headless Chromium, waits for the model, presses
// "Double-click both" and asserts that the GenClass side sent one invoice while the plain side sent two.
// Run by .github/workflows/live-demo-check.yml (after a site deploy, and daily). Local use:
// DEMO_URL=https://genclass.dev/ node site/check/live-demo.mjs
//
// Two runs: the first with the lab's explicit hold budget (?lab-hold=900), which checks the page and the runtime's
// action path on a WASM-only runner; the second with the runtime's automatic budget (?lab-hold=auto), which is
// informational: on WASM the first decision can be slower than the first automatic budget (see PR #4).
//
// The runtime skips held decisions in a hidden tab by design, so the check asserts document.visibilityState first.
import { chromium } from "playwright";

const base = process.env.DEMO_URL || "https://genclass.dev/";
const sep = base.includes("?") ? "&" : "?";

async function run(label, query, { mustPass }) {
const browser = await chromium.launch();
const page = await browser.newPage();
const consoleLines = [];
page.on("console", (m) => {
const t = m.text();
if (t.includes("[GenClass]")) consoleLines.push(t);
});
const url = `${base}${sep}${query}&check=${Date.now()}`;
await page.goto(url, { waitUntil: "load" });
const vis = await page.evaluate(() => document.visibilityState);
if (vis !== "visible") throw new Error(`${label}: visibilityState is ${vis}; the runtime skips held decisions in a hidden tab, so this run proves nothing`);
await page.waitForFunction(() => window.GenClass?.runtime?.status?.state === "ready", null, { timeout: 120_000 });
const model = await page.evaluate(() => {
const s = GenClass.runtime.status;
return { device: s.device, variant: s.variant, loadMs: s.loadMs, holdBudgetMs: GenClass.runtime.holdBudgetMs(), latency: s.latency };
});
await page.waitForFunction(() => !document.getElementById("dup-go")?.disabled, null, { timeout: 10_000 });
await page.click("#dup-go");
await page.waitForFunction(
() => /invoice/.test(document.getElementById("inv-on-v")?.textContent || "") && /invoice/.test(document.getElementById("inv-off-v")?.textContent || ""),
null,
{ timeout: 20_000 },
);
const result = await page.evaluate(() => {
const a = GenClass.runtime.audit();
const recs = Array.isArray(a) ? a : a.decisions || [];
return {
on: document.getElementById("inv-on-v").textContent,
off: document.getElementById("inv-off-v").textContent,
decisions: recs.map((d) => ({ trigger: d.trigger, diagnosis: d.diagnosis, p: d.diagnosisConfidence, ran: d.ran, executed: d.executed, held: d.held, holdBudgetMs: d.holdBudgetMs, latencyMs: d.latencyMs, reason: d.reason })),
};
});
await browser.close();
const ok = /^1 invoice sent/.test(result.on) && /^2 identical invoices sent/.test(result.off);
console.log(`\n== ${label} (${url})`);
console.log(JSON.stringify({ model, ...result, consoleLines }, null, 2));
console.log(ok ? `${label}: OK` : `${label}: FAILED (${mustPass ? "blocking" : "informational"})`);
return ok;
}

const explicit = await run("explicit hold budget", "lab-hold=900", { mustPass: true });
const auto = await run("automatic hold budget", "lab-hold=auto", { mustPass: false });
console.log(`\nsummary: explicit=${explicit ? "ok" : "FAILED"} automatic=${auto ? "ok" : "failed (informational)"}`);
if (!explicit) process.exit(1);
Loading