Skip to content

Commit

Permalink
Add snapshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tillh-stripe committed Dec 17, 2024
1 parent a66532f commit b085346
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2673,7 +2673,7 @@ extension PaymentSheetUITestCase {
// Reload and pay with the now-saved US bank account
reload(app, settings: settings)
app.buttons["Present PaymentSheet"].tap()
XCTAssertTrue(app.buttons["••••6789"].waitForExistenceAndTap())
XCTAssertTrue(app.buttons["•••• 6789"].waitForExistenceAndTap())

// Make sure bottom notice mandate is visible
XCTAssertTrue(app.textViews["By continuing, you agree to authorize payments pursuant to these terms."].exists)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@
CB225E962CEF80DC00054262 /* PaymentMethodTypeCollectionViewCellSnapshotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB225E952CEF80DC00054262 /* PaymentMethodTypeCollectionViewCellSnapshotTests.swift */; };
CB46EF492CED1A2E00E9A7F2 /* PaymentMethodIncentive.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB46EF482CED1A2E00E9A7F2 /* PaymentMethodIncentive.swift */; };
CB46EF4B2CED1BDA00E9A7F2 /* PromoBadgeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB46EF4A2CED1BDA00E9A7F2 /* PromoBadgeView.swift */; };
CBF7BE542D11BF5300A4C172 /* BankAccountInfoViewSnapshotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBF7BE532D11BF5300A4C172 /* BankAccountInfoViewSnapshotTests.swift */; };
CD19725E26DBDB9960D828CB /* BottomSheetPresentationAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8F09CF961C943E36D76860F /* BottomSheetPresentationAnimator.swift */; };
CF2AD2C7F761C46AE559E563 /* SavedPaymentOptionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B3ECDF6CF9AABD573F86CA2 /* SavedPaymentOptionsViewController.swift */; };
D0B9FBCB359A7D774B98D19E /* LinkCookieKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1928BE9DFF116368B1A19DC /* LinkCookieKey.swift */; };
Expand Down Expand Up @@ -772,6 +773,7 @@
CB46EF482CED1A2E00E9A7F2 /* PaymentMethodIncentive.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentMethodIncentive.swift; sourceTree = "<group>"; };
CB46EF4A2CED1BDA00E9A7F2 /* PromoBadgeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromoBadgeView.swift; sourceTree = "<group>"; };
CBCFE3D39D670C3C77C59722 /* cs-CZ */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "cs-CZ"; path = "cs-CZ.lproj/Localizable.strings"; sourceTree = "<group>"; };
CBF7BE532D11BF5300A4C172 /* BankAccountInfoViewSnapshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BankAccountInfoViewSnapshotTests.swift; sourceTree = "<group>"; };
CC3498CF4AEAA8F169616CDF /* STPCardBrandChoice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPCardBrandChoice.swift; sourceTree = "<group>"; };
CCA2B5817236F64A212A8C61 /* IntentConfirmParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntentConfirmParams.swift; sourceTree = "<group>"; };
CD0150C1C20FD33EA024096A /* Appearance+FontScaling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Appearance+FontScaling.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1657,6 +1659,7 @@
3F70E5F0FE6218715432D55A /* AddPaymentMethodViewControllerSnapshotTests.swift */,
25AB69CF78A2B13839EB32EC /* AddressViewController */,
BE92D55DA4B4D449734B2917 /* BacsDDMandateViewSnapshotTests.swift */,
CBF7BE532D11BF5300A4C172 /* BankAccountInfoViewSnapshotTests.swift */,
0C53358C028E528F0FC626A2 /* CustomerSheet */,
989C2E3E03E42DA64A2FAE0D /* CustomerSheetSnapshotTests.swift */,
31699A822BE183D40048677F /* DownloadManagerTest.swift */,
Expand Down Expand Up @@ -2006,6 +2009,7 @@
316B33122B5F171C0008D2E5 /* UserDefaults+StripePaymentSheetTest.swift in Sources */,
B63DC67A2CC06AD10011C27E /* EmbeddedPaymentElementSnapshotTests.swift in Sources */,
D77514C28C9A031908E99CA1 /* PaymentMethodMessagingViewFunctionalTest.swift in Sources */,
CBF7BE542D11BF5300A4C172 /* BankAccountInfoViewSnapshotTests.swift in Sources */,
D14478CFCABDF7455DA7472A /* PaymentMethodMessagingViewSnapshotTests.swift in Sources */,
3D3607748436E625FF6CF921 /* PaymentSheet+APITest.swift in Sources */,
68F13446778AF2CAA631ACDE /* PaymentSheet+DeferredAPITest.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// BankAccountInfoViewSnapshotTests.swift
// StripePaymentSheetTests
//
// Created by Till Hellmund on 12/17/24.
//

import StripeCoreTestUtils
import UIKit
@testable import StripePaymentSheet

final class BankAccountInfoViewSnapshotTests : STPSnapshotTestCase {

private static let frame = CGRect(x: 0, y: 0, width: 320, height: 1000)

func test_noPromoBadge() {
let view = BankAccountInfoView(
frame: Self.frame,
theme: .default,
incentive: nil
)
view.setBankName(text: "Stripe Bank")
view.setLastFourOfBank(text: "•••• 4242")
view.setIncentiveEligible(false)

verify(view)
}

func test_eligibleForPromo() {
let view = BankAccountInfoView(
frame: Self.frame,
theme: .default,
incentive: .init(identifier: "link_instant_debits", displayText: "$5")
)
view.setBankName(text: "Stripe Bank")
view.setLastFourOfBank(text: "•••• 4242")
view.setIncentiveEligible(true)

verify(view)
}

func test_ineligibleForPromo() {
let view = BankAccountInfoView(
frame: Self.frame,
theme: .default,
incentive: .init(identifier: "link_instant_debits", displayText: "$5")
)
view.setBankName(text: "Stripe Bank")
view.setLastFourOfBank(text: "•••• 4242")
view.setIncentiveEligible(false)

verify(view)
}

private func verify(
_ view: UIView,
identifier: String? = nil,
file: StaticString = #filePath,
line: UInt = #line
) {
view.backgroundColor = .white
view.autosizeHeight(width: 300)
STPSnapshotVerifyView(view, identifier: identifier, file: file, line: line)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b085346

Please sign in to comment.