Skip to content

Commit 7293176

Browse files
committed
adding test for phone auth incorrect number
1 parent d4b134f commit 7293176

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,13 @@ class AuthenticationExampleUITests: XCTestCase {
185185
func testPhoneAuthLoginRCEInEnforceMode() {
186186
app.staticTexts["Phone Number"].tap()
187187
XCTAssertTrue(app.staticTexts["Sign in using Phone Auth"].waitForExistence(timeout: 3))
188-
let testPhone = "+12345678901"
188+
let testPhone = "12345678901"
189189
app.textFields["Enter Phone Number"].tap()
190190
app.textFields["Enter Phone Number"].typeText(testPhone)
191191
app.buttons["Send Verification Code"].tap()
192192
// Wait for the error message to appear (if there is an error)
193193
let errorAlert = app.alerts.staticTexts["Error"]
194-
let errorExists = errorAlert.waitForExistence(timeout: 5.0)
194+
let errorExists = errorAlert.waitForExistence(timeout: 3.0)
195195
XCTAssertFalse(errorExists, "Error")
196196
let verificationCodeInput = app.textFields["Enter verification code."]
197197
XCTAssertTrue(
@@ -209,6 +209,36 @@ class AuthenticationExampleUITests: XCTestCase {
209209
}
210210
}
211211

212+
func testPhoneAuthLoginRCEInEnforceModeIncorrectNumber() {
213+
app.staticTexts["Phone Number"].tap()
214+
XCTAssertTrue(app.staticTexts["Sign in using Phone Auth"].waitForExistence(timeout: 3))
215+
let testPhone = "1234567890"
216+
app.textFields["Enter Phone Number"].tap()
217+
app.textFields["Enter Phone Number"].typeText(testPhone)
218+
app.buttons["Send Verification Code"].tap()
219+
// Verify that the error dialog appears
220+
let errorDialog = app.alerts["Error"]
221+
XCTAssertTrue(
222+
errorDialog.waitForExistence(timeout: 5),
223+
"Error dialog should appear."
224+
)
225+
let okButton = errorDialog.buttons["OK"] // Dismiss the error dialog
226+
XCTAssertTrue(okButton.exists, "The 'OK' button should be present in the error dialog.")
227+
okButton.tap()
228+
// Ensure the dialog is dismissed
229+
XCTAssertFalse(errorDialog.exists, "The error dialog should be dismissed after tapping 'OK'.")
230+
// Go back and check that there is no user that is signed in
231+
app.swipeDown(velocity: .fast)
232+
// Go back and check that there is no user that is signed in
233+
app.tabBars.firstMatch.buttons.element(boundBy: 1).tap()
234+
wait(forElement: app.navigationBars["User"], timeout: 5.0)
235+
XCTAssertEqual(
236+
app.cells.count,
237+
0,
238+
"The user shouldn't be signed in and the user view should have no cells."
239+
)
240+
}
241+
212242
func DRAFT_testGoogleSignInAndLinkAccount() {
213243
let interruptionMonitor = addUIInterruptionMonitor(withDescription: "Sign in with Google") {
214244
alert -> Bool in

0 commit comments

Comments
 (0)