Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up API Testers #4141

Merged
merged 24 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7d3a6e8
added all api tests to the xcode project, created a new framework tar…
aboedo Jul 31, 2024
67b1527
remove old objc api tester
aboedo Jul 31, 2024
4b7bcc3
replace old swift api tester with framework
aboedo Jul 31, 2024
ae812aa
remove old swift api tester references
aboedo Jul 31, 2024
1b9ccd4
more clean up
aboedo Jul 31, 2024
8233805
replade old receipt parser api tester with new one
aboedo Jul 31, 2024
b697f73
clean up old receipt parser API tester
aboedo Jul 31, 2024
faf25d0
replace old RevenueCatUI Swift API Tester with new one as framework
aboedo Jul 31, 2024
375d399
clean up old RevenueCat UI Swift API Tester references
aboedo Jul 31, 2024
c28cf86
remove old custom entitlements computation api tester project, replac…
aboedo Jul 31, 2024
a1a213e
clean up old references
aboedo Jul 31, 2024
1e9b43c
clean up some test targets
aboedo Jul 31, 2024
ce81479
clean up all remaining test targets
aboedo Jul 31, 2024
36826e4
fix availability checks in custom entitlements computation swift API …
aboedo Jul 31, 2024
56ac64c
removed a couple of references to the old projects
aboedo Jul 31, 2024
8be18f6
reflects new scheme in tests
aboedo Jul 31, 2024
9c9cc88
add clarification in comment
aboedo Jul 31, 2024
f72c0ba
clean up platforms listed in api testers
aboedo Aug 2, 2024
50252c3
and more platforms lists cleanup
aboedo Aug 2, 2024
0aa9cf3
add carthage installation tests on all commits for testing
aboedo Aug 2, 2024
3aea769
clean up more platform checks in api tests
aboedo Aug 2, 2024
8159380
and more platform check cleanup
aboedo Aug 2, 2024
029b161
and even more platform check cleanup
aboedo Aug 2, 2024
5a98922
delete temporary changes
aboedo Aug 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -469,19 +469,14 @@ jobs:
command: swift build -c release --target RevenueCatUI
no_output_timeout: 30m

spm-custom-entitlement-computation-build:
api-tests:
<<: *base-job
steps:
- checkout
- run:
name: SPM Custom Entitlement Computation Build
command: swift build --target RevenueCat_CustomEntitlementComputation
no_output_timeout: 30m
- install-dependencies
- update-spm-installation-commit
- run:
name: Custom Entitlement Computation API Tests
command: bundle exec fastlane build_custom_entitlement_computation_api_tester
name: API Tests
command: bundle exec fastlane run_api_tests

spm-receipt-parser:
<<: *base-job
Expand Down Expand Up @@ -563,11 +558,6 @@ jobs:
- store_artifacts:
path: fastlane/test_output
destination: scan-test-output
- run:
condition:
- not: << pipeline.parameters.generate_revenuecatui_snapshots >>
name: RevenueCatUI API Tests
command: bundle exec fastlane build_revenuecatui_api_tester

run-revenuecat-ui-ios-17:
<<: *base-job
Expand Down Expand Up @@ -1415,7 +1405,6 @@ workflows:
- run-test-macos
- run-test-tvos
- run-test-watchos
- spm-custom-entitlement-computation-build
- spm-receipt-parser
- spm-release-build
- spm-release-build-xcode-14
Expand All @@ -1431,3 +1420,4 @@ workflows:
- installation-tests-xcode-direct-integration
- installation-tests-receipt-parser
- deploy-purchase-tester-dry-run
- api-tests
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ Tests/purchases-ios-snapshots

Examples/**/Package.resolved

Tests/APITesters/RevenueCatUIAPITester/RevenueCatUISwiftAPITester.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Tests/APITesters/CustomEntitlementComputationSwiftAPITester/CustomEntitlementComputationSwiftAPITester.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Tests/InstallationTests/SPMInstallation/SPMInstallation.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Tests/InstallationTests/ReceiptParserInstallation/ReceiptParserInstallation.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Tests/InstallationTests/XcodeDirectInstallation/XcodeDirectInstallation.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Expand Down
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ excluded:
- Examples
- Tests/InstallationTests
- Tests/TestingApps
- Tests/APITesters
- vendor
- scan_derived_data
- .git
Expand Down
212 changes: 131 additions & 81 deletions RevenueCat.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1,864 changes: 1,864 additions & 0 deletions Tests/APITesters/AllAPITests/AllAPITests.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
version = "1.3">
LastUpgradeVersion = "1540"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand All @@ -14,10 +15,10 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2DD778CF270E233F0079CBD4"
BuildableName = "SwiftAPITester.app"
BlueprintName = "SwiftAPITester"
ReferencedContainer = "container:SwiftAPITester.xcodeproj">
BlueprintIdentifier = "2D4C60D72C5AD1BC00A29FD2"
BuildableName = "AllAPITests.framework"
BlueprintName = "AllAPITests"
ReferencedContainer = "container:AllAPITests.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
Expand All @@ -26,8 +27,20 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D4C60DF2C5AD1BC00A29FD2"
BuildableName = "AllAPITestsTests.xctest"
BlueprintName = "AllAPITestsTests"
ReferencedContainer = "container:AllAPITests.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand All @@ -50,10 +63,10 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2DD778CF270E233F0079CBD4"
BuildableName = "SwiftAPITester.app"
BlueprintName = "SwiftAPITester"
ReferencedContainer = "container:SwiftAPITester.xcodeproj">
BlueprintIdentifier = "2D4C60D72C5AD1BC00A29FD2"
BuildableName = "AllAPITests.framework"
BlueprintName = "AllAPITests"
ReferencedContainer = "container:AllAPITests.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
Expand Down
17 changes: 17 additions & 0 deletions Tests/APITesters/AllAPITests/AllAPITests/AllAPITests.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// AllAPITests.h
// AllAPITests
//
// Created by Andrés Boedo on 7/31/24.
//

