Add API tests for purchases-capacitor and purchases-capacitor-ui#720
Conversation
|
Nice! Thank you so much for adding this! Will take a look later. One thought however, it might also be useful to add api-extractor (same way we do for the PHC TS libraries + RN) to extract the public API automatically and have "golden" API tests created automatically. These tests can still be useful though, but I think the others make sure to cover things more extensively. |
Thanks @tonidero, great idea. Working on that as a follow-up here |
a6ef5ff to
7304e65
Compare
tonidero
left a comment
There was a problem hiding this comment.
Tests themselves looking good but have a comment that I think would need to be addressed... In any case, I would say the api-extractor changes you did in the follow-up PR provide more coverage than these so I think of these as less important. Though they can still be useful in certain occasions.
| @@ -0,0 +1,32 @@ | |||
| import type { PurchasesPlugin } from '../src/definitions'; | |||
There was a problem hiding this comment.
One thing is that this is importing directly from src... I think the proper way to implement these API tests is split it into a separate Capacitor/TS project and to link to the library from there, not the source code. Otherwise, these API tests actually would have access to the internal code of the library and it might seem like we're exposing things that we aren't actually.
There was a problem hiding this comment.
Very good point, updated to make the api tester separate projects with their own package.json that import the library instead :)
Add TypeScript compilation-only API tests that verify the public API surface compiles correctly. Covers all plugin methods, types, enums, option interfaces, and listener callbacks for both packages. - Main package: purchases, offerings, customerInfo, enums, errors, attributes, definitions - UI package: revenuecatui, definitions, enums
- Add type tests for PurchasesWinBackOffer, GoogleProductChangeInfo, Storefront, UpgradeInfo in offerings.ts - Add WebPurchaseRedemption field test (redemptionLink) - Add WebPurchaseRedemptionResult discriminated union coverage - Add WebPurchaseRedemptionResultType exhaustive enum switch - Add PaywallResultEnum re-export test in UI package
- Add missing enums: VERIFICATION_RESULT, PRODUCT_TYPE, PURCHASE_TYPE, PAYWALL_RESULT, WebPurchaseRedemptionResultType - Add missing type tests: PurchasesSubscriptionInfo, PurchasesVirtualCurrency, PurchaseParams, ShouldPurchasePromoProductListener, MakePurchaseResult - Add missing type aliases: Store, OwnershipType, PeriodType - Add missing properties on PurchasesEntitlementInfo (8 fields), PurchasesEntitlementInfos (verification), CustomerInfo (subscriptionsByProductIdentifier), PurchasesStoreProduct (productType), PurchasesPackage (webCheckoutUrl), PurchasesOffering (webCheckoutUrl) - Add missing PurchasesConfiguration options (6 fields) - Add missing TEST_STORE_SIMULATED_PURCHASE_ERROR error code
Instead of importing directly from ../src/definitions (which gives access to internal code), the apitesters are now separate TS projects with their own package.json that depend on the parent package via file: links. This ensures the tests can only access the public API surface exposed through the package exports.
7304e65 to
6a04b54
Compare
tonidero
left a comment
There was a problem hiding this comment.
Looking good! Just a possible improvement but no blockers
**This is an automatic release.** ## RevenueCat SDK ### 📦 Dependency Updates * Updates purchases-hybrid-common to 17.54.0 (#745) via RevenueCat Git Bot (@RCGitBot) * [Android 9.28.1](https://github.com/RevenueCat/purchases-android/releases/tag/9.28.1) * [Android 9.28.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.28.0) * [Android 9.27.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.27.0) * [iOS 5.67.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.67.0) * [iOS 5.66.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.66.0) * [AUTOMATIC BUMP] Updates purchases-hybrid-common to 17.53.0 (#737) via RevenueCat Git Bot (@RCGitBot) * [Android 9.28.1](https://github.com/RevenueCat/purchases-android/releases/tag/9.28.1) * [Android 9.28.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.28.0) * [Android 9.27.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.27.0) * [iOS 5.67.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.67.0) * [iOS 5.66.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.66.0) ### 🔄 Other Changes * fix: upgrade dependencies with known security vulnerabilities (#743) via Cesar de la Vega (@vegaro) * Bump fastlane-plugin-revenuecat_internal from `9a6911b` to `f11fe40` (#742) via dependabot[bot] (@dependabot[bot]) * security: pin GitHub Actions to SHA hashes (#741) via Alfonso Embid-Desmet (@alfondotnet) * Merge release PR after deploy (#739) via Antonio Pallares (@ajpallares) * Add missing API tests for presentation configuration and trackCustomPaywallImpression (#740) via Rick (@rickvdl) * Require PR approval before release tagging (#738) via Antonio Pallares (@ajpallares) * Add API tests for purchases-capacitor and purchases-capacitor-ui (#720) via Rick (@rickvdl) * Add AGENTS.md for AI coding agent guidance (#696) via Facundo Menzella (@facumenzella)
Summary
noEmit: true) that verify the public API surface of bothpurchases-capacitorandpurchases-capacitor-uicompiles correctlyrun-api-testsandrun-api-tests-uiCI jobs to the CircleCI workflow and release gateDetails
purchases-capacitor (
apitesters/)purchases.ts— AllPurchasesPluginmethod signatures including discriminated union coverageofferings.ts— Offering, package, product, and storefront typescustomerInfo.ts— CustomerInfo, entitlements, subscription infoenums.ts— Exhaustive switch coverage for all enumserrors.ts— All PURCHASES_ERROR_CODE valuesattributes.ts— All 19 attribute setter methodsdefinitions.ts— All Capacitor-specific option interfacespurchases-capacitor-ui (
purchases-capacitor-ui/apitesters/)revenuecatui.ts— All RevenueCatUIPlugin method signaturesenums.ts— PURCHASE_LOGIC_RESULT and PAYWALL_RESULTdefinitions.ts— All UI option types