From 5f4fdcf5424f25c292c37ccb6e5bb53f1f12579b Mon Sep 17 00:00:00 2001 From: erenbesel Date: Wed, 15 Jan 2025 11:17:53 +0100 Subject: [PATCH 1/2] correctly track apple pay component --- AdyenComponents/Apple Pay/ApplePayComponent.swift | 7 +++---- .../Apple Pay/ApplePayComponentTests.swift | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/AdyenComponents/Apple Pay/ApplePayComponent.swift b/AdyenComponents/Apple Pay/ApplePayComponent.swift index 4e5ee2a3a4..2047492eed 100644 --- a/AdyenComponents/Apple Pay/ApplePayComponent.swift +++ b/AdyenComponents/Apple Pay/ApplePayComponent.swift @@ -78,10 +78,12 @@ public class ApplePayComponent: NSObject, PresentableComponent, PaymentComponent super.init() paymentAuthorizationViewController?.delegate = self + sendInitialAnalytics() } public var viewController: UIViewController { - createPaymentAuthorizationViewController() + sendDidLoadEvent() + return createPaymentAuthorizationViewController() } public func didFinalize(with success: Bool, completion: (() -> Void)?) { @@ -130,6 +132,3 @@ extension ApplePayComponent { @_spi(AdyenInternal) extension ApplePayComponent: TrackableComponent {} - -@_spi(AdyenInternal) -extension ApplePayComponent: ViewControllerDelegate {} diff --git a/Tests/IntegrationTests/Components Tests/Apple Pay/ApplePayComponentTests.swift b/Tests/IntegrationTests/Components Tests/Apple Pay/ApplePayComponentTests.swift index e45be0ba81..60a723cec8 100644 --- a/Tests/IntegrationTests/Components Tests/Apple Pay/ApplePayComponentTests.swift +++ b/Tests/IntegrationTests/Components Tests/Apple Pay/ApplePayComponentTests.swift @@ -424,7 +424,7 @@ class ApplePayComponentTest: XCTestCase { ) // When - sut.viewDidLoad(viewController: mockViewController) + setupRootViewController(sut.viewController) // Then XCTAssertEqual(analyticsProviderMock.initialEventCallsCount, 1) From 8185ea7f356cf08f962cd7a337782fa18fa6365c Mon Sep 17 00:00:00 2001 From: erenbesel Date: Wed, 15 Jan 2025 11:31:18 +0100 Subject: [PATCH 2/2] use loadViewIfNeeded instead of setupRoot for SUT --- .../Components Tests/Apple Pay/ApplePayComponentTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/IntegrationTests/Components Tests/Apple Pay/ApplePayComponentTests.swift b/Tests/IntegrationTests/Components Tests/Apple Pay/ApplePayComponentTests.swift index 60a723cec8..33212e3c15 100644 --- a/Tests/IntegrationTests/Components Tests/Apple Pay/ApplePayComponentTests.swift +++ b/Tests/IntegrationTests/Components Tests/Apple Pay/ApplePayComponentTests.swift @@ -424,7 +424,7 @@ class ApplePayComponentTest: XCTestCase { ) // When - setupRootViewController(sut.viewController) + sut.viewController.loadViewIfNeeded() // Then XCTAssertEqual(analyticsProviderMock.initialEventCallsCount, 1)