fix(plans/add-purchases): inline 1-52 range validation on Number of Purchases - #776
Conversation
Add wireRangeInput('add-purchases-count', 1, 52) in openAddPurchasesModal
so the Number of Purchases field shows a "Must be a whole number between
1 and 52" error inline as the user types, instead of only at save time.
The submit button is also disabled while the field is aria-invalid.
Harden the save-time guard in handleAddPurchases to use Number() +
Number.isInteger() instead of parseInt, so a fractional value like 2.5
is rejected before reaching the API (feedback_strict_int_parse).
Export openAddPurchasesModal for test access and add 13 new cases in
plans-range-validation.test.ts covering below-range (0), above-range
(53), boundary values (1/26/52), fractions (2.5), button-disabled
toggling, a11y attributes, and the save-time guard.
Mirrors the wireRangeInput pattern from #702/#714 across the codebase.
|
Warning Review limit reached
More reviews will be available in 59 minutes and 55 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
Summary
Plans 5.4: the "Number of Purchases" field in the Add Purchases modal accepted out-of-range values (1-52) and only surfaced the error on Save. Other range-validated fields (see #702 / PR #714) validate inline at type-time. Mirror that pattern.
Fix
openAddPurchasesModal, calledwireRangeInput('add-purchases-count', 1, 52)after the modal DOM is built.aria-invalid.parseIntwithNumber()+Number.isInteger()save-time guard (perfeedback_strict_int_parsememory).Files changed
frontend/src/plans.tsfrontend/src/__tests__/plans-range-validation.test.tsTest plan
Closes #771.