Fixed retention offer preview not basing prices off actual tier#26786
Fixed retention offer preview not basing prices off actual tier#26786
Conversation
WalkthroughBumps app version from 2.66.2 to 2.66.3. Adds 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/portal/test/app.test.js (1)
140-174: Add a monthly-cadence case too.This fixture already starts as a yearly subscription, so this test only proves the
yearbranch. A second case withcadence=monthwould better protect against stale yearly fields leaking into monthly retention previews.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/portal/test/app.test.js` around lines 140 - 174, Add a second test case that mirrors the existing "uses the selected tier price for retention offer preview members" test but sets cadence=month in the query string; construct a monthlyPrice (getPriceData with interval: 'month') and ensure paidProduct includes both monthlyPrice and yearlyPrice, call app.fetchOfferQueryStrData with cadence=month and tier_id set to paidProduct.id, then assert subscription.price.amount equals monthlyPrice.amount, subscription.price.interval is 'month', subscription.price.price_id equals monthlyPrice.id, and subscription.tier matches the paidProduct id/name to ensure the monthly branch is covered (refer to the existing test name, App.fetchOfferQueryStrData and app.getContextFromState).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/portal/src/app.js`:
- Around line 984-989: The price calculation currently treats any non-'year'
cadence as monthly which can diverge from live behavior; update the logic around
retentionOffer.cadence (the const price assignment and its use before returning
previewMember/previewSubscription) to explicitly handle supported values: if
cadence === 'year' use product.yearlyPrice, else if cadence === 'month' use
product.monthlyPrice, and for missing/invalid cadence return previewMember (or
otherwise short-circuit) so preview behavior matches the live offer path and
avoids silently mis-mapping unsupported cadence values.
---
Nitpick comments:
In `@apps/portal/test/app.test.js`:
- Around line 140-174: Add a second test case that mirrors the existing "uses
the selected tier price for retention offer preview members" test but sets
cadence=month in the query string; construct a monthlyPrice (getPriceData with
interval: 'month') and ensure paidProduct includes both monthlyPrice and
yearlyPrice, call app.fetchOfferQueryStrData with cadence=month and tier_id set
to paidProduct.id, then assert subscription.price.amount equals
monthlyPrice.amount, subscription.price.interval is 'month',
subscription.price.price_id equals monthlyPrice.id, and subscription.tier
matches the paidProduct id/name to ensure the monthly branch is covered (refer
to the existing test name, App.fetchOfferQueryStrData and
app.getContextFromState).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f0f1bd8b-e6dd-4b6d-b317-30fa0c7ad0bf
📒 Files selected for processing (3)
apps/portal/package.jsonapps/portal/src/app.jsapps/portal/test/app.test.js
Changelog for v2.66.2 -> 2.66.3:
89cf2bb to
fad87bd
Compare
closes https://linear.app/ghost/issue/BER-3434
$15.00tier price from fixtures, instead of reading the tier value passed by Admin