qa(idle-poll): assert zero background reqs in a 55s idle window #12

Merged
shad merged 1 commits from qa/idle-poll-strict-zero into main 2026-06-15 00:25:13 +00:00
+19 -10
View File
@@ -1,8 +1,16 @@
// Idle-poll audit. User explicitly complained "way too many GETs / non-stop". // Idle-poll audit. User explicitly complained "way too many GETs / non-stop".
// For each scene: visit, settle, then watch network for 30s with no user input. // For each scene: visit, settle for a generous burst window, then watch network
// Pass if total requests in that 30s window is reasonable (<= 5). // for 60s with no user input. Strict assertion: zero background /api/* or
// The topbar identity-hydration + chat/queue badge polls at 60s, so a 30s // /internal/* requests during that window.
// window should see at most 1 such fire. //
// What counts as "background":
// - Anything fired more than SETTLE_MS after the scene becomes interactive
// - Excludes the 60s topbar badge poll fired exactly at minute boundaries —
// the window is sized to fit BETWEEN two such fires
//
// The topbar badge poll runs every 60s. A 55s observation window after a
// 5s settle covers a full minute of operator inactivity without spanning
// the next poll boundary, so the strict assertion "zero" is correct.
import { chromium } from "playwright"; import { chromium } from "playwright";
const URL = "https://canvas.flow-master.ai/"; const URL = "https://canvas.flow-master.ai/";
@@ -19,8 +27,9 @@ const SCENES = [
{ chip: /What is FlowMaster/, label: "explainer" }, { chip: /What is FlowMaster/, label: "explainer" },
]; ];
const IDLE_WINDOW_MS = 30_000; const SETTLE_MS = 5_000;
const MAX_REQ_PER_WINDOW = 5; const IDLE_WINDOW_MS = 55_000;
const MAX_REQ_PER_WINDOW = 0;
const results = []; const results = [];
function record(name, ok, detail = "") { function record(name, ok, detail = "") {
@@ -49,7 +58,7 @@ for (const s of SCENES) {
// Settle period — the scene's initial fetch burst should complete here. // Settle period — the scene's initial fetch burst should complete here.
await p.waitForLoadState("networkidle").catch(() => {}); await p.waitForLoadState("networkidle").catch(() => {});
await p.waitForTimeout(1500); await p.waitForTimeout(SETTLE_MS);
// Now record every request fired for the next IDLE_WINDOW_MS. // Now record every request fired for the next IDLE_WINDOW_MS.
const requests = []; const requests = [];
@@ -65,9 +74,9 @@ for (const s of SCENES) {
const ok = requests.length <= MAX_REQ_PER_WINDOW; const ok = requests.length <= MAX_REQ_PER_WINDOW;
const summary = requests.length const summary = requests.length
? `${requests.length} reqs · ${requests.slice(0, 3).map((r) => `${r.method} ${r.url.slice(0, 50)}`).join(", ")}${requests.length > 3 ? "…" : ""}` ? `${requests.length} background reqs in ${IDLE_WINDOW_MS / 1000}s · ${requests.slice(0, 3).map((r) => `${r.method} ${r.url.slice(0, 50)}`).join(", ")}${requests.length > 3 ? "…" : ""}`
: "0 reqs · quiet"; : `0 background reqs in ${IDLE_WINDOW_MS / 1000}s`;
record(`idle_${s.label}_quiet_at_30s`, ok, summary); record(`idle_${s.label}_zero_background_traffic`, ok, summary);
} }
await b.close(); await b.close();