()
| 250 | |
| 251 | |
| 252 | def record() -> None: |
| 253 | try: |
| 254 | from playwright.sync_api import sync_playwright |
| 255 | except ImportError: |
| 256 | sys.exit( |
| 257 | "[record_demo] ERROR: playwright not installed.\n" |
| 258 | " pip install playwright && playwright install chromium" |
| 259 | ) |
| 260 | |
| 261 | with sync_playwright() as p: |
| 262 | browser = p.chromium.launch(headless=True) |
| 263 | context = browser.new_context( |
| 264 | viewport={"width": 1280, "height": 720}, |
| 265 | record_video_dir=str(OUT_DIR), |
| 266 | record_video_size={"width": 1280, "height": 720}, |
| 267 | ) |
| 268 | page = context.new_page() |
| 269 | |
| 270 | # ------------------------------------------------------------------ |
| 271 | # Scene 1 (4s) — landing page, empty state, suggestion chips visible |
| 272 | # ------------------------------------------------------------------ |
| 273 | log("Scene 1: landing page...") |
| 274 | page.goto(BASE_URL) |
| 275 | page.wait_for_load_state("networkidle") |
| 276 | time.sleep(4) |
| 277 | page.screenshot(path=str(SS_DIR / "01-landing.png")) |
| 278 | log("Screenshot: 01-landing.png") |
| 279 | |
| 280 | # ------------------------------------------------------------------ |
| 281 | # Scene 2 (3s) — fill input to show "about to investigate" state |
| 282 | # ------------------------------------------------------------------ |
| 283 | log("Scene 2: filling input...") |
| 284 | _set_state(page, f"data.input = 'Investigate {_EMAIL}';") |
| 285 | time.sleep(2) |
| 286 | page.screenshot(path=str(SS_DIR / "02-input.png")) |
| 287 | log("Screenshot: 02-input.png") |
| 288 | time.sleep(1) |
| 289 | |
| 290 | # ------------------------------------------------------------------ |
| 291 | # Scene 3 (~6s) — animated investigation in 4 stages |
| 292 | # ------------------------------------------------------------------ |
| 293 | log("Scene 3: running animated investigation...") |
| 294 | _inject_investigation(page) |
| 295 | page.screenshot(path=str(SS_DIR / "03-investigation.png")) |
| 296 | log("Screenshot: 03-investigation.png") |
| 297 | |
| 298 | # ------------------------------------------------------------------ |
| 299 | # Scene 4 (3s) — scroll to top then back to show full conversation |
| 300 | # ------------------------------------------------------------------ |
| 301 | log("Scene 4: scrolling conversation...") |
| 302 | page.evaluate("document.getElementById('chat-area').scrollTo(0, 0)") |
| 303 | time.sleep(1) |
| 304 | page.evaluate( |
| 305 | "document.getElementById('chat-area').scrollTo(0, " |
| 306 | "document.getElementById('chat-area').scrollHeight)" |
| 307 | ) |
| 308 | time.sleep(2) |
| 309 |
no test coverage detected