From 40ca8c9dd0431317fdb3886076ac5743508e97c5 Mon Sep 17 00:00:00 2001 From: Andreas Bauer Date: Thu, 9 Nov 2023 22:57:41 -0800 Subject: [PATCH] Fix tests --- Package.swift | 2 +- .../Views/ReauthenticationAlertModifier.swift | 10 ++++++---- .../TestAppUITests/FirebaseAccountTests.swift | 15 ++++++++++++++- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Package.swift b/Package.swift index 3566656..0c98ac4 100644 --- a/Package.swift +++ b/Package.swift @@ -26,7 +26,7 @@ let package = Package( dependencies: [ .package(url: "https://github.com/StanfordSpezi/Spezi", .upToNextMinor(from: "0.8.0")), .package(url: "https://github.com/StanfordSpezi/SpeziViews.git", .upToNextMinor(from: "0.6.1")), - .package(url: "https://github.com/StanfordSpezi/SpeziAccount", .upToNextMinor(from: "0.7.0")), + .package(url: "https://github.com/StanfordSpezi/SpeziAccount", branch: "fix/security-related-modifier"), .package(url: "https://github.com/StanfordSpezi/SpeziStorage", .upToNextMinor(from: "0.5.0")), .package(url: "https://github.com/firebase/firebase-ios-sdk", from: "10.13.0") ], diff --git a/Sources/SpeziFirebaseAccount/Views/ReauthenticationAlertModifier.swift b/Sources/SpeziFirebaseAccount/Views/ReauthenticationAlertModifier.swift index 7701892..a21215f 100644 --- a/Sources/SpeziFirebaseAccount/Views/ReauthenticationAlertModifier.swift +++ b/Sources/SpeziFirebaseAccount/Views/ReauthenticationAlertModifier.swift @@ -37,11 +37,13 @@ struct ReauthenticationAlertModifier: ViewModifier { func body(content: Content) -> some View { content - .onAppear(perform: { - print("We are getting displayed!") - }) .alert(Text("Authentication Required", bundle: .module), isPresented: isPresented, presenting: context) { context in - PasswordKey.DataEntry($password) + SecureField(text: $password) { + Text(PasswordFieldType.password.localizedStringResource) + } + .textContentType(.newPassword) + .autocorrectionDisabled() + .textInputAutocapitalization(.never) .validate(input: password, rules: .nonEmpty) .receiveValidation(in: $validation) diff --git a/Tests/UITests/TestAppUITests/FirebaseAccountTests.swift b/Tests/UITests/TestAppUITests/FirebaseAccountTests.swift index c779208..c640289 100644 --- a/Tests/UITests/TestAppUITests/FirebaseAccountTests.swift +++ b/Tests/UITests/TestAppUITests/FirebaseAccountTests.swift @@ -185,6 +185,12 @@ final class FirebaseAccountTests: XCTestCase { // swiftlint:disable:this type_bo XCTAssertTrue(XCUIApplication().alerts[alert].waitForExistence(timeout: 6.0)) XCUIApplication().alerts[alert].scrollViews.otherElements.buttons["Delete"].tap() + XCTAssertTrue(app.alerts["Authentication Required"].waitForExistence(timeout: 2.0)) + XCTAssertTrue(app.alerts["Authentication Required"].secureTextFields["Password"].waitForExistence(timeout: 0.5)) + app.typeText("TestPassword") // the password field has focus already + XCTAssertTrue(app.alerts["Authentication Required"].buttons["Login"].waitForExistence(timeout: 0.5)) + app.alerts["Authentication Required"].buttons["Login"].tap() + sleep(2) let accountsNew = try await FirebaseClient.getAllAccounts() XCTAssertEqual(accountsNew, []) @@ -236,6 +242,13 @@ final class FirebaseAccountTests: XCTestCase { // swiftlint:disable:this type_bo try app.textFields["E-Mail Address"].enter(value: "de", checkIfTextWasEnteredCorrectly: false) app.buttons["Done"].tap() + + XCTAssertTrue(app.alerts["Authentication Required"].waitForExistence(timeout: 2.0)) + XCTAssertTrue(app.alerts["Authentication Required"].secureTextFields["Password"].waitForExistence(timeout: 0.5)) + app.typeText("TestPassword") // the password field has focus already + XCTAssertTrue(app.alerts["Authentication Required"].buttons["Login"].waitForExistence(timeout: 0.5)) + app.alerts["Authentication Required"].buttons["Login"].tap() + sleep(3) XCTAssertTrue(app.staticTexts["test@username.de"].waitForExistence(timeout: 5.0)) @@ -495,4 +508,4 @@ extension XCUIApplication { sleep(3) buttons["Close"].tap() } -} +} // swiftlint:disable:this file_length diff --git a/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index eb92943..9352607 100644 --- a/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -113,8 +113,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/StanfordSpezi/SpeziAccount", "state" : { - "revision" : "e6b2670daa8fa17d6cc6fa44b3d08ded3a69d3e5", - "version" : "0.7.0" + "branch" : "fix/security-related-modifier", + "revision" : "f67d04e045827ba0d3e4c3b3bcbb5a5da4d77c31" } }, {