Skip to content

Commit 16ce089

Browse files
chore: previews for enrolment
1 parent 3de264f commit 16ce089

File tree

1 file changed

+54
-3
lines changed

1 file changed

+54
-3
lines changed

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/MFAEnrolmentView.swift

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
import FirebaseAuth
16+
import FirebaseCore
1617
import SwiftUI
1718

1819
private enum FocusableField: Hashable {
@@ -583,7 +584,57 @@ extension MFAEnrolmentView: View {
583584
}
584585
}
585586

586-
#Preview {
587-
MFAEnrolmentView()
588-
.environment(AuthService())
587+
#Preview("MFA Enabled - Both Methods") {
588+
FirebaseOptions.dummyConfigurationForPreview()
589+
let config = AuthConfiguration(
590+
mfaEnabled: true,
591+
allowedSecondFactors: [.sms, .totp]
592+
)
593+
let authService = AuthService(configuration: config)
594+
return MFAEnrolmentView()
595+
.environment(authService)
596+
}
597+
598+
#Preview("MFA Disabled") {
599+
FirebaseOptions.dummyConfigurationForPreview()
600+
let config = AuthConfiguration(
601+
mfaEnabled: false,
602+
allowedSecondFactors: []
603+
)
604+
let authService = AuthService(configuration: config)
605+
return MFAEnrolmentView()
606+
.environment(authService)
607+
}
608+
609+
#Preview("No Allowed Factors") {
610+
FirebaseOptions.dummyConfigurationForPreview()
611+
let config = AuthConfiguration(
612+
mfaEnabled: true,
613+
allowedSecondFactors: []
614+
)
615+
let authService = AuthService(configuration: config)
616+
return MFAEnrolmentView()
617+
.environment(authService)
618+
}
619+
620+
#Preview("SMS Only") {
621+
FirebaseOptions.dummyConfigurationForPreview()
622+
let config = AuthConfiguration(
623+
mfaEnabled: true,
624+
allowedSecondFactors: [.sms]
625+
)
626+
let authService = AuthService(configuration: config)
627+
return MFAEnrolmentView()
628+
.environment(authService)
629+
}
630+
631+
#Preview("TOTP Only") {
632+
FirebaseOptions.dummyConfigurationForPreview()
633+
let config = AuthConfiguration(
634+
mfaEnabled: true,
635+
allowedSecondFactors: [.totp]
636+
)
637+
let authService = AuthService(configuration: config)
638+
return MFAEnrolmentView()
639+
.environment(authService)
589640
}

0 commit comments

Comments
 (0)