import { expect, test } from "@playwright/test"; /** * Cluster C Playwright sweep — diagnostics overlay mount/unmount. The * harness page exposes `window.mountDiagnostics()` and * `window.unmountDiagnostics()` hooks; this spec verifies the overlay * element appears, displays the expected cache stats prefix, and * unmounts cleanly. */ test.describe("diagnostics overlay (cluster C)", () => { test("mounts and unmounts cleanly", async ({ page }) => { await page.goto("/"); const mountedText = await page.evaluate(async () => { const win = window as unknown as { mountDiagnostics?: () => Promise; }; if (typeof win.mountDiagnostics !== "function") return null; await win.mountDiagnostics(); return document.querySelector("[data-packer-browser-diagnostics]") ?.textContent; }); if (mountedText === null) { test.skip(true, "harness did not expose mountDiagnostics"); return; } expect(mountedText).toContain("packer-browser cache.size"); const present = await page.evaluate(async () => { const win = window as unknown as { unmountDiagnostics?: () => void; }; win.unmountDiagnostics?.(); return document.querySelector("[data-packer-browser-diagnostics]"); }); expect(present).toBeNull(); }); });