Skip to content

Commit

Permalink
Added empty ui test class
Browse files Browse the repository at this point in the history
  • Loading branch information
neelSharma12 committed Feb 3, 2025
1 parent 1f61ddf commit 796533d
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Adyen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
000888742D4CF597009C03E1 /* PayToPaymentMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000888732D4CF58D009C03E1 /* PayToPaymentMethod.swift */; };
000888782D4CF5FC009C03E1 /* PayToComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000888772D4CF5F5009C03E1 /* PayToComponent.swift */; };
0008887C2D4CFA73009C03E1 /* PayToComponentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0008887A2D4CFA67009C03E1 /* PayToComponentTests.swift */; };
000888822D510414009C03E1 /* PayToComponentUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000888812D510412009C03E1 /* PayToComponentUITests.swift */; };
000888832D510414009C03E1 /* PayToComponentUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000888812D510412009C03E1 /* PayToComponentUITests.swift */; };
00165FE02C05DA8600347399 /* RedireactableAwaitAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00165FDF2C05DA8600347399 /* RedireactableAwaitAction.swift */; };
001BFF422A6E74BD007B2A46 /* DropInSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 001BFF412A6E74BD007B2A46 /* DropInSettingsView.swift */; };
001BFF432A6E74BD007B2A46 /* DropInSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 001BFF412A6E74BD007B2A46 /* DropInSettingsView.swift */; };
Expand Down Expand Up @@ -1501,6 +1503,7 @@
000888732D4CF58D009C03E1 /* PayToPaymentMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PayToPaymentMethod.swift; sourceTree = "<group>"; };
000888772D4CF5F5009C03E1 /* PayToComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PayToComponent.swift; sourceTree = "<group>"; };
0008887A2D4CFA67009C03E1 /* PayToComponentTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PayToComponentTests.swift; sourceTree = "<group>"; };
000888812D510412009C03E1 /* PayToComponentUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PayToComponentUITests.swift; sourceTree = "<group>"; };
00165FDF2C05DA8600347399 /* RedireactableAwaitAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedireactableAwaitAction.swift; sourceTree = "<group>"; };
001BFF412A6E74BD007B2A46 /* DropInSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropInSettingsView.swift; sourceTree = "<group>"; };
00220953299B885600B2BACD /* BLIKComponentUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BLIKComponentUITests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2805,6 +2808,7 @@
007D790B2812C81400382D31 /* AtomeComponentUITests.swift */,
007D791E2823A84C00382D31 /* AffirmComponentUITests.swift */,
814E15492C87407F00D90D4B /* CardComponentUITests.swift */,
000888812D510412009C03E1 /* PayToComponentUITests.swift */,
);
path = Components;
sourceTree = "<group>";
Expand Down Expand Up @@ -6741,6 +6745,7 @@
81DF94182BAAD8EB0001DCBC /* DummyPaymentMethods.swift in Sources */,
81DF94192BAAD8EB0001DCBC /* DokuComponentUITests.swift in Sources */,
81DF941A2BAAD8EB0001DCBC /* IssuerListComponentUITests.swift in Sources */,
000888832D510414009C03E1 /* PayToComponentUITests.swift in Sources */,
81DF941B2BAAD8EB0001DCBC /* AffirmComponentUITests.swift in Sources */,
81BE48362BB6D1BE003A51F6 /* String+UIImage.swift in Sources */,
81DF941C2BAAD8EB0001DCBC /* XCTestCase+FormAddressItem.swift in Sources */,
Expand Down Expand Up @@ -7835,6 +7840,7 @@
81825CC22AC59C6400F91912 /* XCTestCase+RootViewController.swift in Sources */,
F9CCA3D7296ECDB200AD643D /* XCTestCase+Coder.swift in Sources */,
F9CCA3C5296ECB9900AD643D /* ListViewControllerUITests.swift in Sources */,
000888822D510414009C03E1 /* PayToComponentUITests.swift in Sources */,
F9CCA3D3296ECD0700AD643D /* PostalAddressMocks.swift in Sources */,
817C90822C3D59B30072A202 /* PartialPaymentDelegateMock.swift in Sources */,
81FC2C992BB1BB69007F1316 /* URLProtocolMock.swift in Sources */,
Expand Down
85 changes: 84 additions & 1 deletion AdyenComponents/PayTo/PayToComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import UIKit
public final class PayToComponent: PaymentComponent,
PresentableComponent {

private enum ViewIdentifier {
static let flowSelectionTitleLabelItem = "flowSelectionTitleLabelItem"
static let flowSelectionItem = "flowSelectionSegmentedControlItem"
static let continueButtonItem = "continueButton"
}

/// Configuration for PayTo Component.
public typealias Configuration = BasicComponentConfiguration

Expand All @@ -30,7 +36,13 @@ public final class PayToComponent: PaymentComponent,
private let payToPaymentMethod: PayToPaymentMethod

/// The viewController for the component.
public lazy var viewController: UIViewController = .init()
public lazy var viewController: UIViewController = SecuredViewController(
child: formViewController,
style: configuration.style
)

/// This indicates that `viewController` expected to be presented modally,
public var requiresModalPresentation: Bool = true

/// Initializes the PayTo component.
///
Expand All @@ -46,4 +58,75 @@ public final class PayToComponent: PaymentComponent,
self.context = context
self.configuration = configuration
}

/// The payment flow selection title label item.
internal lazy var flowSelectionTitleLabelItem: FormLabelItem = {
let item = FormLabelItem(
text: "How would you like to use Payto?",
style: configuration.style.footnoteLabel
)
item.style.textAlignment = .left
item.identifier = ViewIdentifierBuilder.build(
scopeInstance: self,
postfix: ViewIdentifier.flowSelectionTitleLabelItem
)
return item
}()

/// The segment control item to choose the payTo flow.
internal lazy var flowSelectionItem: FormSegmentedControlItem = {
let item = FormSegmentedControlItem(
items: ["PayID", "BSB"],
style: configuration.style.segmentedControlStyle,
identifier: ViewIdentifierBuilder.build(
scopeInstance: self,
postfix: ViewIdentifier.flowSelectionItem
)
)
return item
}()

/// The continue button item.
internal lazy var continueButton: FormButtonItem = {
let item = FormButtonItem(style: configuration.style.mainButtonItem)
item.identifier = ViewIdentifierBuilder.build(
scopeInstance: self,
postfix: ViewIdentifier.continueButtonItem
)
item.title = localizedString(.continueTitle, configuration.localizationParameters)
item.buttonSelectionHandler = { [weak self] in
self?.didSelectContinueButton()
}
return item
}()

private lazy var formViewController: FormViewController = {
let formViewController = FormViewController(
scrollEnabled: configuration.showsSubmitButton,
style: configuration.style,
localizationParameters: configuration.localizationParameters
)
formViewController.title = paymentMethod.displayInformation(using: configuration.localizationParameters).title
formViewController.append(FormSpacerItem(numberOfSpaces: 1))
formViewController.append(flowSelectionTitleLabelItem.padding())
formViewController.append(FormSpacerItem(numberOfSpaces: 1))
formViewController.append(flowSelectionItem.padding())

if configuration.showsSubmitButton {
formViewController.append(FormSpacerItem(numberOfSpaces: 2))
formViewController.append(continueButton)
}

return formViewController
}()
}

// MARK: - Event Handling

extension PayToComponent {

private func didSelectContinueButton() {
// TODO: Implement
}

}
27 changes: 27 additions & 0 deletions Tests/SnapshotTests/Components/PayToComponentUITests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Copyright (c) 2025 Adyen N.V.
//
// This file is open source and available under the MIT license. See the LICENSE file for more info.
//

@_spi(AdyenInternal) @testable import Adyen
@testable import AdyenComponents
import AdyenDropIn
import XCTest

class PayToComponentUITests: XCTestCase {

private lazy var paymentMethod: PayToPaymentMethod = .init(
type: .payto,
name: "payto"
)
private var context: AdyenContext { Dummy.context }
private var style: FormComponentStyle { FormComponentStyle() }

override func setUpWithError() throws {
try super.setUpWithError()
BrowserInfo.cachedUserAgent = "some_value"
}

// TODO: Write tests when UI is complete
}

0 comments on commit 796533d

Please sign in to comment.