@@ -10,7 +10,6 @@ import FirebaseCore
1010@testable import FirebaseSwiftUIExample
1111import Testing
1212
13- let kEmailAddress = " [email protected] " 1413let kPassword = " 123456 "
1514
1615struct FirebaseSwiftUIExampleTests {
@@ -25,6 +24,12 @@ struct FirebaseSwiftUIExampleTests {
2524 return AuthService ( configuration: resolvedConfiguration)
2625 }
2726
27+ func createEmail( ) -> String {
28+ let before = UUID ( ) . uuidString. prefix ( 8 )
29+ let after = UUID ( ) . uuidString. prefix ( 6 )
30+ return " \( before) @ \( after) .com "
31+ }
32+
2833 @Test
2934 @MainActor
3035 func testCreateEmailPasswordUser( ) async throws {
@@ -35,7 +40,7 @@ struct FirebaseSwiftUIExampleTests {
3540 #expect( service. errorMessage. isEmpty)
3641 #expect( service. signedInCredential == nil )
3742 #expect( service. currentUser == nil )
38- try await service. createUser ( withEmail: kEmailAddress , password: kPassword)
43+ try await service. createUser ( withEmail: createEmail ( ) , password: kPassword)
3944
4045 #expect( service. authenticationState == . authenticated)
4146 #expect( service. authView == . authPicker)
@@ -49,22 +54,23 @@ struct FirebaseSwiftUIExampleTests {
4954 @MainActor
5055 func testSignInUser( ) async throws {
5156 let service = try await prepareFreshAuthService ( )
52- // TODO: - it clears emulator data but seems like it is still there?
53- // try await service.createUser(withEmail: kEmailAddress, password: kPassword)
54- // try await service.signOut()
57+ let email = createEmail ( )
58+ try await service. createUser ( withEmail: email, password: kPassword)
59+ try await service. signOut ( )
60+ try await Task . sleep ( nanoseconds: 1_000_000_000 )
5561 #expect( service. authenticationState == . unauthenticated)
5662 #expect( service. authView == . authPicker)
5763 #expect( service. errorMessage. isEmpty)
5864 #expect( service. signedInCredential == nil )
5965 #expect( service. currentUser == nil )
6066
61- try await service. signIn ( withEmail: kEmailAddress , password: kPassword)
67+ try await service. signIn ( withEmail: email , password: kPassword)
6268
6369 #expect( service. authenticationState == . authenticated)
6470 #expect( service. authView == . authPicker)
6571 #expect( service. errorMessage. isEmpty)
6672 #expect( service. currentUser != nil )
6773 // TODO: - reinstate once this PR is merged: https://github.com/firebase/FirebaseUI-iOS/pull/1256
68- // #expect(service.signedInCredential is AuthCredential)
74+ // #expect(service.signedInCredential is AuthCredential)
6975 }
7076}
0 commit comments