Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into DEV-64080/Intermed…
Browse files Browse the repository at this point in the history
…iate-DA-feature
  • Loading branch information
robertdalmeida committed Jan 19, 2024
2 parents df1f1d7 + d624902 commit 1d7b22d
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 17 deletions.
1 change: 1 addition & 0 deletions AdyenComponents/Apple Pay/ApplePayConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ extension ApplePayComponent {
throw ApplePayComponent.Error.emptyMerchantIdentifier
}
self.paymentRequest = paymentRequest
self.allowOnboarding = allowOnboarding

self.merchantIdentifier = paymentRequest.merchantIdentifier
self.applePayPayment = try ApplePayPayment(countryCode: paymentRequest.countryCode,
Expand Down
24 changes: 17 additions & 7 deletions Tests/Card Tests/CardComponentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,18 @@ class CardComponentTests: XCTestCase {
}

func testTintColorCustomization() throws {
guard #available(iOS 17.0, *) else {
throw XCTSkip("This test is unfortunately very flaky on macos-12 runners that are needed to test on older iOS versions - so we skip it")
}

var configuration = CardComponent.Configuration()

let tintColor: UIColor = .black
let titleColor: UIColor = .gray

configuration.style = {
var style = FormComponentStyle(tintColor: .systemYellow)
style.textField.title.color = .gray
var style = FormComponentStyle(tintColor: tintColor)
style.textField.title.color = titleColor
return style
}()

Expand All @@ -425,13 +431,16 @@ class CardComponentTests: XCTestCase {
let switchView: UISwitch = try XCTUnwrap(component.viewController.view.findView(with: "AdyenCard.CardComponent.storeDetailsItem.switch"))
let securityCodeItemView: FormTextItemView<FormCardSecurityCodeItem> = try XCTUnwrap(component.viewController.view.findView(with: "AdyenCard.CardComponent.securityCodeItem"))

XCTAssertEqual(securityCodeItemView.titleLabel.textColor, .gray)
wait(until: switchView, at: \.onTintColor, is: tintColor)

wait(until: securityCodeItemView, at: \.titleLabel.textColor, is: titleColor)

self.focus(textItemView: securityCodeItemView)
try withoutAnimation {
focus(textItemView: securityCodeItemView)
}

wait(until: switchView, at: \.onTintColor, is: .systemYellow)
wait(until: securityCodeItemView, at: \.titleLabel.textColor, is: .systemYellow)
wait(until: securityCodeItemView, at: \.separatorView.backgroundColor?.cgColor, is: UIColor.systemYellow.cgColor)
wait(until: securityCodeItemView, at: \.titleLabel.textColor, is: tintColor)
wait(until: securityCodeItemView, at: \.separatorView.backgroundColor, is: tintColor)
}

func testSuccessTintColorCustomization() throws {
Expand Down Expand Up @@ -2213,6 +2222,7 @@ class CardComponentTests: XCTestCase {

private func focus(textItemView: some FormTextItemView<some FormTextItem>) {
textItemView.textField.becomeFirstResponder()
wait(until: textItemView.textField, at: \.isFirstResponder, is: true)
}

private enum CardViewIdentifier {
Expand Down
9 changes: 4 additions & 5 deletions Tests/Card Tests/Utilities/ThrottlerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import XCTest
class ThrottlerTests: XCTestCase {

func test() {
let sut = Throttler(minimumDelay: 1)
let sut = Throttler(minimumDelay: 0.3)

let lastBlockExpectation = expectation(description: "wait for last block execution")

Expand All @@ -29,12 +29,11 @@ class ThrottlerTests: XCTestCase {
}
}

wait(for: .milliseconds(100))
wait(for: .milliseconds(5))
}

waitForExpectations(timeout: 100, handler: nil)

XCTAssertEqual(counter, 1)
wait(for: [lastBlockExpectation], timeout: 100)
XCTAssertEqual(counter, 1) // Making sure the code was only executed once
}

}
17 changes: 14 additions & 3 deletions Tests/Helpers/XCTestCase+RootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ extension DispatchTimeInterval {
extension XCTestCase {

enum TestAnimationSpeed: Float {
case paused = 0
case system = 1
case fast = 100
}
Expand All @@ -74,9 +73,21 @@ extension XCTestCase {
///
/// After the block the animation speed gets reset to the previous speed
func withAnimation(_ speed: TestAnimationSpeed, block: () throws -> Void) throws {
let speedBefore = UIApplication.shared.adyen.mainKeyWindow?.layer.speed ?? 1
let previousLayerSpeed = UIApplication.shared.adyen.mainKeyWindow?.layer.speed ?? 1

UIApplication.shared.adyen.mainKeyWindow?.layer.speed = speed.rawValue
try block()
UIApplication.shared.adyen.mainKeyWindow?.layer.speed = speedBefore
UIApplication.shared.adyen.mainKeyWindow?.layer.speed = previousLayerSpeed
}

/// Executes a block with UIView animations disabled
///
/// After the block the animation speed gets reset to the previous value
func withoutAnimation(block: () throws -> Void) throws {
let wereAnimationsEnabled = UIView.areAnimationsEnabled

UIView.setAnimationsEnabled(false)
try block()
UIView.setAnimationsEnabled(wereAnimationsEnabled)
}
}
2 changes: 1 addition & 1 deletion UITests/Components/BLIK/BLIKComponentUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ final class BLIKComponentUITests: XCTestCase {

let submitButton: SubmitButton! = sut.viewController.view.findView(with: "AdyenComponents.BLIKComponent.payButtonItem.button")

try withAnimation(.paused) {
try withoutAnimation {
// start loading
submitButton.showsActivityIndicator = true
wait(until: submitButton, at: \.showsActivityIndicator, is: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class OnlineBankingComponentUITests: XCTestCase {
sut.viewController.view.findView(with: "AdyenComponents.OnlineBankingComponent.continueButton.button")
)

try withAnimation(.paused) {
try withoutAnimation {
// start loading
button.showsActivityIndicator = true
wait(until: button, at: \.showsActivityIndicator, is: true)
Expand Down

0 comments on commit 1d7b22d

Please sign in to comment.