test(e2e): cubrir el corazón del juego (trigger, game over, resume) - #28
Conversation
Promote the manual spike/repro.mjs standoff checks into real Playwright tests. Determinism comes from stubbing Math.random via addInitScript (installed before the game script runs, so both spin and pullTrigger are deterministic) without touching production code: 0 -> HIT (floor(0 * 6) === 0) 0.5 -> MISS (floor(0.5 * 6) === 3) New scenarios: - HIT: buried tally rises, chamber shrinks - MISS: dodged, pardoned tally rises - game over on emptying the chamber, plus restart dealing a fresh pile - persistence: reloading with a pending verdict resumes the standoff via localStorage (ddr_progress) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 5 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Comment |
Qué cubre lo nuevo
Los 5 tests e2e previos cubrían home/hub y el camino feliz del demo (carga, spin→veredicto, spare), pero no el corazón del producto. Este PR añade
tests/e2e/roulette-core.spec.tscon 4 escenarios:toast--kill("Bang"), y la recámara encoge.toast--miss("Click"), recámara encoge.localStorage, se recarga para reanudar, y un disparo vacía la recámara → aparece "The dust settles" con los totales correctos yddr_progresslimpiado. El botón de reinicio reparte una baraja nueva completa (12).localStorage(claveddr_progress) en vez de volver a girar.Esto promueve la lógica del script manual
spike/repro.mjs(que no corría en CI) a tests reales de Playwright.Cómo se logra el determinismo
El disparo depende de
Math.floor(Math.random() * 6) === 0. Siguiendo el enfoque despike/repro.mjs, se estubaMath.randoma una constante, pero adaptado a Playwright conpage.addInitScript, que instala el stub antes de que cargue el script del juego en cada navegación/recarga. Así tantospin()comopullTrigger()son deterministas y los tests no son flaky, sin tocar el código de producción:0→floor(0 * 6) === 0→ HIT0.5→floor(0.5 * 6) === 3→ MISSResultado de los tests
npm test(Playwright, chromium): 9/9 pasan (5 previos + 4 nuevos), ~7.3s.Nota de entorno: Astro 7 daemoniza el dev server cuando stdout está pipeado, lo que rompe el
webServerlauncher de Playwright; se pre-arrancó el dev server manualmente (reuseExistingServerlo detecta) y se paró al terminar.🤖 Generated with Claude Code