diff --git a/components/DieD16.test.tsx b/components/DieD16.test.tsx index 794b38b..96f9460 100644 --- a/components/DieD16.test.tsx +++ b/components/DieD16.test.tsx @@ -174,6 +174,14 @@ describe("DieD16 — tamaño, interacción y accesibilidad", () => { expect(onRoll).toHaveBeenCalledTimes(1); }); + // T34: los call sites fijan nombres exactos («Tirar 1D16») — pin de accesibilidad preservado. + it("rollLabel pone el texto EXACTO del botón de tirar", () => { + const onRoll = vi.fn(); + render(); + fireEvent.click(screen.getByRole("button", { name: "Tirar 1D16" })); + expect(onRoll).toHaveBeenCalledTimes(1); + }); + it("el botón queda deshabilitado mientras rolling", () => { render( {}} />); const btn = must(screen.getByRole("button", { name: "Tirar" }) as HTMLButtonElement | null); diff --git a/components/DieD16.tsx b/components/DieD16.tsx index 73fb3db..f1c86e7 100644 --- a/components/DieD16.tsx +++ b/components/DieD16.tsx @@ -50,6 +50,9 @@ export interface DieD16Props { label?: string; /** Spanish result text; defaults to «Resultado: n». */ resultText?: (n: number) => string; + /** Spanish roll-button label; defaults to «Tirar». T34: migrated call sites + * pin exact button names («Tirar 1D6»…) — this text renders verbatim. */ + rollLabel?: string; } /** Scaled jico skew (L112 judgment call kept: -8/12 vs the d6's -16/24). */ @@ -105,6 +108,7 @@ export function DieD16({ size = 120, label = "Dado 1D16", resultText = (n) => `Resultado: ${n}`, + rollLabel = "Tirar", }: DieD16Props) { const [roll, setRoll] = useState(() => ({ prev: value, @@ -200,7 +204,7 @@ export function DieD16({

{onRoll && ( )} diff --git a/components/DieD6.test.tsx b/components/DieD6.test.tsx index 2c52fbb..cb851d3 100644 --- a/components/DieD6.test.tsx +++ b/components/DieD6.test.tsx @@ -178,6 +178,14 @@ describe("DieD6 — tamaño, interacción y accesibilidad", () => { expect(onRoll).toHaveBeenCalledTimes(1); }); + // T34: los call sites fijan nombres exactos («Tirar 1D6») — pin de accesibilidad preservado. + it("rollLabel pone el texto EXACTO del botón de tirar", () => { + const onRoll = vi.fn(); + render(); + fireEvent.click(screen.getByRole("button", { name: "Tirar 1D6" })); + expect(onRoll).toHaveBeenCalledTimes(1); + }); + it("el botón queda deshabilitado mientras rolling", () => { render( {}} />); const btn = must(screen.getByRole("button", { name: "Tirar" }) as HTMLButtonElement | null); diff --git a/components/DieD6.tsx b/components/DieD6.tsx index 0315e20..0e655d0 100644 --- a/components/DieD6.tsx +++ b/components/DieD6.tsx @@ -48,6 +48,9 @@ export interface DieD6Props { label?: string; /** Spanish result text; defaults to «Resultado: n». */ resultText?: (n: number) => string; + /** Spanish roll-button label; defaults to «Tirar». T34: migrated call sites + * pin exact button names («Tirar 1D6»…) — this text renders verbatim. */ + rollLabel?: string; } /** Jico skewed landing (approved v3): never face-on. */ @@ -112,6 +115,7 @@ export function DieD6({ size = 120, label = "Dado 1D6", resultText = (n) => `Resultado: ${n}`, + rollLabel = "Tirar", }: DieD6Props) { const [roll, setRoll] = useState(() => ({ prev: value, @@ -202,7 +206,7 @@ export function DieD6({

