Skip to content

fix(plans/add-purchases): inline 1-52 range validation on Number of Purchases - #776

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/771-add-purchases-range-validation
May 28, 2026
Merged

cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/771-add-purchases-range-validation

Conversation

@cristim

@cristim cristim commented May 27, 2026

Copy link
Copy Markdown
Member

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

  • Exported openAddPurchasesModal, called wireRangeInput('add-purchases-count', 1, 52) after the modal DOM is built.
  • Added submit-button disable/re-enable listener keyed on aria-invalid.
  • Replaced parseInt with Number() + Number.isInteger() save-time guard (per feedback_strict_int_parse memory).

Files changed

  • frontend/src/plans.ts
  • frontend/src/__tests__/plans-range-validation.test.ts

Test plan

  • 13 new tests: below-range (0), above-range (53), boundary values (1/26/52), fraction (2.5), button-disabled toggling, aria attributes, save-time block.
  • 42 / 42 tests pass (29 pre-existing + 13 new).
  • Manual: open Add Purchases, type 0 / 53 / 2.5 -> inline error, Save disabled; type 26 -> Save enabled.

Closes #771.

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.
@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/this-sprint Within the current sprint impact/many Affects most users effort/xs Trivial / one-liner type/bug Defect labels May 27, 2026
@coderabbitai

coderabbitai Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@cristim, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 42ca9fea-3bbb-42a8-b65c-38e28aba3863

📥 Commits

Reviewing files that changed from the base of the PR and between d986b4d and 12a4a84.

📒 Files selected for processing (2)
  • frontend/src/__tests__/plans-range-validation.test.ts
  • frontend/src/plans.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/771-add-purchases-range-validation

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

@cristim

cristim commented May 27, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented May 28, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

@cristim
cristim merged commit ba708e3 into feat/multicloud-web-frontend May 28, 2026
5 of 6 checks passed
@cristim
cristim deleted the fix/771-add-purchases-range-validation branch June 3, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner impact/many Affects most users priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant