Skip to content

test(e2e): cubrir el corazón del juego (trigger, game over, resume) - #28

Merged
finallyjay merged 1 commit into
mainfrom
test/roulette-core-e2e
Aug 4, 2026
Merged

test(e2e): cubrir el corazón del juego (trigger, game over, resume)#28
finallyjay merged 1 commit into
mainfrom
test/roulette-core-e2e

Conversation

@finallyjay

Copy link
Copy Markdown
Owner

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.ts con 4 escenarios:

  • HIT ("pull the trigger" con bala): sube la cuenta de 🪦 enterrados, el toast pasa a toast--kill ("Bang"), y la recámara encoge.
  • MISS (cámara vacía, esquiva): sube la cuenta de 📖 indultados, toast toast--miss ("Click"), recámara encoge.
  • Game over + restart: se siembra una partida en su último forajido con un veredicto pendiente en localStorage, se recarga para reanudar, y un disparo vacía la recámara → aparece "The dust settles" con los totales correctos y ddr_progress limpiado. El botón de reinicio reparte una baraja nueva completa (12).
  • Persistencia / resume: tras hacer spin y dejar un veredicto pendiente, se recarga la página y el standoff se reanuda desde localStorage (clave ddr_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 de spike/repro.mjs, se estuba Math.random a una constante, pero adaptado a Playwright con page.addInitScript, que instala el stub antes de que cargue el script del juego en cada navegación/recarga. Así tanto spin() como pullTrigger() son deterministas y los tests no son flaky, sin tocar el código de producción:

  • 0floor(0 * 6) === 0HIT
  • 0.5floor(0.5 * 6) === 3MISS

Resultado 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 webServer launcher de Playwright; se pre-arrancó el dev server manualmente (reuseExistingServer lo detecta) y se paró al terminar.

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
daily-dev-roulette Ready Ready Preview Aug 4, 2026 5:44pm

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 5 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ee6f4772-e286-4525-867c-de324f13e854

📥 Commits

Reviewing files that changed from the base of the PR and between e676201 and ebd5030.

📒 Files selected for processing (1)
  • tests/e2e/roulette-core.spec.ts

Comment @coderabbitai help to get the list of available commands.

@finallyjay
finallyjay merged commit 7c87ca3 into main Aug 4, 2026
7 checks passed
@finallyjay
finallyjay deleted the test/roulette-core-e2e branch August 4, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant