Skip to content

test(recommendations): assert action-box financial range (closes #281) - #799

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/281-wave2
Jun 8, 2026
Merged

cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/281-wave2

Conversation

@cristim

@cristim cristim commented May 28, 2026

Copy link
Copy Markdown
Member

Summary

Adds two regression tests in frontend/src/__tests__/recommendations.test.ts that pin the action-box summary's min/max range behaviour:

  1. Multi-cell selection with a per-cell range: 2 cells, one with two term variants (1yr + 3yr), one single-variant. Asserts the summary renders $300 - $500/mo, $1,100 - $1,800 upfront, 2 cells.
  2. Multi-cell selection with identical totals: when all per-cell sums collapse to the same min and max, formatSavingsRange returns a single value without the – separator. Asserts $400/mo and no – $400 substring.

Why no production change

The action-box render at frontend/src/recommendations.ts:3015-3023 already uses formatSavingsRange(min, max), which is exactly what the issue asks for. The "shows a single value instead of a range" symptom in the issue body predated the broader pageLevelRange + formatSavingsRange work that landed via the multi-cell-selection refactor. This PR just adds the missing test coverage so the range contract can't regress silently.

Locale note

formatCurrency calls toLocaleString(undefined, ...) which in Node/JSDOM may emit $1100 (no thousands separator) instead of $1,100. The regex makes the comma optional to stay robust across runtimes.

Test plan

  • npx jest src/__tests__/recommendations.test.ts -t '#281' — both new tests pass
  • Full npx jest src/__tests__/recommendations.test.ts no regressions

Closes #281

The production code in `recommendations.ts:3015-3023` already renders the
action-box summary as a min/max range via `formatSavingsRange(min, max)`,
which collapses to a single value when min == max. This PR adds the
regression tests that pin that behaviour for two cases the previous test
suite did not cover:

- Multi-cell selection with a per-cell range: 2 cells, one with two term
  variants (1yr/3yr), one single-variant. Asserts the summary shows
  `$300 - $500/mo`, `$1,100 - $1,800 upfront`, `2 cells`.
- Multi-cell selection with identical totals: collapses to `$400/mo`
  without a range separator (per formatSavingsRange's same-value branch).

Closes #281. No production changes -- the range render already shipped via
the broader pageLevelRange + formatSavingsRange work; this PR just stops
that contract from regressing silently.
@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/few Limited audience effort/s Hours type/feat New capability labels May 28, 2026
@coderabbitai

coderabbitai Bot commented May 28, 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 29 minutes and 40 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: db65166d-c50b-4dc6-963b-5764c18e55f1

📥 Commits

Reviewing files that changed from the base of the PR and between 4956d66 and 732eafb.

📒 Files selected for processing (1)
  • frontend/src/__tests__/recommendations.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/281-wave2

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

@cristim

cristim commented May 28, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 28, 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 30, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

@cristim

cristim commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 36 minutes and 52 seconds before sending another message.

cristim commented Jun 7, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Jun 7, 2026 •

Copy link
Copy Markdown
Contributor

@cristim: Triggering a full review of the PR now.


🧠 Learnings used
Learnt from: cristim
Repo: LeanerCloud/CUDly PR: 0
File: :0-0
Timestamp: 2026-05-05T15:44:54.463Z
Learning: In the LeanerCloud/CUDly repository, when a CodeRabbit review flags something as "outside-diff" that was already implemented in an earlier commit of the same PR, it is likely a stale-snapshot artifact where the review diff was generated against a pre-fix view. The inline comment convention `(CR pass on PR #<number> Finding N)` is used by the maintainer (cristim) to mark lines that were changed in direct response to a prior CodeRabbit review pass.

Learnt from: cristim
Repo: LeanerCloud/CUDly PR: 277
File: frontend/src/__tests__/recommendations.test.ts:2472-2476
Timestamp: 2026-05-05T07:46:01.902Z
Learning: In the CUDly frontend (`frontend/src/recommendations.ts`), `effectiveSavingsPct` intentionally has NO plausibility guard (no null return or warning for reconstructed percentages above per-term ceilings). The maintainer explicitly rejected that approach in PR `#277`. The fix for inflated percentages (issue `#274`) is purely a data-path fix: plumbing the provider's canonical `on_demand_cost` through to the frontend so the denominator is not reconstructed from potentially misleading `monthly_cost + savings + amortized`. Tests that pin the reconstructed >80% behavior are intentional documentation of the pre-fix path, not bugs.
✅ Action performed

Full review finished.

@cristim

cristim commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@cristim
cristim merged commit dddff5a into feat/multicloud-web-frontend Jun 8, 2026
5 checks passed
@cristim
cristim deleted the fix/281-wave2 branch June 8, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/few Limited audience priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/feat New capability urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant