@@ -23,9 +23,11 @@ class DaysUntilBirthdayUITests_iOS: XCTestCase {
2323 " Would you like to save this password to use with apps and websites? "
2424 private let signInDisclaimerHeaderText =
2525 " Sign in to Days Until Birthday "
26+ private let accessHeaderText = " Days Until Birthday wants access to your Google Account "
2627 private let additionalAccessHeaderText = " Days Until Birthday wants additional access to your Google Account "
2728 private let appTrustWarningText = " Make sure you trust Days Until Birthday "
2829 private let chooseAnAccountHeaderText = " Choose an account "
30+ private let consentRequestHeaderText = " Share some info with Days Until Birthday "
2931 private let notNowText = " Not Now "
3032 private let timeout : TimeInterval = 30
3133
@@ -68,6 +70,27 @@ class DaysUntilBirthdayUITests_iOS: XCTestCase {
6870 return XCTFail ( " Signing out should return user to sign in view " )
6971 }
7072 }
73+
74+ func testFetchVerificationSignalAndDisconnect( ) {
75+ sampleApp. launch ( )
76+
77+ XCTAssertTrue ( navigateToVerifyMyAge ( ) )
78+ XCTAssertTrue ( displayVerificationSignal ( ) )
79+
80+ guard sampleApp
81+ . navigationBars
82+ . buttons [ " Sign-in with Google " ]
83+ . waitForExistence ( timeout: timeout) else {
84+ return XCTFail ( " Failed to show navigation button back to Sign In View " )
85+ }
86+ sampleApp. navigationBars. buttons [ " Sign-in with Google " ] . tap ( )
87+
88+ guard sampleApp
89+ . buttons [ " GoogleSignInButton " ]
90+ . waitForExistence ( timeout: timeout) else {
91+ return XCTFail ( " Failed to return user to sign in view " )
92+ }
93+ }
7194}
7295
7396extension DaysUntilBirthdayUITests_iOS {
@@ -262,10 +285,90 @@ extension DaysUntilBirthdayUITests_iOS {
262285 return true
263286 }
264287
288+ /// Navigates to the verification view from the user profile view.
289+ /// - returns: `true` if the navigation was performed successfully.
290+ /// - note: This method will attempt to find a pop up asking for permission to
291+ /// sign in with Google.
292+ func navigateToVerifyMyAge( ) -> Bool {
293+ guard sampleApp. buttons [ " Verify " ]
294+ . waitForExistence ( timeout: timeout) else {
295+ XCTFail ( " Failed to find button navigating to verify my age view " )
296+ return false
297+ }
298+ sampleApp. buttons [ " Verify " ] . tap ( )
299+
300+ if springboardApp
301+ . staticTexts [ signInStaticText]
302+ . waitForExistence ( timeout: timeout) {
303+ guard springboardApp
304+ . buttons [ " Continue " ]
305+ . waitForExistence ( timeout: timeout) else {
306+ XCTFail ( " Failed to find 'Continue' button " )
307+ return false
308+ }
309+ springboardApp. buttons [ " Continue " ] . tap ( )
310+
311+ if sampleApp
312+ . staticTexts [ Credential . email. rawValue]
313+ . waitForExistence ( timeout: timeout) {
314+ XCTAssertTrue ( useExistingSignIn ( ) )
315+ } else {
316+ XCTAssertTrue ( signInForTheFirstTime ( ) )
317+ }
318+
319+ handleConsentRequestIfNeeded ( )
320+ }
321+
322+ guard sampleApp. staticTexts [ " Verified Account! " ]
323+ . waitForExistence ( timeout: timeout) else {
324+ XCTFail ( " Failed to show age verification view " )
325+ return false
326+ }
327+
328+ guard sampleApp. staticTexts [ " Access Token: " ]
329+ . waitForExistence ( timeout: timeout) else {
330+ XCTFail ( " Access Token element did not appear " )
331+ return false
332+ }
333+
334+ return true
335+ }
336+
337+ /// Displays a sheet over the Verification view with the fetched verification signal..
338+ /// - returns: `true` if the display was performed successfully.
339+ func displayVerificationSignal( ) -> Bool {
340+ guard sampleApp. buttons [ " Fetch Age Verification Signal " ]
341+ . waitForExistence ( timeout: timeout) else {
342+ XCTFail ( " Failed to find button to refresh access token " )
343+ return false
344+ }
345+ sampleApp. buttons [ " Fetch Age Verification Signal " ] . tap ( )
346+
347+ guard sampleApp. staticTexts [ " User is verified over 18! " ]
348+ . waitForExistence ( timeout: timeout) else {
349+ XCTFail ( " Failed to show age verification signal view " )
350+ return false
351+ }
352+
353+ guard sampleApp
354+ . navigationBars
355+ . buttons [ " Close " ]
356+ . waitForExistence ( timeout: timeout) else {
357+ XCTFail ( " Failed to show close button back to age signal view " )
358+ return false
359+ }
360+ sampleApp. navigationBars. buttons [ " Close " ] . tap ( )
361+
362+ return true
363+ }
364+
265365 /// Proceeds through the view with header "Days Until Birthday wants additional access to your Google Account" if needed.
266366 func handleAccessRequestIfNeeded( ) {
267- let currentlyShowingAdditionalAccessRequest = sampleApp. staticTexts [ additionalAccessHeaderText]
268- . waitForExistence ( timeout: timeout) && sampleApp. staticTexts [ appTrustWarningText]
367+ let currentlyShowingAdditionalAccessHeaderText =
368+ sampleApp. staticTexts [ additionalAccessHeaderText] . waitForExistence ( timeout: timeout) ||
369+ sampleApp. staticTexts [ accessHeaderText] . waitForExistence ( timeout: timeout)
370+ let currentlyShowingAdditionalAccessRequest =
371+ currentlyShowingAdditionalAccessHeaderText && sampleApp. staticTexts [ appTrustWarningText]
269372 . waitForExistence ( timeout: timeout) &&
270373 sampleApp. buttons [ " Continue " ]
271374 . waitForExistence ( timeout: timeout)
@@ -275,6 +378,17 @@ extension DaysUntilBirthdayUITests_iOS {
275378 }
276379 }
277380
381+ /// Proceeds through the view with header "Share some info with Days Until Birthday" if needed.
382+ func handleConsentRequestIfNeeded( ) {
383+ let currentlyShowingConsentRequest =
384+ sampleApp. staticTexts [ consentRequestHeaderText] . waitForExistence ( timeout: timeout)
385+ && sampleApp. buttons [ " Agree " ] . waitForExistence ( timeout: timeout)
386+
387+ if currentlyShowingConsentRequest {
388+ sampleApp. buttons [ " Agree " ] . tap ( )
389+ }
390+ }
391+
278392 /// Proceeds through the sign-in disclaimer view if needed.
279393 func handleSignInDisclaimerIfNeeded( ) {
280394 let currentlyShowingSignInDisclaimer = sampleApp. staticTexts [ signInDisclaimerHeaderText]
0 commit comments