New TestStoreProduct for creating mock StoreProducts and Offerings#2711
Merged
NachoSoto merged 6 commits intoJun 29, 2023
Merged
Conversation
be432d1 to
63ef66e
Compare
092c19d to
3c606bf
Compare
734d723 to
781c5bf
Compare
781c5bf to
d7e50c2
Compare
d7e50c2 to
750aaaa
Compare
Codecov Report
@@ Coverage Diff @@
## main #2711 +/- ##
==========================================
+ Coverage 86.46% 86.51% +0.04%
==========================================
Files 212 213 +1
Lines 15055 15101 +46
==========================================
+ Hits 13018 13064 +46
Misses 2037 2037
|
750aaaa to
66fe37d
Compare
aboedo
approved these changes
Jun 29, 2023
Comment on lines
292
to
293
Member
There was a problem hiding this comment.
we really aren't making Liskov very happy with this, but it should be fine
Contributor
Author
There was a problem hiding this comment.
If I understand your point, that also applies to how we handle SK1 and SK2 products above, right?
Fixes #1563 and #2193. This introduces **`DEBUG` and `Swift` only** types that allow creating a whole `Offering` for tests and SwiftUI previews. Example:  By making it available in only `DEBUG` builds we ensure that apps can't accidentally try to purchase these products, which would be impossible. If this is attempted in `DEBUG` builds, we return `ErrorCode`. When trying to compile this API in release builds, you get an error with a suggestion: 
66fe37d to
272f3ee
Compare
NachoSoto
added a commit
that referenced
this pull request
Jun 30, 2023
**This is an automatic release.** ### New Features * New `TestStoreProduct` for creating mock `StoreProduct`s and `Offering`s (#2711) via NachoSoto (@NachoSoto) ✨ With this new API you can now create fake products for unit tests and SwiftUI previews! 🎉 #### Example: ```swift let product = TestStoreProduct( localizedTitle: "PRO monthly", price: 3.99, localizedPriceString: "$3.99", productIdentifier: "com.revenuecat.product", productType: .autoRenewableSubscription, localizedDescription: "Description", subscriptionGroupIdentifier: "group", subscriptionPeriod: .init(value: 1, unit: .month) ) let offering = Offering( identifier: "offering", serverDescription: "Main offering", metadata: [:], availablePackages: [ .init( identifier: "monthly", packageType: .monthly, storeProduct: product.toStoreProduct(), offeringIdentifier: offering ) ] ) ``` ### Dependency Updates * Bump fastlane-plugin-revenuecat_internal from `13773d2` to `b2108fb` (#2706) via dependabot[bot] (@dependabot[bot]) ### Other Changes * `VerificationResult: CustomDebugStringConvertible` (#2739) via NachoSoto (@NachoSoto) * Refactor: simplified `PurchasesOrchestrator.syncPurchases` (#2731) via NachoSoto (@NachoSoto) * `Trusted Entitlements`: add integration tests to verify `CustomerInfo` cache invalidation (#2730) via NachoSoto (@NachoSoto) * `SystemInfo.identifierForVendor`: add tests (#2732) via NachoSoto (@NachoSoto) * `Tests`: disabled `iOS 11.x` tests to fix `Xcode 15` tests (#2720) via NachoSoto (@NachoSoto) * `DebugViewSwiftUITests`: create separate snapshots for each OS version (#2721) via NachoSoto (@NachoSoto) * `Integration Tests`: fix clearing `UserDefaults` before each test (#2719) via NachoSoto (@NachoSoto) * Remove unused `Signing.loadPublicKey(with:)` (#2714) via NachoSoto (@NachoSoto) * Add `UInt32(littleEndian32Bits:)` and `UInt32.littleEndianData` (#2713) via NachoSoto (@NachoSoto) * `TimingUtil`: added synchronous API (#2716) via NachoSoto (@NachoSoto) * `XCFramework`: sign archive for `Xcode 15` (#2709) via NachoSoto (@NachoSoto) * `CI`: removed `carthage_archive` from `release` lane (#2710) via NachoSoto (@NachoSoto) * `PriceFormatterProvider.priceFormatterForSK2`: enable on all versions (#2712) via NachoSoto (@NachoSoto) * `xrOS`: add support for `debugRevenueCatOverlay` (#2702) via NachoSoto (@NachoSoto) * Refactor method to get product ID including plan ID in android purchases (#2708) via Toni Rico (@tonidero) * `Purchases.restoreLogHandler` (#2699) via NachoSoto (@NachoSoto) * Remove alpha from purchase tester icon to upload to testflight (#2705) via Toni Rico (@tonidero) --------- Co-authored-by: NachoSoto <ignaciosoto90@gmail.com>
NachoSoto
added a commit
that referenced
this pull request
Jul 23, 2023
See #2711. This is needed for #2855. In order to be able to create test products for the paywall loading screen, we need to be able to do this in release builds as well. Another benefit of exposing `TestStoreProduct` in release builds is that it's also usable for pre-built versions of the SDK (like Carthage).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1563 and #2193.
This introduces
DEBUGandSwiftonly types that allow creating a wholeOfferingfor tests and SwiftUI previews.Example:

By making it available in only
DEBUGbuilds we ensure that apps can't accidentally try to purchase these products, which would be impossible. If this is attempted inDEBUGbuilds, we returnErrorCode.When trying to compile this API in release builds, you get an error with a suggestion:
