Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,60 +126,50 @@ extension DaysUntilBirthdayUITests_iOS {
/// This will assumme the full flow where a user must type in an email and
/// password to sign in with.
func signInForTheFirstTime() -> Bool {
guard sampleApp.textFields["Email or phone"]
.waitForExistence(timeout: timeout) else {
XCTFail("Failed to find email textfield")
return false
}
guard sampleApp
.keyboards
.element
.buttons["return"]
.waitForExistence(timeout: timeout) else {
XCTFail("Failed to find 'return' button")
return false
}
let emailField = sampleApp.textFields["Email or phone"]
guard emailField.waitForExistence(timeout: timeout) else {
XCTFail("Failed to find email textfield")
return false
}

sampleApp.textFields["Email or phone"].typeText(Credential.email.rawValue)
sampleApp.keyboards.element.buttons["return"].tap()
// 1. Explicitly tap the field to bring up the keyboard
emailField.tap()

guard sampleApp.secureTextFields["Enter your password"]
.waitForExistence(timeout: timeout) else {
XCTFail("Failed to find password textfield")
return false
}
guard sampleApp
.keyboards
.element
.buttons["return"]
.waitForExistence(timeout: timeout) else {
XCTFail("Failed to find 'return' button")
return false
}
// 2. Type the text and append "\n" to simulate tapping the return key
emailField.typeText("\(Credential.email.rawValue)\n")

let passwordField = sampleApp.secureTextFields["Enter your password"]
guard passwordField.waitForExistence(timeout: timeout) else {
XCTFail("Failed to find password textfield")
return false
}

sampleApp
.secureTextFields["Enter your password"]
.typeText(Credential.password.rawValue)
sampleApp.keyboards.element.buttons["return"].tap()
// 1. Tap the password field to ensure focus
passwordField.tap()

if sampleApp
.staticTexts[passwordManagerPrompt]
.waitForExistence(timeout: timeout) {
guard sampleApp
.buttons[notNowText]
.waitForExistence(timeout: timeout) else {
XCTFail("Failed to find \(notNowText) button")
return false
// 2. Type password and append "\n"
passwordField.typeText("\(Credential.password.rawValue)\n")

// 3. Handle System Password Prompt via SpringBoard (if it's an Apple system alert)
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let notNowButton = springboard.buttons[notNowText]

// Use a short timeout here so the test doesn't hang too long if the prompt doesn't appear
if notNowButton.waitForExistence(timeout: 3) {
notNowButton.tap()
} else {
// Fallback: Check inside sampleApp just in case it's a custom in-app prompt
if sampleApp.buttons[notNowText].waitForExistence(timeout: 1) {
sampleApp.buttons[notNowText].tap()
}
}
sampleApp.buttons[notNowText].tap()
}

// Proceed through sign-in disclaimer and/or access request view(s) if needed
handleSignInDisclaimerIfNeeded()
handleAccessRequestIfNeeded()
handleReturningUserSignInDisclaimerIfNeeded()
// Proceed through sign-in disclaimer and/or access request view(s) if needed
handleSignInDisclaimerIfNeeded()
handleAccessRequestIfNeeded()
handleReturningUserSignInDisclaimerIfNeeded()

return true
return true
}

/// Signs in expecting a prior sign in.
Expand Down Expand Up @@ -268,39 +258,24 @@ extension DaysUntilBirthdayUITests_iOS {

/// Proceeds through the view with header "Days Until Birthday wants additional access to your Google Account" if needed.
func handleAccessRequestIfNeeded() {
let currentlyShowingAdditionalAccessRequest = sampleApp.staticTexts[additionalAccessHeaderText]
.waitForExistence(timeout: timeout) && sampleApp.staticTexts[appTrustWarningText]
.waitForExistence(timeout: timeout) &&
sampleApp.buttons["Continue"]
.waitForExistence(timeout: timeout)

if currentlyShowingAdditionalAccessRequest {
sampleApp.buttons["Continue"].tap()
}
}
let continueButton = sampleApp.buttons["Continue"]
if continueButton.waitForExistence(timeout: 5) {
continueButton.tap()
} }

/// Proceeds through the sign-in disclaimer view if needed.
func handleSignInDisclaimerIfNeeded() {
let currentlyShowingSignInDisclaimer = sampleApp.staticTexts[signInDisclaimerHeaderText]
.waitForExistence(timeout: timeout) &&
sampleApp.buttons["Continue"]
.waitForExistence(timeout: timeout)

if currentlyShowingSignInDisclaimer {
sampleApp.buttons["Continue"].tap()
}
let continueButton = sampleApp.buttons["Continue"]
if continueButton.waitForExistence(timeout: 5) {
continueButton.tap()
}
}

func handleReturningUserSignInDisclaimerIfNeeded() {
let currentlyShowingReturningUserSignInDisclaimer =
sampleApp.staticTexts[returningUserSignInDisclaimerHeaderText]
.waitForExistence(timeout: timeout) &&
sampleApp.buttons["Continue"]
.waitForExistence(timeout: timeout)

if currentlyShowingReturningUserSignInDisclaimer {
sampleApp.buttons["Continue"].tap()
}
let continueButton = sampleApp.buttons["Continue"]
if continueButton.waitForExistence(timeout: 5) {
continueButton.tap()
}
}

/// This method looks for an account in the current view that reflects an already-signed-in state, and taps it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ struct DaysUntilBirthday: App {
}
}
}


// testing
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import GoogleSignIn
/// An observable class for authenticating via Google.
final class GoogleSignInAuthenticator: ObservableObject {
private var authViewModel: AuthenticationViewModel
private let claims: Set<GIDClaim> = [GIDClaim.essentialAMR(), GIDClaim.authTime()]
private let claims: Set<GIDClaim> = [GIDClaim.authTime()]

/// Creates an instance of this authenticator.
/// - parameter authViewModel: The view model this authenticator will set logged in status on.
Expand Down
Loading