fix(opportunities): disable 'Plan from X selected' on heterogeneous selection - #777
Conversation
…election (closes #769) Plans require a uniform provider/service/term/payment combination. Add isHomogeneousSelection() helper that checks all four axes; gate the "Plan from N selected" button on the result. The Purchase button is unaffected. The existing a11y hint span surfaces the explanation when the selection is heterogeneous. Eight new tests cover all four axes, the single-row pass-through, and the DOM-level button/hint state.
|
Warning Review limit reached
More reviews will be available in 13 minutes and 53 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)
📝 WalkthroughWalkthroughThis PR implements issue ChangesHeterogeneous Selection Gating for Plan Button
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/__tests__/recommendations.test.ts`:
- Around line 6426-6442: The test helper makeRec uses non-canonical underscore
payment tokens (overrides.payment defaulting to 'all_upfront' and elsewhere
'no_upfront'); update these defaults and any hardcoded test values in the new
homogeneity tests to use the canonical hyphenated tokens ('all-upfront' and
'no-upfront') so test fixtures match real app payloads—locate the makeRec
function and other occurrences around the referenced blocks (e.g., where
overrides.payment is set) and replace underscore variants with the hyphenated
tokens.
In `@frontend/src/recommendations.ts`:
- Around line 3159-3167: The heterogeneous-plan hint is currently gated by
existence (planBtn != null) which still holds when the plan button is hidden;
update the guard so heterogeneousPlanBlock uses visibility instead: check that
planBtn exists and is visible (e.g., planBtn && !planBtn.hidden) when computing
heterogeneousPlanBlock (alongside hasSelection and !planHomogeneous), so the
disabledHint text about plans only appears for users who can actually see/use
the plan button; leave the rest of the logic for disabledHint, disabledMessage,
and planHomogeneous unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f36239f3-07d6-43dd-b979-3eff7dee189d
📒 Files selected for processing (2)
frontend/src/__tests__/recommendations.test.tsfrontend/src/recommendations.ts
…an hint on button visibility Replace underscore payment tokens (`all_upfront`, `no_upfront`) with the canonical hyphenated form (`all-upfront`, `no-upfront`) in the `makeRec` test helper default and the heterogeneous-payment fixture so test payloads match real app payloads. Tighten the `heterogeneousPlanBlock` guard in recommendations.ts to `planBtn != null && !planBtn.hidden` so the heterogeneous-selection hint only surfaces when the plan button is actually visible (not merely present in the DOM for users who lack the `create:plans` permission).
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
QA 6.2: the "Plan from X selected" button was always clickable even when the selection spanned multiple providers / services / terms / payment options. A single plan can only represent one of each, so the modal couldn't actually act on heterogeneous selections.
Fix
isHomogeneousSelection(recs)helper that returnstruewhen all items share the sameprovider/service/term/payment.updateBottomActionBoxgates the plan button onhasSelection && planHomogeneous.Files changed
frontend/src/recommendations.tsfrontend/src/__tests__/recommendations.test.tsTest plan
isHomogeneousSelection: each of 4 axes individually, plus homogeneous, single-row, empty-slice.Closes #769.
Summary by CodeRabbit
Bug Fixes
Tests