mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 12:52:26 +00:00
chore(perf): add nip-07/relay diagnostic harnesses + dev REQ monitor
Headless Playwright probes that reproduce the real login path via a fake window.nostr extension (which loginWithNsec bypasses) and measure steady-state extension-call and relay-REQ rates: - nip07-heat.mjs, req-capture.mjs, ws-lifecycle.mjs, loopc-capture.mjs, etc. Plus js/devReqMonitor.js: a localhost-only WebSocket REQ-rate monitor that warns in-console when relay traffic spikes, naming the storming kinds — used to capture the real-environment storm the mock-relay harness could not see. Removable once the refactor lands. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
a3b205bfa1
commit
35c4e68cde
10 files changed
+674
No files matched your search
@@ -0,0 +1,58 @@
|
||||
// Reproduces the logged-out "videos don't load until refresh after dismissing
|
||||
// the disclaimer" bug. Fresh context (no hasSeenDisclaimer), real relays.
|
||||
//
|
||||
// Usage: APP=http://localhost:3000 node scripts/perf/disclaimer-grid.mjs
|
||||
|
||||
import { chromium } from "playwright";
|
||||
|
||||
const APP = process.env.APP || "http://localhost:3000";
|
||||
|
||||
const cardCount = (page) =>
|
||||
page.evaluate(() => document.querySelectorAll("[data-video-id],[data-video-card]").length);
|
||||
|
||||
const browser = await chromium.launch({ headless: true });
|
||||
const ctx = await browser.newContext(); // fresh: no hasSeenDisclaimer
|
||||
const page = await ctx.newPage();
|
||||
const logs = [];
|
||||
page.on("console", (m) => logs.push(`[${m.type()}] ${m.text()}`.slice(0, 160)));
|
||||
page.on("pageerror", (e) => logs.push(`[pageerror] ${String(e).split("\n")[0]}`));
|
||||
|
||||
await page.goto(APP, { waitUntil: "domcontentloaded", timeout: 30000 });
|
||||
|
||||
// Wait for disclaimer modal to appear.
|
||||
await page.waitForTimeout(3000);
|
||||
const hadDisclaimer = await page.evaluate(() => {
|
||||
const m = document.getElementById("disclaimerModal");
|
||||
return !!m && getComputedStyle(m).display !== "none" && m.offsetParent !== null;
|
||||
});
|
||||
const beforeDismiss = await cardCount(page);
|
||||
|
||||
// Dismiss the disclaimer (click its primary/accept button).
|
||||
let clicked = false;
|
||||
try {
|
||||
const btn = page.locator('#disclaimerModal button, [data-testid="disclaimer-accept"]').first();
|
||||
if (await btn.count()) { await btn.click({ timeout: 4000 }); clicked = true; }
|
||||
} catch (_) {}
|
||||
|
||||
await page.waitForTimeout(6000);
|
||||
const afterDismiss = await cardCount(page);
|
||||
|
||||
// Now reload and re-check (the "refresh fixes it" path).
|
||||
await page.reload({ waitUntil: "domcontentloaded" });
|
||||
await page.waitForTimeout(6000);
|
||||
const afterReload = await cardCount(page);
|
||||
|
||||
await browser.close();
|
||||
|
||||
console.log("\n=== DISCLAIMER → GRID ===");
|
||||
console.log(`disclaimer shown: ${hadDisclaimer}`);
|
||||
console.log(`cards before dismiss: ${beforeDismiss}`);
|
||||
console.log(`dismiss clicked: ${clicked}`);
|
||||
console.log(`cards after dismiss: ${afterDismiss} <- BUG if 0`);
|
||||
console.log(`cards after reload: ${afterReload} <- if >0 here but 0 above = the reported bug`);
|
||||
const interesting = logs.filter((l) => /error|fail|grid|render|feed|disclaimer/i.test(l));
|
||||
if (interesting.length) {
|
||||
console.log("\nrelevant logs:");
|
||||
for (const l of interesting.slice(0, 15)) console.log(" " + l);
|
||||
}
|
||||
console.log("");
|
||||
Reference in new issue
Block a user