"""Bounded actual Overview loopback candidate checks; no external fleet probes.""" import hashlib import json from pathlib import Path from urllib.request import urlopen import zipfile from playwright.sync_api import sync_playwright, expect from browser_zoom import zoom_browser, set_browser_zoom ROOT = Path(__file__).resolve().parents[5] OUT = Path(__file__).resolve().parent / "overview-after" OUT.mkdir(exist_ok=True) BASE = "http://127.0.0.1:5198" PACKAGE = ROOT / "ZB.MOM.WW.Theme/artifacts/ZB.MOM.WW.Theme.1.0.0.nupkg" def state(page): return page.evaluate("""() => { const styles = selector => [...document.querySelectorAll(selector)].map(e => { const s=getComputedStyle(e); return {text:e.textContent.trim().slice(0,100), color:s.color, background:s.backgroundColor, opacity:s.opacity}; }); const active=document.activeElement; return {url:location.href, innerWidth, innerHeight, devicePixelRatio, scrollWidth:document.documentElement.scrollWidth, mainVisible:document.querySelector('main').getBoundingClientRect().height>0, navOpen:document.querySelector('.app-shell').open, active:{tag:active.tagName, name:active.textContent.trim().slice(0,80), outline:getComputedStyle(active).outline,focusVisible:active.matches(':focus-visible')}, selected:styles('.rail-link.active'), status:styles('.chip,.conn-pill'), values:styles('.agg-card.good .agg-value,.agg-card.quiet .agg-value'), rise:[...document.querySelectorAll('.rise')].map(e=>({ animation:getComputedStyle(e).animationName,opacity:getComputedStyle(e).opacity, transform:getComputedStyle(e).transform})), fonts:document.fonts.check('14px "IBM Plex Sans"')}; }""") results = {"packageSha256": hashlib.sha256(PACKAGE.read_bytes()).hexdigest(), "packageSourceRevision": "3d61456d6150145a525a3a646721f865f5680c1b", "fixture": "Actual Overview host, one registry entry pointing only at its own loopback health", "assets": {}, "cases": []} with zipfile.ZipFile(PACKAGE) as package: for name in ["css/theme.css", "css/layout.css", "fonts/ibm-plex-sans-400.woff2", "fonts/ibm-plex-sans-600.woff2", "fonts/ibm-plex-mono-500.woff2"]: response=urlopen(BASE + "/_content/ZB.MOM.WW.Theme/" + name) data=response.read() assert response.status == 200 and data == package.read("staticwebassets/" + name), name results["assets"][name] = hashlib.sha256(data).hexdigest() with sync_playwright() as p: with zoom_browser(p) as (context, worker): page=context.pages[0] errors=[] page.on("pageerror", lambda error: errors.append(str(error))) page.emulate_media(reduced_motion="reduce") for width,height in [(1440,900),(1024,768),(390,844)]: page.set_viewport_size({"width":width,"height":height}) page.goto(BASE) expect(page.get_by_role("heading",name="Fleet Overview",exact=True)).to_be_visible() page.evaluate("document.fonts.ready") data=state(page) assert data["scrollWidth"] <= data["innerWidth"], data assert data["mainVisible"] and data["fonts"] assert all(x["animation"]=="none" and x["opacity"]=="1" and x["transform"]=="none" for x in data["rise"]) assert data["selected"][0]["background"] == "rgb(242, 236, 252)" page.screenshot(path=str(OUT/f"overview-{width}.png"),full_page=True) results["cases"].append(data) if width==390: toggle=page.locator("summary.rail-toggle") # Native user interaction opens/closes only navigation; content stays visible. for _ in range(2): toggle.click() changed=state(page) assert changed["mainVisible"] and changed["scrollWidth"] <= changed["innerWidth"] results["cases"].append(changed) page.set_viewport_size({"width":1440,"height":900}) page.goto(BASE) expect(page.get_by_test_id("pause-toggle")).to_be_visible() # Wait for the real InteractiveServer control; this only pauses the local UI view. pause=page.get_by_test_id("pause-toggle") pause.click() expect(pause).to_have_text("Resume auto-refresh") pause.click() expect(pause).to_have_text("Pause auto-refresh") page.keyboard.press("Tab") keyboard=state(page) assert keyboard["active"]["focusVisible"] and "2px" in keyboard["active"]["outline"], keyboard["active"] results["keyboard"] = keyboard["active"] assert set_browser_zoom(worker,page,2)==2 zoom=state(page) assert zoom["innerWidth"]==720 and zoom["devicePixelRatio"]==2 assert zoom["mainVisible"] and zoom["scrollWidth"] <= zoom["innerWidth"] page.screenshot(path=str(OUT/"overview-200-percent.png"),full_page=False) results["actualBrowserZoom"] = zoom results["pageErrors"]=errors assert not errors, errors (OUT/"results.json").write_text(json.dumps(results,indent=2)+"\n") print(json.dumps({"cases":len(results["cases"]),"allFiveAssetBytesMatch":True,"actualZoom":2,"pageErrors":results["pageErrors"]}))