// Regression guards for the connector-catalog renderer. // // Run: node --test extensions/connector-namespaces/renderer.test.mjs // // These tests exist because two UX bugs kept coming back: // 1. A `@media (prefers-reduced-motion: reduce)` rule froze functional // loaders without a visible fallback. Reduced motion now stops the // animation while forcing each loader into a visible static busy state; // nearby text continues to communicate progress. // 2. The "Restart your Copilot session" banner ignoring Dismiss. The real // root cause was CSS specificity: `.restart-banner{display:flex}` is an // author rule with the same (0,1,0) specificity as the UA // `[hidden]{display:none}` rule, so it overrode the hidden attribute and // `restartBanner.hidden=true` did nothing. The fix is a global // `[hidden]{display:none !important}` reset. A client-side // `restartDismissed` flag also keeps a late hydrateState() from re-showing // it. The guards below fail if either the CSS reset or the JS gate // disappears. import { test } from "node:test"; import assert from "node:assert/strict"; import { baseStyles, renderCatalogHtml, renderSetupHtml } from "./renderer.mjs"; import { renderCreateNamespaceHtml } from "./createPage.mjs"; import { CATEGORY } from "./categories.mjs"; // Pull the balanced body of the prefers-reduced-motion media block out of a // stylesheet string (non-greedy regex can't handle the nested rule braces). // CSS comments are stripped so the guards test declarations rather than prose. function reducedMotionBlock(css) { const start = css.indexOf("@media (prefers-reduced-motion: reduce)"); if (start === -1) return null; const open = css.indexOf("{", start); if (open === -1) return null; let depth = 0; for (let i = open; i < css.length; i++) { if (css[i] === "{") depth++; else if (css[i] === "}" && --depth === 0) { return css.slice(open + 1, i).replace(/\/\*[\s\S]*?\*\//g, ""); } } return null; } function catalogHtml() { return renderCatalogHtml("test-instance", [], { filter: "", category: "all", source: "", config: { subscriptionId: "sub", gatewayName: "ns", resourceGroup: "rg" }, }); } test("setup subscription label names its select", () => { const html = renderSetupHtml([], "", "token"); assert.match(html, /