@@ -24,6 +24,7 @@ class DaysUntilBirthdayUITests_iOS: XCTestCase {
2424 private let signInDisclaimerHeaderText =
2525 " Sign in to Days Until Birthday "
2626 private let additionalAccessHeaderText = " Days Until Birthday wants additional access to your Google Account "
27+ private let infoSharingHeaderText = " Share some info with Days Until Birthday "
2728 private let appTrustWarningText = " Make sure you trust Days Until Birthday "
2829 private let chooseAnAccountHeaderText = " Choose an account "
2930 private let notNowText = " Not Now "
@@ -34,6 +35,22 @@ class DaysUntilBirthdayUITests_iOS: XCTestCase {
3435 bundleIdentifier: " com.apple.springboard "
3536 )
3637
38+ func testSignInFetchVerificationSignalAndDisconnect( ) {
39+ sampleApp. launch ( )
40+ XCTAssertTrue ( signIn ( ) )
41+ XCTAssertTrue ( navigateToVerifyMyAge ( ) )
42+
43+ XCTAssertTrue ( navigateBackToUserProfileView ( ) )
44+
45+ sampleApp. navigationBars. buttons [ " Disconnect " ] . tap ( )
46+
47+ guard sampleApp
48+ . buttons [ " GoogleSignInButton " ]
49+ . waitForExistence ( timeout: timeout) else {
50+ return XCTFail ( " Disconnecting should return user to sign in view " )
51+ }
52+ }
53+
3754 func testSignInNavigateToDaysUntilBirthdayAndDisconnect( ) {
3855 sampleApp. launch ( )
3956
@@ -195,6 +212,75 @@ extension DaysUntilBirthdayUITests_iOS {
195212 return true
196213 }
197214
215+ func navigateToVerifyMyAge( ) -> Bool {
216+ guard sampleApp. buttons [ " Verify My Age " ]
217+ . waitForExistence ( timeout: timeout) else {
218+ XCTFail ( " Failed to find button navigating to verify my age view " )
219+ return false
220+ }
221+ sampleApp. buttons [ " Verify My Age " ] . tap ( )
222+
223+ if springboardApp
224+ . staticTexts [ signInStaticText]
225+ . waitForExistence ( timeout: timeout) {
226+ guard springboardApp
227+ . buttons [ " Continue " ]
228+ . waitForExistence ( timeout: timeout) else {
229+ XCTFail ( " Failed to find 'Continue' button " )
230+ return false
231+ }
232+ springboardApp. buttons [ " Continue " ] . tap ( )
233+
234+ if sampleApp
235+ . staticTexts [ chooseAnAccountHeaderText]
236+ . waitForExistence ( timeout: timeout) {
237+ guard findAndTapExistingSignedInEmail ( ) else {
238+ XCTFail ( " Failed to find signed-in account " )
239+ return false
240+ }
241+ }
242+
243+ handleInfoSharingRequestIfNeeded ( )
244+ }
245+
246+ guard sampleApp. staticTexts [ " Verified Account! " ]
247+ . waitForExistence ( timeout: 30 ) else {
248+ XCTFail ( " Failed to show age verification view " )
249+ return false
250+ }
251+
252+ let currentAccessTokenIdentifier = sampleApp. staticTexts [ " Access Token: " ]
253+
254+ guard currentAccessTokenIdentifier. waitForExistence ( timeout: timeout) else {
255+ XCTFail ( " Access Token element did not appear " )
256+ return false
257+ }
258+
259+ guard sampleApp. buttons [ " Fetch Age Verification Signal " ]
260+ . waitForExistence ( timeout: timeout) else {
261+ XCTFail ( " Failed to find button to refresh access token " )
262+ return false
263+ }
264+ sampleApp. buttons [ " Fetch Age Verification Signal " ] . tap ( )
265+
266+ guard sampleApp. staticTexts [ " User is verified over 18! " ]
267+ . waitForExistence ( timeout: 30 ) else {
268+ XCTFail ( " Failed to show age verification signal view " )
269+ return false
270+ }
271+
272+ guard sampleApp
273+ . navigationBars
274+ . buttons [ " Close " ]
275+ . waitForExistence ( timeout: timeout) else {
276+ XCTFail ( " Failed to show close button back to age signal view " )
277+ return false
278+ }
279+ sampleApp. navigationBars. buttons [ " Close " ] . tap ( )
280+
281+ return true
282+ }
283+
198284 /// Navigates to the days until birthday view from the user profile view.
199285 /// - returns: `true` if the navigation was performed successfully.
200286 /// - note: This method will attempt to find a pop up asking for permission to
@@ -262,6 +348,17 @@ extension DaysUntilBirthdayUITests_iOS {
262348 return true
263349 }
264350
351+ func handleInfoSharingRequestIfNeeded( ) {
352+ let currentlyShowingInfoSharingRequest = sampleApp. staticTexts [ infoSharingHeaderText]
353+ . waitForExistence ( timeout: timeout) &&
354+ sampleApp. buttons [ " Agree " ]
355+ . waitForExistence ( timeout: timeout)
356+
357+ if currentlyShowingInfoSharingRequest {
358+ sampleApp. buttons [ " Agree " ] . tap ( )
359+ }
360+ }
361+
265362 /// Proceeds through the view with header "Days Until Birthday wants additional access to your Google Account" if needed.
266363 func handleAccessRequestIfNeeded( ) {
267364 let currentlyShowingAdditionalAccessRequest = sampleApp. staticTexts [ additionalAccessHeaderText]
0 commit comments