Skip to content

Make WinbackOfferEligibilityCalculator testable#6866

Merged
fire-at-will merged 8 commits into
winback-offer-eligibilityfrom
make-winback-eligibility-calculator-testable
May 28, 2026
Merged

Make WinbackOfferEligibilityCalculator testable#6866
fire-at-will merged 8 commits into
winback-offer-eligibilityfrom
make-winback-eligibility-calculator-testable

Conversation

@fire-at-will

@fire-at-will fire-at-will commented May 28, 2026

Copy link
Copy Markdown
Contributor

Description

Make the WinbackOfferEligibilityCalculator testable by removing its direct dependencies on StoreKit classes.


Note

Medium Risk
Changes how win-back offers are resolved for subscriptions (purchase-relevant), but it is largely a structural refactor with new coverage; incorrect adapter mapping could change which offers are returned.

Overview
Refactors win-back offer eligibility so WinBackOfferEligibilityCalculator runs on internal, StoreKit-free protocols instead of Product / StoreProduct types directly. A new WinBackEligibilityAdapters.swift maps real StoreKit subscription data into those protocols at the public entry point; eligibility rules (purchased ownership, renewal IDs, billing-plan filtering on iOS 26.4+) stay the same but are easier to unit test.

Adds WinBackOfferEligibilityCalculatorTests with mocks covering empty/error paths, offer ordering, missing offers, and billing-plan / pricing-term filtering when the newer APIs are available.

Reviewed by Cursor Bugbot for commit 7c2c53a. Bugbot is set up for automated code reviews on this repo. Configure here.

@fire-at-will fire-at-will requested a review from a team as a code owner May 28, 2026 17:53

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d4d5922. Configure here.

Comment thread Sources/Purchasing/StoreKit2/Win-Back Offers/WinBackEligibilityAdapters.swift Outdated
@emerge-tools

emerge-tools Bot commented May 28, 2026

Copy link
Copy Markdown

⚠️ 3 new unused protocols, 4 builds increased size

Name Version Download Change Install Change Approval
RevenueCat
com.revenuecat.PaywallsTester
1.0 (1) 18.1 MB ⬆️ 50.9 kB (0.28%) 64.9 MB ⬆️ 197.2 kB (0.31%) N/A
BinarySizeTest
com.revenuecat.binary-size-test.local-source
1.0 (1) 4.1 MB ⬆️ 17.9 kB (0.44%) 12.4 MB ⬆️ 44.0 kB (0.36%) ⏳ Needs approval
BinarySizeTest
com.revenuecat.binary-size-test.cocoapods
1.0 (1) 6.2 MB ⬆️ 25.0 kB (0.4%) 27.3 MB ⬆️ 93.6 kB (0.35%) ⏳ Needs approval
BinarySizeTest
com.revenuecat.binary-size-test.spm
1.0 (1) 4.2 MB ⬆️ 17.1 kB (0.41%) 10.8 MB ⬆️ 39.5 kB (0.37%) ⏳ Needs approval

RevenueCat 1.0 (1)
com.revenuecat.PaywallsTester

⚠️ Found new unused protocol: WinBackEligibilityPricingTermsType
⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 197.2 kB (0.31%)
Total download size change: ⬆️ 50.9 kB (0.28%)

Largest size changes

Item Install Size Change
DYLD.String Table ⬆️ 73.2 kB
📝 RCInstallmentsInfo.Objc Metadata ⬆️ 8.8 kB
Code Signature ⬆️ 5.1 kB
DYLD.Exports ⬆️ 4.6 kB
RevenueCat.ProductsManager.ProductsManager ⬆️ 3.7 kB
View Treemap

Image of diff

BinarySizeTest 1.0 (1)
com.revenuecat.binary-size-test.local-source

⚖️ Compare build
📦 Install build
⏱️ Analyze build performance

Total install size change: ⬆️ 44.0 kB (0.36%)
Total download size change: ⬆️ 17.9 kB (0.44%)

Largest size changes

Item Install Size Change
DYLD.String Table ⬆️ 3.2 kB
📝 RevenueCat.WinBackOfferEligibilityCalculator.winbackOffersByID(fo... ⬆️ 2.2 kB
📝 RCInstallmentsInfo.Objc Metadata ⬆️ 2.1 kB
DYLD.Exports ⬆️ 1.8 kB
Swift.Sequence.compactMap ⬇️ -1.4 kB
View Treemap

Image of diff

BinarySizeTest 1.0 (1)
com.revenuecat.binary-size-test.cocoapods

⚠️ Found new unused protocol: WinBackEligibilityPricingTermsType
⚖️ Compare build
📦 Install build
⏱️ Analyze build performance

Total install size change: ⬆️ 93.6 kB (0.35%)
Total download size change: ⬆️ 25.0 kB (0.4%)

Largest size changes

Item Install Size Change
DYLD.String Table ⬆️ 35.4 kB
Code Signature ⬆️ 2.3 kB
📝 RevenueCat.WinBackOfferEligibilityCalculator.winbackOffersByID(fo... ⬆️ 2.3 kB
📝 RCInstallmentsInfo.Objc Metadata ⬆️ 2.1 kB
DYLD.Exports ⬆️ 1.7 kB
View Treemap

Image of diff

BinarySizeTest 1.0 (1)
com.revenuecat.binary-size-test.spm

⚠️ Found new unused protocol: WinBackEligibilityPricingTermsType
⚖️ Compare build
📦 Install build
⏱️ Analyze build performance

Total install size change: ⬆️ 39.5 kB (0.37%)
Total download size change: ⬆️ 17.1 kB (0.41%)

Largest size changes

Item Install Size Change
📝 RevenueCat.WinBackOfferEligibilityCalculator.winbackOffersByID(fo... ⬆️ 2.2 kB
📝 RCInstallmentsInfo.Objc Metadata ⬆️ 2.1 kB
DYLD.Exports ⬆️ 1.8 kB
Swift.Sequence.compactMap ⬇️ -1.4 kB
Code Signature ⬆️ 1.2 kB
View Treemap

Image of diff


🛸 Powered by Emerge Tools

Comment trigger: Size diff threshold of 100.00kB exceeded

@fire-at-will fire-at-will changed the title make the calculator testable Make WinbackOfferEligibilityCalculator testable May 28, 2026
@fire-at-will

Copy link
Copy Markdown
Contributor Author

I got verbal approval for this from @JZDesign in slack - will go ahead and merge through to the dev branch

@fire-at-will fire-at-will merged commit 6f763f0 into winback-offer-eligibility May 28, 2026
16 of 19 checks passed
@fire-at-will fire-at-will deleted the make-winback-eligibility-calculator-testable branch May 28, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant