@@ -26,6 +26,7 @@ class DaysUntilBirthdayUITests_iOS: XCTestCase {
2626 private let additionalAccessHeaderText = " Days Until Birthday wants additional access to your Google Account "
2727 private let appTrustWarningText = " Make sure you trust Days Until Birthday "
2828 private let chooseAnAccountHeaderText = " Choose an account "
29+ private let consentRequestHeaderText = " Share some info with Days Until Birthday "
2930 private let notNowText = " Not Now "
3031 private let timeout : TimeInterval = 30
3132
@@ -68,6 +69,23 @@ class DaysUntilBirthdayUITests_iOS: XCTestCase {
6869 return XCTFail ( " Signing out should return user to sign in view " )
6970 }
7071 }
72+
73+ func testFetchVerificationSignalAndDisconnect( ) {
74+ sampleApp. launch ( )
75+
76+ XCTAssertTrue ( signIn ( ) )
77+ XCTAssertTrue ( navigateToVerifyMyAge ( ) )
78+ XCTAssertTrue ( displayVerificationSignal ( ) )
79+ XCTAssertTrue ( navigateBackToUserProfileView ( ) )
80+
81+ sampleApp. navigationBars. buttons [ " Disconnect " ] . tap ( )
82+
83+ guard sampleApp
84+ . buttons [ " GoogleSignInButton " ]
85+ . waitForExistence ( timeout: timeout) else {
86+ return XCTFail ( " Disconnecting should return user to sign in view " )
87+ }
88+ }
7189}
7290
7391extension DaysUntilBirthdayUITests_iOS {
@@ -262,6 +280,84 @@ extension DaysUntilBirthdayUITests_iOS {
262280 return true
263281 }
264282
283+ /// Navigates to the verification view from the user profile view.
284+ /// - returns: `true` if the navigation was performed successfully.
285+ /// - note: This method will attempt to find a pop up asking for permission to
286+ /// sign in with Google.
287+ func navigateToVerifyMyAge( ) -> Bool {
288+ guard sampleApp. buttons [ " Verify My Age " ]
289+ . waitForExistence ( timeout: timeout) else {
290+ XCTFail ( " Failed to find button navigating to verify my age view " )
291+ return false
292+ }
293+ sampleApp. buttons [ " Verify My Age " ] . tap ( )
294+
295+ if springboardApp
296+ . staticTexts [ signInStaticText]
297+ . waitForExistence ( timeout: timeout) {
298+ guard springboardApp
299+ . buttons [ " Continue " ]
300+ . waitForExistence ( timeout: timeout) else {
301+ XCTFail ( " Failed to find 'Continue' button " )
302+ return false
303+ }
304+ springboardApp. buttons [ " Continue " ] . tap ( )
305+
306+ if sampleApp
307+ . staticTexts [ chooseAnAccountHeaderText]
308+ . waitForExistence ( timeout: timeout) {
309+ guard findAndTapExistingSignedInEmail ( ) else {
310+ XCTFail ( " Failed to find signed-in account " )
311+ return false
312+ }
313+ }
314+
315+ handleConsentRequestIfNeeded ( )
316+ }
317+
318+ guard sampleApp. staticTexts [ " Verified Account! " ]
319+ . waitForExistence ( timeout: timeout) else {
320+ XCTFail ( " Failed to show age verification view " )
321+ return false
322+ }
323+
324+ guard sampleApp. staticTexts [ " Access Token: " ]
325+ . waitForExistence ( timeout: timeout) else {
326+ XCTFail ( " Access Token element did not appear " )
327+ return false
328+ }
329+
330+ return true
331+ }
332+
333+ /// Displays a sheet over the Verification view with the fetched verification signal..
334+ /// - returns: `true` if the display was performed successfully.
335+ func displayVerificationSignal( ) -> Bool {
336+ guard sampleApp. buttons [ " Fetch Age Verification Signal " ]
337+ . waitForExistence ( timeout: timeout) else {
338+ XCTFail ( " Failed to find button to refresh access token " )
339+ return false
340+ }
341+ sampleApp. buttons [ " Fetch Age Verification Signal " ] . tap ( )
342+
343+ guard sampleApp. staticTexts [ " User is verified over 18! " ]
344+ . waitForExistence ( timeout: timeout) else {
345+ XCTFail ( " Failed to show age verification signal view " )
346+ return false
347+ }
348+
349+ guard sampleApp
350+ . navigationBars
351+ . buttons [ " Close " ]
352+ . waitForExistence ( timeout: timeout) else {
353+ XCTFail ( " Failed to show close button back to age signal view " )
354+ return false
355+ }
356+ sampleApp. navigationBars. buttons [ " Close " ] . tap ( )
357+
358+ return true
359+ }
360+
265361 /// Proceeds through the view with header "Days Until Birthday wants additional access to your Google Account" if needed.
266362 func handleAccessRequestIfNeeded( ) {
267363 let currentlyShowingAdditionalAccessRequest = sampleApp. staticTexts [ additionalAccessHeaderText]
@@ -275,6 +371,17 @@ extension DaysUntilBirthdayUITests_iOS {
275371 }
276372 }
277373
374+ /// Proceeds through the view with header "Share some info with Days Until Birthday" if needed.
375+ func handleConsentRequestIfNeeded( ) {
376+ let currentlyShowingConsentRequest =
377+ sampleApp. staticTexts [ consentRequestHeaderText] . waitForExistence ( timeout: timeout)
378+ && sampleApp. buttons [ " Agree " ] . waitForExistence ( timeout: timeout)
379+
380+ if currentlyShowingConsentRequest {
381+ sampleApp. buttons [ " Agree " ] . tap ( )
382+ }
383+ }
384+
278385 /// Proceeds through the sign-in disclaimer view if needed.
279386 func handleSignInDisclaimerIfNeeded( ) {
280387 let currentlyShowingSignInDisclaimer = sampleApp. staticTexts [ signInDisclaimerHeaderText]
0 commit comments