Skip to content

Fixed retention offer preview not basing prices off actual tier#26786

Merged
sagzy merged 2 commits intomainfrom
fix/retention-offer-preview
Mar 11, 2026
Merged

Fixed retention offer preview not basing prices off actual tier#26786
sagzy merged 2 commits intomainfrom
fix/retention-offer-preview

Conversation

@sagzy
Copy link
Copy Markdown
Contributor

@sagzy sagzy commented Mar 11, 2026

closes https://linear.app/ghost/issue/BER-3434

  • Retention offer previews were using the default $15.00 tier price from fixtures, instead of reading the tier value passed by Admin

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 11, 2026

Walkthrough

Bumps app version from 2.66.2 to 2.66.3. Adds getRetentionPreviewMember({ site, offers }) to compute a preview member with retention-offer-adjusted subscription data. Changes getContextMember signature to accept site, offers, and pageData, and updates its call site in getContextFromState. In the dev/preview path, if page === 'accountPlan' and pageData?.action === 'cancel', it returns the retention preview member. Adds a test asserting the retention preview applies the selected tier price.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing retention offer preview to use actual tier prices instead of default fixture values.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description is directly related to the changeset, describing the issue with retention offer preview using default fixture prices instead of actual tier values.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/retention-offer-preview

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.

❤️ Share

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

@sagzy sagzy requested a review from mike182uk March 11, 2026 17:01
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 year branch. A second case with cadence=month would 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

📥 Commits

Reviewing files that changed from the base of the PR and between e7505d9 and fe98bc0.

📒 Files selected for processing (3)
  • apps/portal/package.json
  • apps/portal/src/app.js
  • apps/portal/test/app.test.js

Comment thread apps/portal/src/app.js
@sagzy sagzy force-pushed the fix/retention-offer-preview branch from 89cf2bb to fad87bd Compare March 11, 2026 17:07
@sagzy sagzy changed the title Fixed retention offer preview not showing prices from an actual tier Fixed retention offer preview not basing prices off actual tier Mar 11, 2026
@sagzy sagzy enabled auto-merge (squash) March 11, 2026 17:18
@sagzy sagzy disabled auto-merge March 11, 2026 17:19
@sagzy sagzy enabled auto-merge (squash) March 11, 2026 17:21
@sagzy sagzy merged commit e13f948 into main Mar 11, 2026
28 checks passed
@sagzy sagzy deleted the fix/retention-offer-preview branch March 11, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants