Support all platforms in the test targets#717
Support all platforms in the test targets#717aboedo merged 6 commits intoRevenueCat:swift_migrationfrom
Conversation
| // Should match available platforms in | ||
| // https://developer.apple.com/documentation/iad/adclient?language=objc | ||
| #if TARGET_OS_IOS | ||
| #if TARGET_OS_IOS || TARGET_OS_MACCATALYST |
There was a problem hiding this comment.
I've added Mac Catalyst, but I didn't remove the comment. I think is useful until this class will be migrated to Swift in order to check again the available platforms.
There was a problem hiding this comment.
I saw this after the class had already been merged in #711 😬
I think we had it like this originally because if TARGET_OS_MACCATALYST, then TARGET_OS_IOS also evaluates to true? I'd have to double check.
I think being explicit is probably a good idea in any case
There was a problem hiding this comment.
hehe, no problem, I'll update my branch 👍🏼 Swift code is always welcome 🙂
Well, you're right, it's a double check. IMO, since Mac Catalyst is not so popular it wouldn't make sense to be explicit. So, it's ok for me to use only iOS
| [adClientProxy requestAttributionDetailsWithBlock:completionHandler]; | ||
| #else | ||
| completionHandler([NSDictionary new], nil); | ||
| #endif |
There was a problem hiding this comment.
Well, I added this else block because I think if the code is not executed in iOS, this closure never will be released. Maybe I'm wrong... 🤔
There was a problem hiding this comment.
you're not wrong, I noticed that too when migrating AttributionFetcher 😬
| return mockIdentifier ?? "identifier" | ||
| } | ||
|
|
||
| @available(iOS 11.2, *) |
There was a problem hiding this comment.
redundant availability information
| expect(receivedOffers[2]["price"] as? NSDecimalNumber) == discount3.price | ||
| expect((receivedOffers[2]["payment_mode"] as? NSNumber)?.intValue) == discount3.paymentMode.rawValue | ||
| } | ||
| let discount1 = PromotionalOffer(offerIdentifier: "offerid1", |
There was a problem hiding this comment.
the test is the same, I've only changed how the discounts are initialized. The constructor with a product discount as param is not available for all OS versions, but there is another compatible one. Since the objective of this test case is not to test if the constructor works fine, I think we can use the most compatible constructor. WDYT?
There was a problem hiding this comment.
agreed, I think this was probably an oversight.
|
|
||
| func testCacheKey() { | ||
| if #available(macOS 10.14.4, *) { |
|
|
||
| import Foundation | ||
| import XCTest | ||
| import OHHTTPStubs |
| // | ||
|
|
||
| import XCTest | ||
| import OHHTTPStubs |
|
|
||
| func testPostAppleSearchAdsAttributionIfNeededSkipsIfATTFrameworkNotIncludedOnNewOS() { | ||
| if #available(iOS 14, macOS 11, tvOS 14, *) { | ||
| #if os(iOS) |
There was a problem hiding this comment.
Since the AdClient class is only available for iOS, it doesn't make sense to launch these tests
| // | ||
|
|
||
| import XCTest | ||
| import OHHTTPStubs |
| // Copyright © 2019 RevenueCat. All rights reserved. | ||
| // | ||
|
|
||
| #if !os(watchOS) |
There was a problem hiding this comment.
Ok, here there is an x-files 😅 I've disabled all these test cases for watchOS. I'm not sure what it's happening, but all the tests with POST requests fail. It seems that the stub matcher doesn't recognize the request when is sent. But the same code works fine for the rest of the platforms 🕺🏼
TBH, I'm not sure that the OHHTTPStubs supports correctly watchOS. As you can see, there is an issue with the same behavior and there is a WIP PR to support watchOS. Maybe I'm missing something 🤔
I've asked to OHHTTPStubs' maintainers the status of that task ...
There was a problem hiding this comment.
let's add a comment to explain that
There was a problem hiding this comment.
Perfect! Anyway, I'm going to investigate a little bit more in order to know what it's happening 🤔
| // Should match available platforms in | ||
| // https://developer.apple.com/documentation/iad/adclient?language=objc | ||
| #if TARGET_OS_IOS | ||
| #if TARGET_OS_IOS || TARGET_OS_MACCATALYST |
There was a problem hiding this comment.
I saw this after the class had already been merged in #711 😬
I think we had it like this originally because if TARGET_OS_MACCATALYST, then TARGET_OS_IOS also evaluates to true? I'd have to double check.
I think being explicit is probably a good idea in any case
| [adClientProxy requestAttributionDetailsWithBlock:completionHandler]; | ||
| #else | ||
| completionHandler([NSDictionary new], nil); | ||
| #endif |
There was a problem hiding this comment.
you're not wrong, I noticed that too when migrating AttributionFetcher 😬
| let p = MockSKProduct(mockProductIdentifier: identifier) | ||
| p.mockSubscriptionGroupIdentifier = "1234567" | ||
| if #available(iOS 12.2, *) { | ||
| if #available(iOS 12.2, tvOS 11.2, macOS 10.13.2, *) { |
There was a problem hiding this comment.
I think we might even wanna update the check for iOS - SKProductDiscount is available starting on 11.2
| @available(iOS 12.2, tvOS 11.2, macOS 10.13.2, *) | ||
| lazy var mockDiscount: SKProductDiscount? = nil | ||
|
|
||
| @available(iOS 12.2, *) | ||
| @available(iOS 12.2, tvOS 11.2, macOS 10.13.2, *) |
There was a problem hiding this comment.
same note here, I think we missed the mark with the availability checks for iOS 11.2
| expect(receivedOffers[2]["price"] as? NSDecimalNumber) == discount3.price | ||
| expect((receivedOffers[2]["payment_mode"] as? NSNumber)?.intValue) == discount3.paymentMode.rawValue | ||
| } | ||
| let discount1 = PromotionalOffer(offerIdentifier: "offerid1", |
There was a problem hiding this comment.
agreed, I think this was probably an oversight.
| #if canImport(AppTrackingTransparency) | ||
| import AppTrackingTransparency | ||
| #endif |
| // Copyright © 2019 RevenueCat. All rights reserved. | ||
| // | ||
|
|
||
| #if !os(watchOS) |
There was a problem hiding this comment.
let's add a comment to explain that
…gets # Conflicts: # Purchases/Attribution/RCAttributionFetcher.m
I've checked it and if I run the tests by fastlane I get this crash but if I run the tests by Xcode, I got a green. Let me check it, maybe it's related to the tests config. |
|
Thanks for the code review and your feedback 🤙 I've updated the PR with the suggested changes. I investigated the problem related to the But the main problem is that Nimble.podspec That said, I suggest that the tests shouldn't support WDYT? |
@Juanpe 💯💯💯 |
Hi guys 👋🏼 ! Just to inform you, |
|
Awesome! |
This is a follow up to #717. In order to be able to reproduce #2338, which seems to be an issue only on `watchOS`, it's important that we now run tests on `watchOS` as well. ## Changes: - Added CircleCI job - Added lane - Simplified `UnitTestsHostApp` definition using `SwiftUI` - Increased _test only_ watchOS deployment target to 7.0 (this was necessary to be able to have a comm on `@main` for the host app - Fixed test compilation on `watchOS` - Disabled `HTTPClient` tests on `watchOS` (see AliSoftware/OHHTTPStubs#287) - `StoreKitConfigTestCase` is only available from `watchOS 7.0` since that's when `SKTestSession` was introduced - Added `watchOS` support to `UnitTests` target - Added `watchOS` support to `ReceiptParserTests` target - Fixed `isFamilySharable` `watchOS` version checks for version 8.0 - Created new `CI-RevenueCat` Test Plan to only run unit tests and not StoreKit tests on `watchOS`
This is a follow up to #717. In order to be able to reproduce #2338, which seems to be an issue only on `watchOS`, it's important that we now run tests on `watchOS` as well. We probably won't be able to fully replicate that issue since we don't run tests on actual devices, so they'll still run on 64 bits. But this way we might be able to prevent issues that are only reproducible on `watchOS` in the future. ## Changes: - Added CircleCI job - Added lane - Simplified `UnitTestsHostApp` definition using `SwiftUI` - Increased _test only_ `watchOS` deployment target to 7.0 (this was necessary to be able to have a common `@main` for the host app) - Increased _test only_ `tvOS` deployment target to `14.0` (same as above, plus we only run tvOS tests on the latest version anyway. We test backwards compatibility through iOS already) - Fixed test compilation on `watchOS` - Disabled `HTTPClient` tests on `watchOS` (see AliSoftware/OHHTTPStubs#287) - `StoreKitConfigTestCase` is only available from `watchOS 7.0` since that's when `SKTestSession` was introduced - Added `watchOS` support to `UnitTests` target - Added `watchOS` support to `ReceiptParserTests` target - Fixed `isFamilySharable` `watchOS` version checks for version 8.0 - Created new `CI-RevenueCat` Test Plan to only run unit tests and not StoreKit tests on `watchOS`
This is a follow up to #717. In order to be able to reproduce #2338, which seems to be an issue only on `watchOS`, it's important that we now run tests on `watchOS` as well. We probably won't be able to fully replicate that issue since we don't run tests on actual devices, so they'll still run on 64 bits. But this way we might be able to prevent issues that are only reproducible on `watchOS` in the future. - Added CircleCI job - Added lane - Simplified `UnitTestsHostApp` definition using `SwiftUI` - Increased _test only_ `watchOS` deployment target to 7.0 (this was necessary to be able to have a common `@main` for the host app) - Increased _test only_ `tvOS` deployment target to `14.0` (same as above, plus we only run tvOS tests on the latest version anyway. We test backwards compatibility through iOS already) - Fixed test compilation on `watchOS` - Disabled `HTTPClient` tests on `watchOS` (see AliSoftware/OHHTTPStubs#287) - `StoreKitConfigTestCase` is only available from `watchOS 7.0` since that's when `SKTestSession` was introduced - Added `watchOS` support to `UnitTests` target - Added `watchOS` support to `ReceiptParserTests` target - Fixed `isFamilySharable` `watchOS` version checks for version 8.0 - Created new `CI-RevenueCat` Test Plan to only run unit tests and not StoreKit tests on `watchOS`

Resolves #652
The goal of this PR is to enable all platforms in the test targets.