fix(aluno): finish-button hint + duration clamp (v2, rebased on #182)#184
Conversation
CardTreino footer ganha <p> condicional data-testid finish-hint quando completedCount === 0 e sem feedback loading. Sinaliza pre-condicao (marque exercicios) para o botao Finalizar e Avaliar Treino que parecia morto quando disabled. Test: stateful mock useWorkoutTracker para toggle. 15/15 card-treino, 1134/1134 suite. Co-Authored-By: Claude <noreply@anthropic.com>
HistoricoTreinoBaseSchema requires duracaoMinutos >= 1. Quick workouts (<30s) rounded to 0, failing save and surfacing "ocorreu um erro inesperado ao salvar no histórico" toast. Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 21 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: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR. |
There was a problem hiding this comment.
3 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/components/WorkoutSession.tsx">
<violation number="1" location="src/components/WorkoutSession.tsx:173">
P2: Custom agent: **Enforce Pragmatic Test Coverage**
This business-logic fix clamps workout duration to at least 1 minute to prevent a Zod schema failure on very short sessions, but the edge case isn't covered by tests. If the clamp is accidentally removed or altered, the failure path (duration of 0 causing a validation toast) would regress silently. Consider adding a test that mocks time so the workout ends in under a minute, then asserts that `onFinish` is called with `duracaoMinutos >= 1`.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| setIsFinishing(true); | ||
| const endTime = new Date(); | ||
| const duracaoMinutos = Math.round((endTime.getTime() - startTime.getTime()) / 60000); | ||
| const duracaoMinutos = Math.max( |
There was a problem hiding this comment.
P2: Custom agent: Enforce Pragmatic Test Coverage
This business-logic fix clamps workout duration to at least 1 minute to prevent a Zod schema failure on very short sessions, but the edge case isn't covered by tests. If the clamp is accidentally removed or altered, the failure path (duration of 0 causing a validation toast) would regress silently. Consider adding a test that mocks time so the workout ends in under a minute, then asserts that onFinish is called with duracaoMinutos >= 1.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/components/WorkoutSession.tsx, line 173:
<comment>This business-logic fix clamps workout duration to at least 1 minute to prevent a Zod schema failure on very short sessions, but the edge case isn't covered by tests. If the clamp is accidentally removed or altered, the failure path (duration of 0 causing a validation toast) would regress silently. Consider adding a test that mocks time so the workout ends in under a minute, then asserts that `onFinish` is called with `duracaoMinutos >= 1`.</comment>
<file context>
@@ -170,7 +170,10 @@ export function WorkoutSession({ treino, onFinish, onCancel }: Readonly<WorkoutS
setIsFinishing(true);
const endTime = new Date();
- const duracaoMinutos = Math.round((endTime.getTime() - startTime.getTime()) / 60000);
+ const duracaoMinutos = Math.max(
+ 1,
+ Math.round((endTime.getTime() - startTime.getTime()) / 60000)
</file context>
- card-treino.tsx: finish-hint gains aria-live="polite" so AT announces
reappearance when user unchecks last completed exercise.
- WorkoutSession.test.tsx: new test asserting onFinish receives
duracaoMinutos >= 1 even on sub-minute session (regression guard for
the Math.max(1, ...) clamp).
- card-treino.test.tsx: simplify "hides finish hint" test per cubic —
set mockReturnValue directly to { 'ex-1': true } + rerender; drop
mutable let, callback re-mock, fireEvent.click, silent no-op path.
Co-Authored-By: Claude <noreply@anthropic.com>
|
ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR. |
|



Summary
Two small aluno-side bug fixes bundled (v2 — rebased fresh on
mainafter PR #182 merge; old PR #183 hadWorkoutSession.tsxconflicts).1. Dead finish-button UX —
card-treino.tsxButton "Finalizar e Avaliar Treino" disabled silently when
completedCount === 0. No visual precondition feedback → users perceive dead button. Added conditional hint below button:3 new unit tests (hint visible, hint hides on check, stateful
useWorkoutTrackermock withmockReturnValueoverride +rerender).2. Toast "inesperado ao salvar no histórico" —
WorkoutSession.tsx:173Zod schema
HistoricoTreinoBaseSchemarequiresduracaoMinutos: z.coerce.number().int().min(1). Quick workout (<30s) →Math.round((end - start) / 60000)returns0→ schema fail → toast. Defensive clamp:Re-applied on top of #182's mobile fullscreen rewrite (no conflict).
Gates
Supersedes #183.
🤖 Generated with Claude Code
Summary by cubic
Adds a visible hint when the finish button is disabled and clamps workout duration to at least 1 minute to prevent save errors and confusing toasts. Improves the aluno workout flow and announces the hint to screen readers when it reappears.
aria-live="polite"so the hint is announced when it reappears.duracaoMinutosto a minimum of 1 to satisfy the Zod schema and prevent the "inesperado ao salvar no histórico" toast on sub-minute sessions.Written for commit 265de6c. Summary will update on new commits.