#!/usr/bin/env python3 """Show the baked indexer presets in the page, and the fail-closed shape of a fetch whose sources have not seen the transactions (the dossier here is synthetic, so it must not pass).""" import asyncio import os from playwright.async_api import async_playwright HERE = os.path.dirname(os.path.abspath(__file__)) PROFILE = os.path.join(HERE, "chromium-profile") PAGE = "http://127.0.0.1:8080/?chains=blake&network=xbt" async def main(): dossier = open(os.path.join(HERE, "dossier.json")).read() async with async_playwright() as p: context = await p.chromium.launch_persistent_context( PROFILE, viewport={"width": 1280, "height": 1700}) page = context.pages[0] if context.pages else await context.new_page() page.on("console", lambda m: print("console:", m.text)) cdp = await context.new_cdp_session(page) await cdp.send("Network.clearBrowserCache") await page.goto(PAGE, wait_until="load", timeout=60000) card = page.locator("#cards .card").first await card.locator("input").nth(0).fill("wss://swaprelay.smesh.lol") await page.get_by_role("button", name="Connect").click() await page.wait_for_function( "document.getElementById('connect-status').textContent.includes('connected')", timeout=120000) await page.wait_for_function( "document.querySelectorAll('#indexers input').length > 0", timeout=60000) presets = await page.locator("#indexers").inner_text() print(presets[:600]) await page.screenshot(path=os.path.join(HERE, "02-presets.png"), full_page=True) await page.locator("#dossier").fill(dossier) await page.get_by_role("button", name="Fetch facts from the selected sources").click() await page.wait_for_timeout(8000) filled = await page.locator("#dossier").input_value() print("sources after fetch:", [s["name"] for s in __import__("json").loads(filled)["sources"]]) print("checked:", await page.evaluate( "Array.from(document.querySelectorAll('#indexers input')).filter(i => i.checked).length")) await page.get_by_role("button", name="Verify").click() await page.wait_for_function( "document.getElementById('verify-report').textContent.length > 0", timeout=60000) report = await page.locator("#verify-report").inner_text() print("report:", " | ".join(report.splitlines()[:4])) await page.screenshot(path=os.path.join(HERE, "03-fetch-fails-closed.png"), full_page=True) await context.close() asyncio.run(main())