#import <Foundation/Foundation.h>

//! Project version number for AllAPITests.
FOUNDATION_EXPORT double AllAPITestsVersionNumber;

//! Project version string for AllAPITests.
FOUNDATION_EXPORT const unsigned char AllAPITestsVersionString[];

// Note: this file is empty because we only want the ability to run tests, but API tests really run at
// the compilation step. I.e.: if the test compiles and can run, then it already passed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// AllAPITestsTests.swift
// AllAPITestsTests
//
// Created by Andrés Boedo on 7/31/24.
//

@testable import AllAPITests
import XCTest

class AllAPITestsTests: XCTestCase {

func testExample() throws {
// Note: this test is empty because we only want the ability to run tests, but API tests really run at
// the compilation step. I.e.: if the test compiles and can run, then it already passed.
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ import RevenueCat_CustomEntitlementComputation
private var attribution: Attribution!

func checkAttributionAPI() {
attribution.enableAdServicesAttributionTokenCollection()
#if os(iOS) || os(macOS)
if #available(iOS 14.3, macOS 11.1, macCatalyst 14.3, *) {
attribution.enableAdServicesAttributionTokenCollection()
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// CustomEntitlementComputationSwiftAPITester.h
// CustomEntitlementComputationSwiftAPITester
//
// Created by Andrés Boedo on 7/31/24.
//

#import <Foundation/Foundation.h>

//! Project version number for CustomEntitlementComputationSwiftAPITester.
FOUNDATION_EXPORT double CustomEntitlementComputationSwiftAPITesterVersionNumber;

//! Project version string for CustomEntitlementComputationSwiftAPITester.
FOUNDATION_EXPORT const unsigned char CustomEntitlementComputationSwiftAPITesterVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <CustomEntitlementComputationSwiftAPITester/PublicHeader.h>


Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ var offer: PromotionalOffer!
func checkPromotionalOfferAPI() {
let discount: StoreProductDiscount = offer.discount
let sk1Discount = offer.discount.sk1Discount
let sk2Discount = offer.discount.sk2Discount
if #available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *) {
let sk2Discount = offer.discount.sk2Discount
print(sk2Discount!)
}

let signedData = offer.signedData

Expand All @@ -23,5 +26,5 @@ func checkPromotionalOfferAPI() {
let _: String = signedData.signature
let _: Int = signedData.timestamp

print(discount, sk1Discount!, sk2Discount!)
print(discount, sk1Discount!)
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ private func checkPurchasesPurchasingAPI(purchases: Purchases) {
purchases.restorePurchases()
purchases.restorePurchases { (_: CustomerInfo?, _: PublicError?) in }

if #available(iOS 14.0, *) {
#if os(iOS)
purchases.presentCodeRedemptionSheet()
purchases.presentCodeRedemptionSheet()
#endif
}

// PurchasesDelegate
let customerInfo: CustomerInfo? = nil
Expand All @@ -141,10 +143,12 @@ private func checkPurchasesSupportAPI(purchases: Purchases) {
#if os(iOS)
purchases.showManageSubscriptions { _ in }
#endif
#if os(iOS) || targetEnvironment(macCatalyst)
_ = purchases.showPriceConsentIfNeeded
_ = purchases.delegate?.shouldShowPriceConsent
#endif
if #available(iOS 13.4, *) {
#if os(iOS) || targetEnvironment(macCatalyst)
_ = purchases.showPriceConsentIfNeeded
_ = purchases.delegate?.shouldShowPriceConsent
#endif
}
}

private func checkAsyncMethods(purchases: Purchases) async {
Expand All @@ -162,21 +166,25 @@ private func checkAsyncMethods(purchases: Purchases) async {

let _: CustomerInfo = try await purchases.restorePurchases()

#if os(iOS)
try await purchases.showManageSubscriptions()
let _: RefundRequestStatus = try await purchases.beginRefundRequest(forProduct: "")
let _: RefundRequestStatus = try await purchases.beginRefundRequest(forEntitlement: "")
let _: RefundRequestStatus = try await purchases.beginRefundRequestForActiveEntitlement()
#endif
if #available(iOS 15.0, *) {
#if os(iOS)
try await purchases.showManageSubscriptions()
let _: RefundRequestStatus = try await purchases.beginRefundRequest(forProduct: "")
let _: RefundRequestStatus = try await purchases.beginRefundRequest(forEntitlement: "")
let _: RefundRequestStatus = try await purchases.beginRefundRequestForActiveEntitlement()
#endif
}
} catch {}
}

func checkNonAsyncMethods(_ purchases: Purchases) {
#if os(iOS)
purchases.beginRefundRequest(forProduct: "") { (_: Result<RefundRequestStatus, PublicError>) in }
purchases.beginRefundRequest(forEntitlement: "") { (_: Result<RefundRequestStatus, PublicError>) in }
purchases.beginRefundRequestForActiveEntitlement { (_: Result<RefundRequestStatus, PublicError>) in }
#endif
if #available(iOS 15.0, *) {
#if os(iOS)
purchases.beginRefundRequest(forProduct: "") { (_: Result<RefundRequestStatus, PublicError>) in }
purchases.beginRefundRequest(forEntitlement: "") { (_: Result<RefundRequestStatus, PublicError>) in }
purchases.beginRefundRequestForActiveEntitlement { (_: Result<RefundRequestStatus, PublicError>) in }
#endif
}
}

private func checkConfigure() -> Purchases! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ func checkStoreProductAPI() {
let decimalPrice: NSDecimalNumber = product.priceDecimalNumber
let localizedPriceString: String = product.localizedPriceString
let productIdentifier: String = product.productIdentifier
let isFamilyShareable: Bool = product.isFamilyShareable
if #available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) {
let isFamilyShareable: Bool = product.isFamilyShareable
print(isFamilyShareable)
}
let subscriptionGroupIdentifier: String? = product.subscriptionGroupIdentifier
let priceFormatter: NumberFormatter? = product.priceFormatter
let subscriptionPeriod: SubscriptionPeriod? = product.subscriptionPeriod
Expand All @@ -31,7 +34,10 @@ func checkStoreProductAPI() {
let pricePerMonth: NSDecimalNumber? = product.pricePerMonth
let localizedIntroductoryPriceString: String? = product.localizedIntroductoryPriceString
let sk1Product: SK1Product? = product.sk1Product
let sk2Product: SK2Product? = product.sk2Product
if #available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *) {
let sk2Product: SK2Product? = product.sk2Product
print(sk2Product!)
}

print(
product!,
Expand All @@ -44,25 +50,25 @@ func checkStoreProductAPI() {
decimalPrice,
localizedPriceString,
productIdentifier,
isFamilyShareable,
subscriptionGroupIdentifier!,
priceFormatter!,
subscriptionPeriod!,
introductoryPrice!,
discounts,
pricePerMonth!,
localizedIntroductoryPriceString!,
sk1Product!,
sk2Product!
sk1Product!
)
}

func checkConstructors() {
let sk1Product: SK1Product! = nil
let sk2Product: SK2Product! = nil
if #available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *) {
let sk2Product: SK2Product! = nil
_ = StoreProduct(sk2Product: sk2Product!)
}

_ = StoreProduct(sk1Product: sk1Product!)
_ = StoreProduct(sk2Product: sk2Product!)
}

func checkProductCategory(_ category: StoreProduct.ProductCategory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ func checkStoreProductDiscountAPI() {
let subscriptionPeriod: SubscriptionPeriod = discount.subscriptionPeriod

let sk1Discount: SK1ProductDiscount = discount.sk1Discount!
let sk2Discount: SK2ProductDiscount = discount.sk2Discount!
if #available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *) {
let sk2Discount: SK2ProductDiscount = discount.sk2Discount!
print(sk2Discount)
}

print(
offerIdentifier!,
Expand All @@ -33,8 +36,7 @@ func checkStoreProductDiscountAPI() {
paymentMode,
priceFormatter!,
subscriptionPeriod,
sk1Discount,
sk2Discount
sk1Discount
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ func checkStoreTransactionAPI() {
let quantity: Int = transaction.quantity

let sk1: SKPaymentTransaction? = transaction.sk1Transaction
let sk2: StoreKit.Transaction? = transaction.sk2Transaction
if #available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *) {
let sk2: StoreKit.Transaction? = transaction.sk2Transaction
print(sk2!)
}

print(
productIdentifier,
purchaseDate,
transactionIdentifier,
quantity,
sk1!,
sk2!
sk1!
)
}
Loading