diff --git a/.circleci/config.yml b/.circleci/config.yml index 40f173c67f..47661c53ab 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -329,6 +329,14 @@ jobs: no_output_timeout: 5m environment: SCAN_DEVICE: iPhone 14,OS=16.4 + - 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: name: RevenueCatUI API Tests command: bundle exec fastlane build_revenuecatui_api_tester diff --git a/RevenueCatUI/View+PresentPaywall.swift b/RevenueCatUI/View+PresentPaywall.swift index 8995d97b4b..8aab649238 100644 --- a/RevenueCatUI/View+PresentPaywall.swift +++ b/RevenueCatUI/View+PresentPaywall.swift @@ -9,6 +9,7 @@ import RevenueCat import SwiftUI @available(iOS 16.0, macOS 13.0, tvOS 16.0, *) +@available(macOS, unavailable, message: "RevenueCatUI does not support macOS yet") extension View { /// Presents a ``PaywallView`` if the given entitlement identifier is not active @@ -57,6 +58,7 @@ extension View { } @available(iOS 16.0, macOS 13.0, tvOS 16.0, *) +@available(macOS, unavailable, message: "RevenueCatUI does not support macOS yet") private struct PresentingPaywallModifier: ViewModifier { var shouldDisplay: @Sendable (CustomerInfo) -> Bool diff --git a/Tests/RevenueCatUITests/__Snapshots__/OtherPaywallViewTests/iOS16-testDefaultPaywall.1.png b/Tests/RevenueCatUITests/__Snapshots__/OtherPaywallViewTests/iOS16-testDefaultPaywall.1.png index dcb28586fe..33e49d2d87 100644 Binary files a/Tests/RevenueCatUITests/__Snapshots__/OtherPaywallViewTests/iOS16-testDefaultPaywall.1.png and b/Tests/RevenueCatUITests/__Snapshots__/OtherPaywallViewTests/iOS16-testDefaultPaywall.1.png differ diff --git a/Tests/UnitTests/TestHelpers/SnapshotTesting+Extensions.swift b/Tests/UnitTests/TestHelpers/SnapshotTesting+Extensions.swift index 61f96749bc..ed4830ddaa 100644 --- a/Tests/UnitTests/TestHelpers/SnapshotTesting+Extensions.swift +++ b/Tests/UnitTests/TestHelpers/SnapshotTesting+Extensions.swift @@ -56,29 +56,18 @@ extension SwiftUI.View { ) { UIView.setAnimationsEnabled(false) - // Add test view to the hierarchy to make sure async rendering takes place. // The tested view is `controller.view` instead of `self` to keep it in memory // while rendering happens - let controller = UIViewController() - let window = UIWindow() - window.rootViewController = controller - - controller.view.addSubview( - self + let controller = UIHostingController(rootView: self .frame(width: size.width, height: size.height) - .asUIView(container: controller, size: size) ) - controller.view.backgroundColor = .white expect( file: file, line: line, - controller.view + controller ).toEventually( haveValidSnapshot( - as: .wait( - for: initialDelay.seconds, - on: .image(size: size) - ), + as: .image(perceptualPrecision: 0.98, size: size), named: "1", // Force each retry to end in `.1.png` file: file, line: line @@ -92,8 +81,7 @@ extension SwiftUI.View { #endif private let timeout: DispatchTimeInterval = .seconds(5) -private let pollInterval: DispatchTimeInterval = .milliseconds(300) -private let initialDelay: DispatchTimeInterval = .milliseconds(100) +private let pollInterval: DispatchTimeInterval = .milliseconds(100) // MARK: - Private @@ -132,47 +120,3 @@ private let outputFormatting: JSONEncoder.OutputFormatting = { return result }() - -// MARK: - SwiftUIContainerView - -#if !os(watchOS) && !os(macOS) -@available(iOS 13.0, macOS 10.15, tvOS 13.0, *) -@available(watchOS, unavailable) -private final class SwiftUIContainerView: UIView { - - private let controller: UIHostingController - - init(container: UIViewController, view: V, size: CGSize) { - self.controller = UIHostingController(rootView: view) - self.controller.view.backgroundColor = nil - - super.init(frame: .init(origin: .zero, size: size)) - - container.addChild(self.controller) - self.addSubview(self.controller.view) - self.controller.didMove(toParent: container) - } - - @available(*, unavailable) - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - override func layoutSubviews() { - super.layoutSubviews() - - self.controller.view.frame = self.bounds - } - -} - -@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.2, *) -private extension SwiftUI.View { - - func asUIView(container: UIViewController, size: CGSize) -> SwiftUIContainerView { - return SwiftUIContainerView(container: container, view: self, size: size) - } - -} - -#endif diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 3752c58317..9565d7cc34 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -183,6 +183,10 @@ platform :ios do scheme: 'RevenueCatUI', destination: "platform=iOS Simulator,name=" + (ENV['SCAN_DEVICE'] || "iPhone 14,OS=16.4"), sdk: 'iphonesimulator', + output_style: :basic, + result_bundle_path: 'fastlane/test_output/revenuecatui.xcresult', + report_formats: [:junit], + report_path: 'fastlane/test_output/revenuecatui/tests.xml', test: true ) end