Skip to content

Commit

Permalink
Paywalls: iOS 17 tests on CI (#2955)
Browse files Browse the repository at this point in the history
  • Loading branch information
NachoSoto committed Sep 8, 2023
1 parent ddca58b commit 51282c1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
22 changes: 22 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,26 @@ jobs:
name: RevenueCatUI API Tests
command: bundle exec fastlane build_revenuecatui_api_tester

spm-revenuecat-ui-ios-17:
<<: *base-job
steps:
- checkout
- update-spm-installation-commit
- run:
name: SPM RevenueCatUI Tests
command: bundle exec fastlane test_revenuecatui
no_output_timeout: 15m
environment:
SCAN_DEVICE: iPhone 14 Pro,OS=17.0
- compress_result_bundle:
directory: fastlane/test_output
bundle_name: revenuecatui
- store_test_results:
path: fastlane/test_output/revenuecatui/tests.xml
- store_artifacts:
path: fastlane/test_output
destination: scan-test-output

run-test-ios-17:
<<: *base-job
steps:
Expand Down Expand Up @@ -947,6 +967,8 @@ workflows:
xcode_version: '14.3.0'
- spm-revenuecat-ui-ios-16:
xcode_version: '14.3.0'
- spm-revenuecat-ui-ios-17:
xcode_version: '15.0.0'
# Disabled until we drop support for iOS 11
# - run-test-ios-17:
# xcode_version: '15.0.0'
Expand Down
14 changes: 13 additions & 1 deletion Tests/RevenueCatUITests/BaseSnapshotTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,28 @@ extension BaseSnapshotTest {
extension View {

/// Adds the receiver to a view hierarchy to be able to test lifetime logic.
func addToHierarchy() {
func addToHierarchy() throws {
if #available(iOS 17.0, *) {
try XCTSkipIf(true, "This is currently not working on iOS 17")
}

UIView.setAnimationsEnabled(false)

let controller = UIHostingController(
rootView: self
.frame(width: BaseSnapshotTest.fullScreenSize.width,
height: BaseSnapshotTest.fullScreenSize.height)
)

let window = UIWindow()
window.isHidden = false
window.rootViewController = controller
window.frame.size = BaseSnapshotTest.fullScreenSize
window.makeKeyAndVisible()

window.addSubview(controller.view)
controller.didMove(toParent: controller)

window.setNeedsLayout()
window.layoutIfNeeded()

Expand Down
2 changes: 1 addition & 1 deletion Tests/RevenueCatUITests/PresentIfNeededTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PresentIfNeededTests: TestCase {
func testPresentWithPurchaseHandler() throws {
var customerInfo: CustomerInfo?

Text("")
try Text("")
.presentPaywallIfNeeded(offering: Self.offering,
introEligibility: .producing(eligibility: .eligible),
purchaseHandler: Self.purchaseHandler) { _ in
Expand Down
4 changes: 2 additions & 2 deletions Tests/RevenueCatUITests/PurchaseCompletedHandlerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PurchaseCompletedHandlerTests: TestCase {
var customerInfo: CustomerInfo?
var purchased = false

PaywallView(
try PaywallView(
offering: Self.offering.withLocalImages,
introEligibility: .producing(eligibility: .eligible),
purchaseHandler: handler
Expand All @@ -51,7 +51,7 @@ class PurchaseCompletedHandlerTests: TestCase {
func testOnPurchaseCompleted() throws {
var customerInfo: CustomerInfo?

PaywallView(
try PaywallView(
offering: Self.offering.withLocalImages,
introEligibility: .producing(eligibility: .eligible),
purchaseHandler: Self.purchaseHandler
Expand Down

0 comments on commit 51282c1

Please sign in to comment.