@@ -105,37 +105,58 @@ struct FirebaseSwiftUIExampleTests {
105105 #expect( service. errorMessage. isEmpty)
106106 #expect( service. signedInCredential == nil )
107107 #expect( service. currentUser == nil )
108- try await service. createUser ( withEmail: createEmail ( ) , password: kPassword)
109- try await Task . sleep ( nanoseconds: 4_000_000_000 )
108+ try await service. createUser ( email: createEmail ( ) , password: kPassword)
109+
110+ try await waitForStateChange {
111+ service. authenticationState == . authenticated
112+ }
110113 #expect( service. authenticationState == . authenticated)
114+
115+ try await waitForStateChange {
116+ service. currentUser != nil
117+ }
118+ #expect( service. currentUser != nil )
111119 #expect( service. authView == . authPicker)
112120 #expect( service. errorMessage. isEmpty)
113- #expect( service. currentUser != nil )
114- // TODO: - reinstate once this PR is merged: https://github.com/firebase/FirebaseUI-iOS/pull/1256
115- // #expect(service.signedInCredential is AuthCredential)
116121 }
117122
118123 @Test
119124 @MainActor
120125 func testSignInUser( ) async throws {
121126 let service = try await prepareFreshAuthService ( )
122127 let email = createEmail ( )
123- try await service. createUser ( withEmail : email, password: kPassword)
128+ try await service. createUser ( email : email, password: kPassword)
124129 try await service. signOut ( )
125- try await Task . sleep ( nanoseconds: 2_000_000_000 )
130+
131+ try await waitForStateChange {
132+ service. authenticationState == . unauthenticated
133+ }
126134 #expect( service. authenticationState == . unauthenticated)
135+
136+ try await waitForStateChange {
137+ service. currentUser == nil
138+ }
139+ #expect( service. currentUser == nil )
127140 #expect( service. authView == . authPicker)
128141 #expect( service. errorMessage. isEmpty)
129142 #expect( service. signedInCredential == nil )
130- #expect( service. currentUser == nil )
131143
132- try await service. signIn ( withEmail : email, password: kPassword)
144+ try await service. signIn ( email : email, password: kPassword)
133145
146+ try await waitForStateChange {
147+ service. authenticationState == . authenticated
148+ }
134149 #expect( service. authenticationState == . authenticated)
150+
151+ try await waitForStateChange {
152+ service. currentUser != nil
153+ }
154+ #expect( service. currentUser != nil )
155+ try await waitForStateChange {
156+ service. signedInCredential != nil
157+ }
158+ #expect( service. signedInCredential != nil )
135159 #expect( service. authView == . authPicker)
136160 #expect( service. errorMessage. isEmpty)
137- #expect( service. currentUser != nil )
138- // TODO: - reinstate once this PR is merged: https://github.com/firebase/FirebaseUI-iOS/pull/1256
139- // #expect(service.signedInCredential is AuthCredential)
140161 }
141162}
0 commit comments