Spaces:
Sleeping
Sleeping
| """Repro the user's complaints about logging back in: | |
| 1. "Attempting to log back in does not work with creds from an existing profile." | |
| → in practice it just takes a while with no UI indication. | |
| 2. After login, the empty-deck banner ("You've gone through what we have for now.") | |
| can flash up before the recs query has populated. | |
| Drives the live site through a real Playwright login flow and dumps a timeline. | |
| """ | |
| from __future__ import annotations | |
| import os | |
| import sys | |
| import time | |
| BASE = os.environ.get("KINK_AUDIT_BASE_URL", "https://perplexed7675-kink-discovery.hf.space") | |
| USER_ID = os.environ.get("REPRO_USER_ID", "real-bunny-72") | |
| TOKEN = os.environ.get("REPRO_TOKEN", "pet-amoeba") | |
| def main() -> int: | |
| from playwright.sync_api import sync_playwright | |
| print(f"== login repro ==", flush=True) | |
| print(f"base_url: {BASE}") | |
| print(f"user_id: {USER_ID}", flush=True) | |
| with sync_playwright() as p: | |
| browser = p.chromium.launch() | |
| ctx = browser.new_context(viewport={"width": 900, "height": 1400}) | |
| page = ctx.new_page() | |
| timeline: list[tuple[float, str]] = [] | |
| t0 = time.monotonic() | |
| def log(label: str) -> None: | |
| timeline.append((time.monotonic() - t0, label)) | |
| print(f" [{timeline[-1][0]:>5.1f}s] {label}", flush=True) | |
| page.goto(BASE, wait_until="domcontentloaded") | |
| log("page loaded") | |
| page.wait_for_selector('[data-testid="onboarding-have-profile"]', timeout=20_000) | |
| page.click('[data-testid="onboarding-have-profile"]') | |
| log("clicked 'I have a profile'") | |
| page.fill('[data-testid="onboarding-login-user-id"]', USER_ID) | |
| page.fill('[data-testid="onboarding-login-private-token"]', TOKEN) | |
| log("filled credentials") | |
| page.click('[data-testid="onboarding-open-profile"]') | |
| log("clicked 'Open profile'") | |
| # Snapshot every 250ms; capture FULL visible body text + take screenshot | |
| import os | |
| out_dir = "/tmp/login_repro_ticks" | |
| os.makedirs(out_dir, exist_ok=True) | |
| for tick in range(20): | |
| page.wait_for_timeout(250) | |
| body_text = page.evaluate( | |
| r"""() => (document.body.innerText || '').trim().split(/\n/).filter(s => s.trim()).slice(0, 8).join(' | ')""" | |
| ) | |
| log(f"tick{tick}: body={body_text!r}") | |
| page.screenshot(path=f"{out_dir}/tick{tick:02d}.png", full_page=False) | |
| if page.evaluate("() => Boolean(document.querySelector('.card-title'))"): | |
| break | |
| page.screenshot(path="/tmp/login_repro_final.png", full_page=True) | |
| log("screenshot at /tmp/login_repro_final.png") | |
| browser.close() | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |