From 00ef0ceba250e853c6759cab56481b20a92dd880 Mon Sep 17 00:00:00 2001 From: Neelam Sharma Date: Mon, 17 Feb 2025 14:20:25 +0100 Subject: [PATCH 1/3] Added identifiers ui elements --- AdyenComponents/PayTo/PayToComponent.swift | 51 +++++++++++++++++++ .../PayTo/PayToComponentTests.swift | 48 +++++++++++++++++ 2 files changed, 99 insertions(+) diff --git a/AdyenComponents/PayTo/PayToComponent.swift b/AdyenComponents/PayTo/PayToComponent.swift index 79d48d0926..111253f860 100644 --- a/AdyenComponents/PayTo/PayToComponent.swift +++ b/AdyenComponents/PayTo/PayToComponent.swift @@ -19,6 +19,9 @@ public final class PayToComponent: PaymentComponent, static let identifierPickerItem = "identifierPicker" static let firstNameInputItem = "firstNameTextfield" static let lastNameInputItem = "lastNameTextfield" + static let emailInputItem = "emailTextfield" + static let abnInputItem = "abnTextfield" + static let organizationIDInputItem = "organizationIDTextfield" } private enum AccountIdentifiers: String, CustomStringConvertible, CaseIterable { @@ -131,6 +134,7 @@ public final class PayToComponent: PaymentComponent, scopeInstance: self, postfix: ViewIdentifier.phoneNumberItem ) + // TODO: Add translation item.title = localizedString(LocalizationKey(key: "Phone"), configuration.localizationParameters) item.placeholder = localizedString(LocalizationKey(key: "Mobile number"), configuration.localizationParameters) return item @@ -198,6 +202,45 @@ public final class PayToComponent: PaymentComponent, return item }() + /// The account holder email text input item. + internal lazy var emailInputItem: FormTextInputItem = { + let item = FormTextInputItem(style: configuration.style.textField) + // TODO: Add translation + item.title = localizedString(LocalizationKey(key: "Email"), configuration.localizationParameters) + item.placeholder = localizedString(LocalizationKey(key: "Email"), configuration.localizationParameters) + item.identifier = ViewIdentifierBuilder.build( + scopeInstance: self, + postfix: ViewIdentifier.emailInputItem + ) + return item + }() + + /// The account holder abn text input item. + internal lazy var abnInputItem: FormTextInputItem = { + let item = FormTextInputItem(style: configuration.style.textField) + // TODO: Add translation + item.title = localizedString(LocalizationKey(key: "ABN"), configuration.localizationParameters) + item.placeholder = localizedString(LocalizationKey(key: "ABN"), configuration.localizationParameters) + item.identifier = ViewIdentifierBuilder.build( + scopeInstance: self, + postfix: ViewIdentifier.abnInputItem + ) + return item + }() + + /// The account holder organization ID text input item. + internal lazy var organizationIDInputItem: FormTextInputItem = { + let item = FormTextInputItem(style: configuration.style.textField) + // TODO: Add translation + item.title = localizedString(LocalizationKey(key: "Organization ID"), configuration.localizationParameters) + item.placeholder = localizedString(LocalizationKey(key: "Organization ID"), configuration.localizationParameters) + item.identifier = ViewIdentifierBuilder.build( + scopeInstance: self, + postfix: ViewIdentifier.organizationIDInputItem + ) + return item + }() + private lazy var formViewController: FormViewController = { let formViewController = FormViewController( scrollEnabled: configuration.showsSubmitButton, @@ -233,6 +276,7 @@ public final class PayToComponent: PaymentComponent, // MARK: - Private private func appendItemsTo(formVC: FormViewController) { + dynamicContent(formVC) staticContent(formVC) } @@ -240,6 +284,13 @@ public final class PayToComponent: PaymentComponent, formVC.append(firstNameInputItem) formVC.append(lastNameInputItem) } + + private func dynamicContent(_ formVC: FormViewController) { + // TODO: Add bussiness logic to show/hide these + formVC.append(emailInputItem) + formVC.append(abnInputItem) + formVC.append(organizationIDInputItem) + } } @_spi(AdyenInternal) diff --git a/Tests/IntegrationTests/Components Tests/PayTo/PayToComponentTests.swift b/Tests/IntegrationTests/Components Tests/PayTo/PayToComponentTests.swift index a25bd6a09b..5e68be122f 100644 --- a/Tests/IntegrationTests/Components Tests/PayTo/PayToComponentTests.swift +++ b/Tests/IntegrationTests/Components Tests/PayTo/PayToComponentTests.swift @@ -141,4 +141,52 @@ class PayToComponentTests: XCTestCase { XCTAssertNotNil(lastNameInputItem, "last name input field should exist") } + func test_email_textfield_exists() throws { + // Given + let sut = try PayToComponent( + paymentMethod: AdyenCoder.decode(payto), + context: Dummy.context + ) + + sut.viewController.loadViewIfNeeded() + + // Check by accessibility identifier + let emailInputItem: FormTextInputItemView = try XCTUnwrap(sut.viewController.view.findView(with: "AdyenComponents.PayToComponent.emailTextfield")) + + // Then + XCTAssertNotNil(emailInputItem, "email input field should exist") + } + + func test_abn_textfield_exists() throws { + // Given + let sut = try PayToComponent( + paymentMethod: AdyenCoder.decode(payto), + context: Dummy.context + ) + + sut.viewController.loadViewIfNeeded() + + // Check by accessibility identifier + let abnInputItem: FormTextInputItemView = try XCTUnwrap(sut.viewController.view.findView(with: "AdyenComponents.PayToComponent.abnTextfield")) + + // Then + XCTAssertNotNil(abnInputItem, "abn input field should exist") + } + + func test_organizationID_textfield_exists() throws { + // Given + let sut = try PayToComponent( + paymentMethod: AdyenCoder.decode(payto), + context: Dummy.context + ) + + sut.viewController.loadViewIfNeeded() + + // Check by accessibility identifier + let organizationIDInputItem: FormTextInputItemView = try XCTUnwrap(sut.viewController.view.findView(with: "AdyenComponents.PayToComponent.organizationIDTextfield")) + + // Then + XCTAssertNotNil(organizationIDInputItem, "organizationID input field should exist") + } + } From 798d257a4c5e59e28057f749bff439bfb8a96692 Mon Sep 17 00:00:00 2001 From: Neelam Sharma Date: Mon, 17 Feb 2025 14:27:11 +0100 Subject: [PATCH 2/3] Fixed type --- AdyenComponents/PayTo/PayToComponent.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AdyenComponents/PayTo/PayToComponent.swift b/AdyenComponents/PayTo/PayToComponent.swift index 111253f860..0ef6e3c811 100644 --- a/AdyenComponents/PayTo/PayToComponent.swift +++ b/AdyenComponents/PayTo/PayToComponent.swift @@ -286,7 +286,7 @@ public final class PayToComponent: PaymentComponent, } private func dynamicContent(_ formVC: FormViewController) { - // TODO: Add bussiness logic to show/hide these + // TODO: Add business logic to show/hide these formVC.append(emailInputItem) formVC.append(abnInputItem) formVC.append(organizationIDInputItem) From a21f0fcf7b15d314c0865308b2c05dc8b86fe6e7 Mon Sep 17 00:00:00 2001 From: Neelam Sharma Date: Mon, 17 Feb 2025 14:37:09 +0100 Subject: [PATCH 3/3] renamed method and add email localised key --- AdyenComponents/PayTo/PayToComponent.swift | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/AdyenComponents/PayTo/PayToComponent.swift b/AdyenComponents/PayTo/PayToComponent.swift index 0ef6e3c811..874205d8e4 100644 --- a/AdyenComponents/PayTo/PayToComponent.swift +++ b/AdyenComponents/PayTo/PayToComponent.swift @@ -206,8 +206,8 @@ public final class PayToComponent: PaymentComponent, internal lazy var emailInputItem: FormTextInputItem = { let item = FormTextInputItem(style: configuration.style.textField) // TODO: Add translation - item.title = localizedString(LocalizationKey(key: "Email"), configuration.localizationParameters) - item.placeholder = localizedString(LocalizationKey(key: "Email"), configuration.localizationParameters) + item.title = localizedString(.emailItemTitle, configuration.localizationParameters) + item.placeholder = localizedString(.emailItemPlaceHolder, configuration.localizationParameters) item.identifier = ViewIdentifierBuilder.build( scopeInstance: self, postfix: ViewIdentifier.emailInputItem @@ -263,7 +263,7 @@ public final class PayToComponent: PaymentComponent, formViewController.append(phoneNumberItem) - appendItemsTo(formVC: formViewController) + appendItems(to: formViewController) if configuration.showsSubmitButton { formViewController.append(FormSpacerItem(numberOfSpaces: 2)) @@ -275,21 +275,21 @@ public final class PayToComponent: PaymentComponent, // MARK: - Private - private func appendItemsTo(formVC: FormViewController) { - dynamicContent(formVC) - staticContent(formVC) + private func appendItems(to formViewController: FormViewController) { + addDynamicContent(to: formViewController) + addStaticContent(to: formViewController) } - private func staticContent(_ formVC: FormViewController) { - formVC.append(firstNameInputItem) - formVC.append(lastNameInputItem) + private func addStaticContent(to formViewController: FormViewController) { + formViewController.append(firstNameInputItem) + formViewController.append(lastNameInputItem) } - private func dynamicContent(_ formVC: FormViewController) { + private func addDynamicContent(to formViewController: FormViewController) { // TODO: Add business logic to show/hide these - formVC.append(emailInputItem) - formVC.append(abnInputItem) - formVC.append(organizationIDInputItem) + formViewController.append(emailInputItem) + formViewController.append(abnInputItem) + formViewController.append(organizationIDInputItem) } }