diff --git a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Internal/StorefrontAPI/StorefrontAPIMutationsTests.swift b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Internal/StorefrontAPI/StorefrontAPIMutationsTests.swift index 6cd2d3e4..7ee4a043 100644 --- a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Internal/StorefrontAPI/StorefrontAPIMutationsTests.swift +++ b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Internal/StorefrontAPI/StorefrontAPIMutationsTests.swift @@ -66,11 +66,11 @@ final class StorefrontAPIMutationsTests: XCTestCase { // MARK: - Mock URLProtocol for Network Mocking class MockURLProtocol: URLProtocol { - static var mockResponseData: Data? - static var mockError: Error? - static var mockStatusCode: Int = 200 - static var capturedRequest: URLRequest? - static var capturedRequestBody: Data? + nonisolated(unsafe) static var mockResponseData: Data? + nonisolated(unsafe) static var mockError: Error? + nonisolated(unsafe) static var mockStatusCode: Int = 200 + nonisolated(unsafe) static var capturedRequest: URLRequest? + nonisolated(unsafe) static var capturedRequestBody: Data? override class func canInit(with _: URLRequest) -> Bool { return true diff --git a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Internal/StorefrontAPI/StorefrontAPIQueriesTests.swift b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Internal/StorefrontAPI/StorefrontAPIQueriesTests.swift index dee78621..ca3569bc 100644 --- a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Internal/StorefrontAPI/StorefrontAPIQueriesTests.swift +++ b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Internal/StorefrontAPI/StorefrontAPIQueriesTests.swift @@ -29,11 +29,11 @@ final class StorefrontAPIQueriesTests: XCTestCase { // MARK: - Mock URLProtocol for Network Mocking class MockURLProtocol: URLProtocol { - static var mockResponseData: Data? - static var mockError: Error? - static var mockStatusCode: Int = 200 - static var capturedRequest: URLRequest? - static var capturedRequestBody: Data? + nonisolated(unsafe) static var mockResponseData: Data? + nonisolated(unsafe) static var mockError: Error? + nonisolated(unsafe) static var mockStatusCode: Int = 200 + nonisolated(unsafe) static var capturedRequest: URLRequest? + nonisolated(unsafe) static var capturedRequestBody: Data? override class func canInit(with _: URLRequest) -> Bool { return true diff --git a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/TestHelpers.swift b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/TestHelpers.swift index 1dc688ae..6cd9cfed 100644 --- a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/TestHelpers.swift +++ b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/TestHelpers.swift @@ -29,6 +29,7 @@ import XCTest // MARK: - Configuration Helpers +@MainActor func XCTAssertThrowsErrorAsync( _ expression: @autoclosure () async throws -> some Any, _ errorHandler: (Error) -> Void, @@ -298,7 +299,7 @@ extension StorefrontAPI.Cart { /// This class conforms to StorefrontAPIProtocol with not implemented errors /// Extend this class and override only the methods you need, per test file @available(iOS 16.0, *) -class MockStorefrontAPI: StorefrontAPIProtocol { +class MockStorefrontAPI: @unchecked Sendable, StorefrontAPIProtocol { func cart(by _: GraphQLScalars.ID) async throws -> StorefrontAPI.Cart? { fatalError("cart(by:) not implemented in test. Override this method in your test class.") } @@ -383,7 +384,7 @@ class MockStorefrontAPI: StorefrontAPIProtocol { // MARK: - Test StorefrontAPI @available(iOS 16.0, *) -class TestStorefrontAPI: MockStorefrontAPI { +class TestStorefrontAPI: MockStorefrontAPI, @unchecked Sendable { var cartResult: Result? override func cart(by _: GraphQLScalars.ID) async throws -> StorefrontAPI.Cart? { diff --git a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/AcceleratedCheckoutButtonsRenderStateTests.swift b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/AcceleratedCheckoutButtonsRenderStateTests.swift index 8ca19ac2..adf3ac56 100644 --- a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/AcceleratedCheckoutButtonsRenderStateTests.swift +++ b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/AcceleratedCheckoutButtonsRenderStateTests.swift @@ -26,6 +26,7 @@ import SwiftUI import XCTest @available(iOS 17.0, *) +@MainActor final class AcceleratedCheckoutButtonsRenderStateTests: XCTestCase { // MARK: - Render State Change Callback Tests diff --git a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayAuthorizationDelegate/ApplePayAuthorizationDelegateControllerTests.swift b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayAuthorizationDelegate/ApplePayAuthorizationDelegateControllerTests.swift index b8e89f4c..5f1f7e75 100644 --- a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayAuthorizationDelegate/ApplePayAuthorizationDelegateControllerTests.swift +++ b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayAuthorizationDelegate/ApplePayAuthorizationDelegateControllerTests.swift @@ -635,12 +635,12 @@ final class ApplePayAuthorizationDelegateControllerTests: XCTestCase { "\"cost\":{\"totalAmount\":{\"amount\":\"0.00\",\"currencyCode\":\"USD\"}}," + "\"discountCodes\":[],\"discountAllocations\":[]}" - static var failReplace = false - static var failDeliveryUpdate = false - static var failPrepareForCompletion = false - static var returnMappableCartUserError = false - static var returnInvalidCart = false - static var lastOperation: String? + nonisolated(unsafe) static var failReplace = false + nonisolated(unsafe) static var failDeliveryUpdate = false + nonisolated(unsafe) static var failPrepareForCompletion = false + nonisolated(unsafe) static var returnMappableCartUserError = false + nonisolated(unsafe) static var returnInvalidCart = false + nonisolated(unsafe) static var lastOperation: String? static func response(for op: String) -> Data { if op == "cartPrepareForCompletion" { diff --git a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayCallbackTests.swift b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayCallbackTests.swift index 99f1bf26..17d4a247 100644 --- a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayCallbackTests.swift +++ b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayCallbackTests.swift @@ -26,6 +26,7 @@ import XCTest @available(iOS 17.0, *) +@MainActor final class ApplePayCallbackTests: XCTestCase { // MARK: - Properties @@ -37,8 +38,8 @@ final class ApplePayCallbackTests: XCTestCase { // MARK: - Setup - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() // Create mock configuration let commonConfig = ShopifyAcceleratedCheckouts.Configuration( @@ -75,13 +76,13 @@ final class ApplePayCallbackTests: XCTestCase { ) } - override func tearDown() { + override func tearDown() async throws { viewController = nil mockConfiguration = nil mockIdentifier = nil errorExpectation = nil cancelExpectation = nil - super.tearDown() + try await super.tearDown() } // MARK: - Error Callback Tests diff --git a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayIntegrationTests.swift b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayIntegrationTests.swift index 7adec063..0000e308 100644 --- a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayIntegrationTests.swift +++ b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayIntegrationTests.swift @@ -27,6 +27,7 @@ import SwiftUI import XCTest @available(iOS 17.0, *) +@MainActor final class ApplePayIntegrationTests: XCTestCase { // MARK: - Properties @@ -37,8 +38,8 @@ final class ApplePayIntegrationTests: XCTestCase { // MARK: - Setup - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() mockCommonConfiguration = ShopifyAcceleratedCheckouts.Configuration( storefrontDomain: "test-shop.myshopify.com", @@ -69,12 +70,12 @@ final class ApplePayIntegrationTests: XCTestCase { ) } - override func tearDown() { + override func tearDown() async throws { mockConfiguration = nil mockCommonConfiguration = nil mockApplePayConfiguration = nil mockShopSettings = nil - super.tearDown() + try await super.tearDown() } // MARK: - Integration Tests @@ -152,7 +153,7 @@ final class ApplePayIntegrationTests: XCTestCase { failCount += 1 } - let button = await ApplePayButton( + let button = ApplePayButton( identifier: .cart(cartID: "gid://Shopify/Cart/test-cart"), eventHandlers: EventHandlers(checkoutDidFail: failHandler), cornerRadius: nil diff --git a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayViewControllerTests.swift b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayViewControllerTests.swift index 1601a968..c7d5bab3 100644 --- a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayViewControllerTests.swift +++ b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayViewControllerTests.swift @@ -27,14 +27,15 @@ import UIKit import XCTest @available(iOS 17.0, *) +@MainActor class ApplePayViewControllerTests: XCTestCase { var viewController: MockApplePayViewController! var mockConfiguration: ApplePayConfigurationWrapper! var mockStorefront: TestStorefrontAPI! var mockAuthorizationDelegate: MockApplePayAuthorizationDelegate! - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() // Create mock shop settings let paymentSettings = PaymentSettings( @@ -91,12 +92,12 @@ class ApplePayViewControllerTests: XCTestCase { viewController.setMockAuthorizationDelegate(mockAuthorizationDelegate) } - override func tearDown() { + override func tearDown() async throws { viewController = nil mockConfiguration = nil mockStorefront = nil mockAuthorizationDelegate = nil - super.tearDown() + try await super.tearDown() } class MockApplePayAuthorizationDelegate: ApplePayAuthorizationDelegate { diff --git a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayViewModifierTests.swift b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayViewModifierTests.swift index d720d13a..5a431312 100644 --- a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayViewModifierTests.swift +++ b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ApplePay/ApplePayViewModifierTests.swift @@ -27,6 +27,7 @@ import SwiftUI import XCTest @available(iOS 17.0, *) +@MainActor final class ApplePayViewModifierTests: XCTestCase { // MARK: - Properties @@ -36,8 +37,8 @@ final class ApplePayViewModifierTests: XCTestCase { // MARK: - Setup - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() mockConfiguration = ShopifyAcceleratedCheckouts.Configuration( storefrontDomain: "test-shop.myshopify.com", @@ -59,11 +60,11 @@ final class ApplePayViewModifierTests: XCTestCase { ) } - override func tearDown() { + override func tearDown() async throws { mockConfiguration = nil mockApplePayConfiguration = nil mockShopSettings = nil - super.tearDown() + try await super.tearDown() } // MARK: - onCancel Modifier Tests diff --git a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ShopPay/ShopPayButtonTests.swift b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ShopPay/ShopPayButtonTests.swift index c24355de..dd9e1cc9 100644 --- a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ShopPay/ShopPayButtonTests.swift +++ b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ShopPay/ShopPayButtonTests.swift @@ -27,6 +27,7 @@ import ViewInspector import XCTest @available(iOS 17.0, *) +@MainActor class ShopPayButtonTests: XCTestCase { // MARK: - Test Setup diff --git a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ShopPay/ShopPayCallbackTests.swift b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ShopPay/ShopPayCallbackTests.swift index de681f07..cff41b12 100644 --- a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ShopPay/ShopPayCallbackTests.swift +++ b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ShopPay/ShopPayCallbackTests.swift @@ -26,6 +26,7 @@ import XCTest @available(iOS 17.0, *) +@MainActor final class ShopPayCallbackTests: XCTestCase { // MARK: - Properties @@ -37,8 +38,8 @@ final class ShopPayCallbackTests: XCTestCase { // MARK: - Setup - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() mockConfiguration = ShopifyAcceleratedCheckouts.Configuration( storefrontDomain: "test-shop.myshopify.com", @@ -53,13 +54,13 @@ final class ShopPayCallbackTests: XCTestCase { ) } - override func tearDown() { + override func tearDown() async throws { viewController = nil mockConfiguration = nil mockIdentifier = nil errorExpectation = nil cancelExpectation = nil - super.tearDown() + try await super.tearDown() } // MARK: - Error Callback Tests diff --git a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ShopPay/ShopPayViewControllerTests.swift b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ShopPay/ShopPayViewControllerTests.swift index 4eadfaa3..18966844 100644 --- a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ShopPay/ShopPayViewControllerTests.swift +++ b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/ShopPay/ShopPayViewControllerTests.swift @@ -26,15 +26,14 @@ import ShopifyCheckoutKit import XCTest @available(iOS 16.0, *) - -@available(iOS 16.0, *) +@MainActor final class ShopPayViewControllerTests: XCTestCase { var viewController: MockShopPayViewController! var mockConfiguration: ShopifyAcceleratedCheckouts.Configuration! var mockStorefront: TestStorefrontAPI! - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() mockConfiguration = ShopifyAcceleratedCheckouts.Configuration( storefrontDomain: "test-shop.myshopify.com", @@ -43,11 +42,11 @@ final class ShopPayViewControllerTests: XCTestCase { mockStorefront = TestStorefrontAPI() } - override func tearDown() { + override func tearDown() async throws { viewController = nil mockConfiguration = nil mockStorefront = nil - super.tearDown() + try await super.tearDown() } @available(iOS 16.0, *) diff --git a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/WalletControllerTests.swift b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/WalletControllerTests.swift index 6f5b1d26..8bfc9b0d 100644 --- a/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/WalletControllerTests.swift +++ b/platforms/swift/Tests/ShopifyAcceleratedCheckoutsTests/Wallets/WalletControllerTests.swift @@ -27,18 +27,19 @@ import UIKit import XCTest @available(iOS 16.0, *) +@MainActor final class WalletControllerTests: XCTestCase { var mockStorefront: TestStorefrontAPI! var controller: MockWalletController! - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() mockStorefront = TestStorefrontAPI() } - override func tearDown() { + override func tearDown() async throws { mockStorefront = nil controller = nil - super.tearDown() + try await super.tearDown() } class MockWalletController: WalletController { diff --git a/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutBridgeTests.swift b/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutBridgeTests.swift index 4fea9013..08ecdc4f 100644 --- a/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutBridgeTests.swift +++ b/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutBridgeTests.swift @@ -25,6 +25,7 @@ import WebKit import XCTest +@MainActor class CheckoutBridgeTests: XCTestCase { func testReturnsStandardUserAgent() { let version = ShopifyCheckoutKit.version diff --git a/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutViewControllerTests.swift b/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutViewControllerTests.swift index 9dad35c9..a63fa411 100644 --- a/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutViewControllerTests.swift +++ b/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutViewControllerTests.swift @@ -25,13 +25,16 @@ import WebKit import XCTest +@MainActor class CheckoutViewDelegateTests: XCTestCase { private var customTitle: String? private let checkoutURL = URL(string: "https://checkout-sdk.myshopify.com")! private var viewController: MockCheckoutWebViewController! private var navigationController: UINavigationController! - override func setUp() { + override func setUp() async throws { + try await super.setUp() + CheckoutWebView.invalidate() ShopifyCheckoutKit.configure { $0.preloading.enabled = true $0.title = customTitle ?? "Checkout" @@ -43,9 +46,10 @@ class CheckoutViewDelegateTests: XCTestCase { navigationController = UINavigationController(rootViewController: viewController) } - override func tearDown() { + override func tearDown() async throws { + CheckoutWebView.invalidate() customTitle = nil - super.tearDown() + try await super.tearDown() } func testTitleIsSetToCheckout() { @@ -54,7 +58,10 @@ class CheckoutViewDelegateTests: XCTestCase { func testTitleCanBeCustomized() { customTitle = "Custom title" - setUp() + ShopifyCheckoutKit.configure { $0.title = customTitle ?? "Checkout" } + viewController = MockCheckoutWebViewController( + checkoutURL: checkoutURL + ) XCTAssertEqual(viewController.title, "Custom title") } @@ -207,6 +214,7 @@ class CheckoutViewDelegateTests: XCTestCase { } } +@MainActor protocol Dismissible: AnyObject { func dismiss(animated flag: Bool, completion: (() -> Void)?) } diff --git a/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutWebViewControllerTests.swift b/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutWebViewControllerTests.swift index c6bdb4c6..1f87cbc2 100644 --- a/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutWebViewControllerTests.swift +++ b/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutWebViewControllerTests.swift @@ -43,6 +43,7 @@ class TestableCheckoutWebViewController: CheckoutWebViewController { } } +@MainActor class CheckoutWebViewControllerTests: XCTestCase { private let url = URL(string: "http://shopify1.shopify.com/checkouts/cn/123")! private let multipassURL = URL(string: "http://shopify1.shopify.com/checkouts/cn/123?multipass=token")! diff --git a/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutWebViewTests.swift b/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutWebViewTests.swift index 5c3ef62d..997b8fcf 100644 --- a/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutWebViewTests.swift +++ b/platforms/swift/Tests/ShopifyCheckoutKitTests/CheckoutWebViewTests.swift @@ -26,13 +26,15 @@ import ShopifyCheckoutProtocol import WebKit import XCTest +@MainActor class CheckoutWebViewTests: XCTestCase { private var view: CheckoutWebView! private var recovery: CheckoutWebView! private var mockDelegate: MockCheckoutWebViewDelegate! private var url = URL(string: "http://shopify1.shopify.com/checkouts/cn/123")! - override func setUp() { + override func setUp() async throws { + try await super.setUp() ShopifyCheckoutKit.configure { $0.preloading.enabled = true } view = CheckoutWebView.for(checkout: url) mockDelegate = MockCheckoutWebViewDelegate() @@ -365,7 +367,7 @@ class CheckoutWebViewTests: XCTestCase { func testDoesNotInstrumentPreloadingTagIfDisabled() throws { let webView = LoadedRequestObservableWebView() - ShopifyCheckoutKit.configuration.preloading.enabled = false + ShopifyCheckoutKit.configure { $0.preloading.enabled = false } try webView.load( checkout: XCTUnwrap(URL(string: "https://checkout-sdk.myshopify.io")), @@ -379,7 +381,7 @@ class CheckoutWebViewTests: XCTestCase { } func testDetachBridgeCalledOnInit() throws { - ShopifyCheckoutKit.configuration.preloading.enabled = false + ShopifyCheckoutKit.configure { $0.preloading.enabled = false } let url = URL(string: "http://shopify1.shopify.com/checkouts/cn/123") let view = try CheckoutWebView.for(checkout: XCTUnwrap(url)) XCTAssertTrue(view.isBridgeAttached) @@ -389,7 +391,7 @@ class CheckoutWebViewTests: XCTestCase { } func testCacheIsClearedOnInvalidate() throws { - ShopifyCheckoutKit.configuration.preloading.enabled = true + ShopifyCheckoutKit.configure { $0.preloading.enabled = true } let url = URL(string: "http://shopify1.shopify.com/checkouts/cn/123") let view = try CheckoutWebView.for(checkout: XCTUnwrap(url)) XCTAssertTrue(view.isBridgeAttached) diff --git a/platforms/swift/Tests/ShopifyCheckoutKitTests/ConfigurationTests.swift b/platforms/swift/Tests/ShopifyCheckoutKitTests/ConfigurationTests.swift index 4e911619..b2ffac27 100644 --- a/platforms/swift/Tests/ShopifyCheckoutKitTests/ConfigurationTests.swift +++ b/platforms/swift/Tests/ShopifyCheckoutKitTests/ConfigurationTests.swift @@ -25,15 +25,16 @@ import UIKit import XCTest +@MainActor class ConfigurationTests: XCTestCase { - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() resetConfigurationState() } - override func tearDown() { + override func tearDown() async throws { resetConfigurationState() - super.tearDown() + try await super.tearDown() } private func resetConfigurationState() { diff --git a/platforms/swift/Tests/ShopifyCheckoutKitTests/LoggerTests.swift b/platforms/swift/Tests/ShopifyCheckoutKitTests/LoggerTests.swift index f902ff3e..b55c7396 100644 --- a/platforms/swift/Tests/ShopifyCheckoutKitTests/LoggerTests.swift +++ b/platforms/swift/Tests/ShopifyCheckoutKitTests/LoggerTests.swift @@ -25,7 +25,7 @@ import os.log @testable import ShopifyCheckoutKit import XCTest -class TestableOSLogger: OSLogger { +class TestableOSLogger: OSLogger, @unchecked Sendable { private(set) var capturedMessages: [(message: String, type: OSLogType)] = [] private let testPrefix: String override init() { @@ -43,17 +43,18 @@ class TestableOSLogger: OSLogger { } } +@MainActor final class OSLoggerTests: XCTestCase { var originalConfiguration: Configuration! - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() originalConfiguration = ShopifyCheckoutKit.configuration } - override func tearDown() { + override func tearDown() async throws { ShopifyCheckoutKit.setConfiguration(originalConfiguration) - super.tearDown() + try await super.tearDown() } func test_sharedLogger_whenAccessed_shouldExist() { diff --git a/platforms/swift/Tests/ShopifyCheckoutKitTests/ShopifyCheckoutKitTests.swift b/platforms/swift/Tests/ShopifyCheckoutKitTests/ShopifyCheckoutKitTests.swift index 256ce287..68a0307d 100644 --- a/platforms/swift/Tests/ShopifyCheckoutKitTests/ShopifyCheckoutKitTests.swift +++ b/platforms/swift/Tests/ShopifyCheckoutKitTests/ShopifyCheckoutKitTests.swift @@ -24,6 +24,7 @@ @testable import ShopifyCheckoutKit import XCTest +@MainActor class ShopifyCheckoutKitTests: XCTestCase { func test_version_whenAccessed_shouldExist() { XCTAssertFalse(ShopifyCheckoutKit.version.isEmpty) diff --git a/platforms/swift/Tests/ShopifyCheckoutKitTests/SwiftUITests.swift b/platforms/swift/Tests/ShopifyCheckoutKitTests/SwiftUITests.swift index cf110383..1ea1e78b 100644 --- a/platforms/swift/Tests/ShopifyCheckoutKitTests/SwiftUITests.swift +++ b/platforms/swift/Tests/ShopifyCheckoutKitTests/SwiftUITests.swift @@ -24,12 +24,13 @@ @testable import ShopifyCheckoutKit import XCTest +@MainActor class CheckoutViewControllerTests: XCTestCase { var checkoutURL: URL! var checkoutViewController: CheckoutViewController! - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() checkoutURL = URL(string: "https://www.shopify.com") checkoutViewController = CheckoutViewController(checkout: checkoutURL) } @@ -39,12 +40,13 @@ class CheckoutViewControllerTests: XCTestCase { } } +@MainActor class CheckoutSheetTests: XCTestCase { var checkoutURL: URL! var checkoutSheet: CheckoutSheet! - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() checkoutURL = URL(string: "https://www.shopify.com") checkoutSheet = CheckoutSheet(checkout: checkoutURL) } @@ -81,12 +83,13 @@ class CheckoutSheetTests: XCTestCase { } } +@MainActor class CheckoutConfigurableTests: XCTestCase { var checkoutURL: URL! var checkoutSheet: CheckoutSheet! - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() checkoutURL = URL(string: "https://www.shopify.com") checkoutSheet = CheckoutSheet(checkout: checkoutURL) }