Skip to content

Commit

Permalink
Do not use .newPassword content type within simulator (#52)
Browse files Browse the repository at this point in the history
# Do not use .newPassword content type within simulator

## ♻️ Current situation & Problem
Previously, we would disable password auto-fill within the simulator to
avoid the simulator proposing a pre-filled password that would otherwise
interfere with our UI tests. This approach broke with iOS 17.2 simulator
and our workaround seems to not always work.
Instead, this PR just avoids using the `.newPassword` content type when
running within the simulator.


## ⚙️ Release Notes 
* Avoid using `.newPassword` text content type when running within the
simulator.


## 📚 Documentation
Inline docs were added.


## ✅ Testing
--

## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
Supereg authored Feb 23, 2024
1 parent 1ced521 commit a7d289e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Sources/SpeziAccount/AccountValue/Keys/PasswordKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ extension PasswordKey {
switch accountViewType {
case .signup, .none:
VerifiableTextField(fieldType.localizedStringResource, text: $password, type: .secure)
#if targetEnvironment(simulator)
// we do not use `.newPassword` within simulator builds to not interfer with UI tests
.textContentType(.password)
#else
.textContentType(.newPassword)
#endif
.disableFieldAssistants()
case .overview: // display description labels in the PasswordChangeSheet (as we have two password fields)
DescriptionGridRow {
Expand All @@ -86,7 +91,12 @@ extension PasswordKey {
SecureField(text: $password) {
Text(fieldType.localizedPrompt)
}
#if targetEnvironment(simulator)
// we do not use `.newPassword` within simulator builds to not interfer with UI tests
.textContentType(.password)
#else
.textContentType(.newPassword)
#endif
.disableFieldAssistants()
}

Expand Down
2 changes: 0 additions & 2 deletions Tests/UITests/TestAppUITests/AccountOverviewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ final class AccountOverviewTests: XCTestCase {
try super.setUpWithError()

continueAfterFailure = false

try disablePasswordAutofill()
}

func testRequirementLevelsOverview() throws {
Expand Down
2 changes: 0 additions & 2 deletions Tests/UITests/TestAppUITests/AccountSetupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ final class AccountSetupTests: XCTestCase {
try super.setUpWithError()

continueAfterFailure = false

try disablePasswordAutofill()
}

func testEmbeddedViewValidation() throws {
Expand Down

0 comments on commit a7d289e

Please sign in to comment.