Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClearButton from UITextField is not recorded with iOS 17 #804

Open
GHMarcus opened this issue Nov 7, 2023 · 3 comments
Open

ClearButton from UITextField is not recorded with iOS 17 #804

GHMarcus opened this issue Nov 7, 2023 · 3 comments

Comments

@GHMarcus
Copy link

GHMarcus commented Nov 7, 2023

Describe the bug

Snapshotting a filled UITextField with an iOS 17 Simulator didn't record the ClearButton at the end of the text field anymore.

To Reproduce

  1. Methode:
  • Simply create a single ViewController with an UITextField in it.
  • Set the clearButtonMode from the text field to .always.
  • Write a test for this controller where you first set a value to the text field befor snapshotting it.
  • iOS 16 test devices will capture the filled text field with clear button
  • iOS 17 test devices will capture the filled text field without clear button
  1. Methode:
  • Use the attached sample project where I prepared the test scenario. In this test project there are 4 recorded snapshots. Empty and Filled states for iOS 16 and 17. They are recorded with an iPhone 14 and when you use an iOS 16 iPhone 14 and run all test both will succeed. When you run the tests with an iOS 17 iPhone 14 the second one (FilledAppearance) will fail.
  • TextInputBug.zip

Expected behavior

  • iOS 17 test devices will capture the filled text field with clear button

Environment

  • swift-snapshot-testing version 1.14.2
  • Xcode 15.0.1
  • Swift 5.9
  • OS: iOS 16.4 und iOS 17.0.1

Additional context

Some strange behaviour I ran into when debugging this bug:

  • If you set an breakpoint directly on the snapshotting line of the filled appearance test (in my test project its line 25 in the TextInputBugTests.swift file).
  • Run the tests.
  • After the system stopped at this breakpoint, take a Quick Look at the in the test created ViewController.
  • You will see the correct view with the clear button
  • After continuing the test it will succeed, instead of failing like when you not look at the ViewController
@mat1th
Copy link

mat1th commented Jan 29, 2024

Hi @GHMarcus, I'm facing the same issue.
Did you find a work around for this?

@GHMarcus
Copy link
Author

@mat1th
Kind of, we ended up checking of we are running inside the Unit-Tests and setting clearButtonMode to .never for this cases.

For some search bars inside of our app it looks like this

if NSClassFromString("XCTest") != nil {
   searchBar.searchTextField.clearButtonMode = .never
}

Hope this will help you.

@mat1th
Copy link

mat1th commented Jan 30, 2024

Hi @GHMarcus, thank you. Will try out if this also is a solution for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants