diff --git a/ElementX/Sources/Other/AccessibilityIdentifiers.swift b/ElementX/Sources/Other/AccessibilityIdentifiers.swift index fb5d84e51..47a6518e9 100644 --- a/ElementX/Sources/Other/AccessibilityIdentifiers.swift +++ b/ElementX/Sources/Other/AccessibilityIdentifiers.swift @@ -62,6 +62,7 @@ enum A11yIdentifiers { } struct AppLockSetupPINScreen { + let textField = "app_lock_setup_pin-text_field" let cancel = "app_lock_setup_pin-cancel" } diff --git a/ElementX/Sources/Screens/AppLock/AppLockSetupPINScreen/View/PINTextField.swift b/ElementX/Sources/Screens/AppLock/AppLockSetupPINScreen/View/PINTextField.swift index bab03a7a7..6c60f0a3c 100644 --- a/ElementX/Sources/Screens/AppLock/AppLockSetupPINScreen/View/PINTextField.swift +++ b/ElementX/Sources/Screens/AppLock/AppLockSetupPINScreen/View/PINTextField.swift @@ -26,6 +26,7 @@ struct PINTextField: View { textField .textFieldStyle(PINTextFieldStyle(pinCode: pinCode, isSecure: isSecure)) .keyboardType(.numberPad) + .accessibilityIdentifier(A11yIdentifiers.appLockSetupPINScreen.textField) .onChange(of: pinCode) { newValue in let sanitized = sanitize(newValue) if sanitized != newValue { @@ -67,7 +68,8 @@ private struct PINTextFieldStyle: TextFieldStyle { .overlay { configuration .focused($isFocussed) - .opacity(0.0) + // Textfield isn't accessible for UI tests otherwise + .opacity(0.01) } .onTapGesture { isFocussed = true } } diff --git a/UITests/Sources/AppLockSetupUITests.swift b/UITests/Sources/AppLockSetupUITests.swift index 49623df3f..c98ec83d2 100644 --- a/UITests/Sources/AppLockSetupUITests.swift +++ b/UITests/Sources/AppLockSetupUITests.swift @@ -137,16 +137,16 @@ class AppLockSetupUITests: XCTestCase { // MARK: - Helpers private func enterPIN() { - app.keys["2"].tap() - app.keys["0"].tap() - app.keys["2"].tap() - app.keys["3"].tap() + let textField = app.secureTextFields[A11yIdentifiers.appLockSetupPINScreen.textField] + XCTAssert(textField.waitForExistence(timeout: 10)) + + textField.clearAndTypeText("2023") } private func enterDifferentPIN() { - app.keys["2"].tap() - app.keys["2"].tap() - app.keys["3"].tap() - app.keys["3"].tap() + let textField = app.secureTextFields[A11yIdentifiers.appLockSetupPINScreen.textField] + XCTAssert(textField.waitForExistence(timeout: 10)) + + textField.clearAndTypeText("2233") } }