{onRoll && ( )} diff --git a/features/leagues/actaKickoffGate.test.tsx b/features/leagues/actaKickoffGate.test.tsx index 557c994..cd0c13b 100644 --- a/features/leagues/actaKickoffGate.test.tsx +++ b/features/leagues/actaKickoffGate.test.tsx @@ -331,3 +331,15 @@ describe("U12 · L32 — manual or automatic 2D6, per-coach duel, optional skip" ).toBeNull(); }); }); + +describe("ActaKickoffGate — T34 · migración del dado del duelo a DieD6", () => { + // WHY (T34, L121): the duel dice (one 1D6 per coach) migrate to the shared + // DieD6 (highlight default "none") keeping their pinned button names via + // the component's rollLabel prop. + + it("los dos dados 1D6 del duelo se renderizan con el componente DieD6 (TÚ y RIVAL)", () => { + gate({ d1: 1, d2: 5, followUp: { home: null, away: null } }); + expect(screen.getByRole("img", { name: /Dado 1D6 · TÚ/ })).toBeTruthy(); + expect(screen.getByRole("img", { name: /Dado 1D6 · RIVAL/ })).toBeTruthy(); + }); +}); diff --git a/features/leagues/actaKickoffGate.tsx b/features/leagues/actaKickoffGate.tsx index e0d845e..631d724 100644 --- a/features/leagues/actaKickoffGate.tsx +++ b/features/leagues/actaKickoffGate.tsx @@ -1,5 +1,7 @@ import { useState } from "react"; +import { DieD6 } from "@/components/DieD6"; + import { KICKOFF_EVENTS, KICKOFF_FREE_RECEPTION_QUOTE, @@ -63,7 +65,10 @@ export interface ActaKickoffGateProps { onSkipDuel: () => void; } -/** Editorial die card (the wizard's DieCard pattern): face + dice BUTTON. */ +/** Editorial die card (the wizard's DieCard pattern): face + dice BUTTON. + * T34 (L121): the face is the shared DieD6 (highlight default "none"); its + * roll button carries the pinned «Tirar 1D6 · TÚ/RIVAL» names via rollLabel + * and the trigger is withheld once recorded (U12's one-shot roll). */ function GateDie({ label, value, @@ -84,27 +89,22 @@ function GateDie({

{label}

- - {value ?? "–"} - - + {/* Controlled wiring (T34): the RNG/state stay with the gate and feed + `value`; no trigger after the recorded throw (the die locks). */} + { + setRollSeq((seq) => seq + 1); + onRoll(); + } + } + /> { + // WHY (T34, L121): the die FACE visuals migrate to the shared controlled + // components (PR #423) with highlight defaulting to "none". Per-site pins: + // the component must render with the RIGHT sides (1D6 -> DieD6, 1D16 -> + // DieD16). The Los Hinchas 1D3 glyph is deliberately NOT migrated (a DieD6 + // would show 6 pips for a 1D3 result — out of coverage, kept as-is). + + it("el paso El Clima muestra la tirada 1D6 con el componente DieD6", () => { + const snapshot = emptySnapshot(); + snapshot.fans.home = { base: 4, dice: 1, total: 5 }; + renderWizard({ snapshot }); + expect(screen.getByRole("img", { name: "Dado 1D6" })).toBeTruthy(); + expect(screen.getByRole("button", { name: "Tirar 1D6" })).toBeTruthy(); + }); + + it("el paso Equipo pateador muestra la tirada 1D6 con el componente DieD6", () => { + renderWizard({ snapshot: readySnapshot() }); + expect(screen.getByRole("img", { name: "Dado 1D6" })).toBeTruthy(); + expect(screen.getByRole("button", { name: "Tirar 1D6" })).toBeTruthy(); + }); + + it("el resultado ACEPTADO de una plegaria se muestra con el componente DieD16", () => { + renderWizard({ snapshot: prayersSnapshot(1) }); + const card = within(step(4, "Plegarias a Nuffle")).getByRole("group", { + name: `Plegaria 1 de 1 · ${HOME}`, + }); + fireEvent.change(within(card).getByRole("spinbutton"), { + target: { value: "8" }, + }); + fireEvent.click(within(card).getByRole("button", { name: "Aceptar" })); + expect(within(card).getByRole("img", { name: /Dado 1D16/ })).toBeTruthy(); + // The prayer step keeps its manual contract: NO die roll button here. + expect(screen.queryByRole("button", { name: "Tirar 1D16" })).toBeNull(); + }); + + it("TRIANGULA · el paso Los Hinchas (1D3) conserva el glyph plano — fuera de cobertura", () => { + // WHY (T34 boundary): DieD6 shows 6 pips — a 1D3 result on that cube + // would lie about the roll. The 1D3 site is deliberately NOT migrated. + renderWizard(); + expect(screen.getByTestId("die-glyph")).toBeTruthy(); + expect(screen.queryByRole("img", { name: "Dado 1D6" })).toBeNull(); + expect(screen.getByRole("button", { name: "Tirar 1D3" })).toBeTruthy(); + }); + + it("TRIANGULA · tras registrar en un sitio migrado NO queda dispara de re-tirada (lock S7)", () => { + // WHY (T34 contract): on migrated sites the DieD6 trigger is withheld + // once recorded (the component renders its button only with onRoll) — + // «una vez tirado los dados, ya no se puede volver a tirar» (S7.6). + const snapshot = emptySnapshot(); + snapshot.fans.home = { base: 4, dice: 1, total: 5 }; + const { onCommit } = renderWizard({ snapshot }); + fireEvent.click(screen.getByRole("button", { name: "Tirar 1D6" })); + expect(onCommit).toHaveBeenCalledTimes(1); + expect(screen.queryByRole("button", { name: "Tirar 1D6" })).toBeNull(); + expect(step(2, "El Clima").textContent).toMatch(/Registrado/); + }); +}); diff --git a/features/leagues/actaPreMatchWizard.tsx b/features/leagues/actaPreMatchWizard.tsx index a8ea081..f2febfd 100644 --- a/features/leagues/actaPreMatchWizard.tsx +++ b/features/leagues/actaPreMatchWizard.tsx @@ -1,5 +1,7 @@ import { Fragment, useState, type ReactNode } from "react"; +import { DieD6 } from "@/components/DieD6"; +import { DieD16 } from "@/components/DieD16"; import { rollD3, rollD6, rollD16 } from "@/lib/random"; import { displayNameOf, @@ -233,11 +235,18 @@ function WeatherTable({ sum }: { sum: number | null }) { /** Editorial die card: face + dice BUTTON (roll records directly) with the * roll animation — LOCKED once recorded: a finished roll never re-rolls (the - * only re-roll path is the kick tie's «Repetir tirada»). */ + * only re-roll path is the kick tie's «Repetir tirada»). + * + * T34 (L121): the die FACE visual migrates to the shared controlled + * components (PR #423), highlight at its default "none". `sides` decides: + * 6 renders the shared DieD6 (its own roll button carries the pinned + * «Tirar 1D6» name via rollLabel); 3 KEEPS the flat glyph — a DieD6 would + * show 6 pips for a 1D3 result (out of component coverage, kept as-is). */ function DieCard({ teamLabel, value, dieLabel, + sides, recorded, onRoll, totalLine, @@ -246,6 +255,8 @@ function DieCard({ teamLabel: string; value: number | null; dieLabel: string; + /** Roll shape: 3 = flat glyph (kept), 6 = shared DieD6 (T34). */ + sides: 3 | 6; recorded: boolean; onRoll: () => void; totalLine: ReactNode; @@ -259,27 +270,49 @@ function DieCard({ {teamLabel}

- - + {sides === 6 ? ( + /* Controlled wiring (T34): the RNG/state stay here and feed the die + * `value`; the roll trigger is withheld once recorded so the S7 lock + * («una vez tirado los dados, ya no se puede volver a tirar») holds + * — no dead re-roll button is offered. */ + { + setRollSeq((seq) => seq + 1); + onRoll(); + } + } + /> + ) : ( + <> + + + + )}
{accepted ? ( - + /* T34 (L121): the recorded 1D16 face is the shared DieD16, + * display-only — the manual entry above already committed the roll + * (no die button rides this step, per T29/L95). */ + ) : ( <> { const value = dice.d3(); @@ -966,6 +997,7 @@ export function ActaPreMatchWizard({ teamLabel={`Tu tirada · ${nameOf(viewerSide)}`} value={shownWeather} dieLabel="Tirar 1D6" + sides={6} recorded={recordedWeather} onRoll={() => { const value = dice.d6(); @@ -1297,6 +1329,7 @@ export function ActaPreMatchWizard({ teamLabel={`Tu tirada · ${nameOf(viewerSide)}`} value={shownKick} dieLabel="Tirar 1D6" + sides={6} recorded={recordedKick} onRoll={() => { const value = dice.d6();