# Smoke-test the built Copenhagen snow globe: shake mechanics, drift growth, # persistence, theme switching, sweep. Also captures the 1200x630 preview.png. import http.server, threading, functools, sys, os, json DIST = os.path.abspath(sys.argv[1]) OUT = os.path.dirname(DIST) httpd = http.server.ThreadingHTTPServer(('127.0.0.1', 8766), functools.partial(http.server.SimpleHTTPRequestHandler, directory=DIST)) threading.Thread(target=httpd.serve_forever, daemon=True).start() from playwright.sync_api import sync_playwright errs, msgs = [], [] results = {} with sync_playwright() as p: b = p.chromium.launch( executable_path='/home/hermeswebui/.hermes/home/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome', args=['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage']) pg = b.new_page(viewport={'width': 1200, 'height': 630}) pg.on('pageerror', lambda e: errs.append(str(e))) pg.on('console', lambda m: msgs.append(f"{m.type}: {m.text}")) pg.goto('http://127.0.0.1:8766/', wait_until='networkidle') pg.wait_for_timeout(600) results['title'] = pg.title() results['has_canvas'] = pg.locator('#globe').count() == 1 results['badge'] = pg.evaluate("!!document.querySelector('advent-badge')") def shakes(): return int(pg.locator('#stat-shakes').text_content().split(':')[1].split()[0]) # Button shake. pg.click('#shake-btn'); pg.wait_for_timeout(200) results['shake_btn'] = shakes() == 1 # Space shake. pg.keyboard.press('Space'); pg.wait_for_timeout(200) results['shake_space'] = shakes() == 2 # Drag-shake: fast left-right reversals over the canvas. box = pg.locator('#globe').bounding_box() cx, cy = box['x'] + box['width']/2, box['y'] + box['height']/2 pg.mouse.move(cx, cy); pg.mouse.down() for i in range(6): pg.mouse.move(cx + (80 if i % 2 else -80), cy, steps=4) pg.mouse.up(); pg.wait_for_timeout(200) results['shake_drag'] = shakes() >= 3 # Drift grows as snow falls. def drift_cm(): return float(pg.locator('#stat-drift').text_content().split(':')[1].strip().split()[0]) d0 = drift_cm() pg.wait_for_timeout(12000) d1 = drift_cm() results['drift_grows'] = d1 > d0 results['drift_before'] = d0 results['drift_after'] = d1 # Click on the drift area = puff, no errors. pg.mouse.click(cx, cy + box['height']*0.28); pg.wait_for_timeout(300) # Theme switch. pg.click('button[data-theme="night"]'); pg.wait_for_timeout(300) results['theme_night_active'] = pg.evaluate( "document.querySelector('button[data-theme=\"night\"]').classList.contains('active')") # Density slider to max. pg.locator('#density').fill('4') pg.locator('#density').dispatch_event('input') pg.wait_for_timeout(1500) results['flakes_text'] = pg.locator('#stat-flakes').text_content() # Persistence: reload keeps shakes + theme. sh = shakes() pg.reload(wait_until='networkidle'); pg.wait_for_timeout(600) results['persist_shakes'] = shakes() == sh results['persist_theme'] = pg.evaluate( "document.querySelector('button[data-theme=\"night\"]').classList.contains('active')") results['persist_drift'] = drift_cm() > 0 # Sweep resets drift. pg.click('#sweep-btn'); pg.wait_for_timeout(400) results['sweep'] = drift_cm() < 0.15 # Preview screenshot: shrink stage so the whole app fits 1200x630. pg.evaluate("""() => { document.querySelector('#stage').style.maxWidth = '430px'; window.dispatchEvent(new Event('resize')); document.body.style.paddingTop = '0.2rem'; }""") pg.wait_for_timeout(1200) pg.screenshot(path=os.path.join(OUT, 'preview_shot.png')) # Also a full-size dusk shot for my own visual check. pg.evaluate("""() => { document.querySelector('#stage').style.maxWidth = ''; window.dispatchEvent(new Event('resize')); document.querySelector('button[data-theme=\"dusk\"]').click(); }""") pg.set_viewport_size({'width': 800, 'height': 1000}) pg.wait_for_timeout(1500) pg.screenshot(path=os.path.join(OUT, 'check_full.png'), full_page=True) results['pageerrors'] = errs results['console_errors'] = [m for m in msgs if m.startswith('error')] b.close() httpd.shutdown() print(json.dumps(results, indent=2))