Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Nov 10, 2023
1 parent cdc64a0 commit 40ca8c9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
15 changes: 14 additions & 1 deletion Tests/UITests/TestAppUITests/FirebaseAccountTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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, [])
Expand Down Expand Up @@ -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["[email protected]"].waitForExistence(timeout: 5.0))

Expand Down Expand Up @@ -495,4 +508,4 @@ extension XCUIApplication {
sleep(3)
buttons["Close"].tap()
}
}
} // swiftlint:disable:this file_length
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down

0 comments on commit 40ca8c9

Please sign in to comment.