@@ -220,6 +220,73 @@ class AuthenticatorViewModelTest {
220220 viewModel.currentStep shouldBe AuthenticatorStep .SignInConfirmTotpCode
221221 }
222222
223+ @Test
224+ fun `SMS MFA Code next step shows the SignInConfirmMfa screen` () = runTest {
225+ coEvery { authProvider.fetchAuthSession() } returns Success (mockAuthSession(isSignedIn = false ))
226+ coEvery { authProvider.signIn(any(), any()) } returns Success (
227+ mockSignInResult(signInStep = AuthSignInStep .CONFIRM_SIGN_IN_WITH_SMS_MFA_CODE )
228+ )
229+
230+ viewModel.start(mockAuthenticatorConfiguration(initialStep = AuthenticatorStep .SignIn ))
231+
232+ viewModel.signIn(" username" , " password" )
233+ viewModel.currentStep shouldBe AuthenticatorStep .SignInConfirmMfa
234+ }
235+
236+ @Test
237+ fun `Custom Challenge next step shows the SignInConfirmCustomAuth screen` () = runTest {
238+ coEvery { authProvider.fetchAuthSession() } returns Success (mockAuthSession(isSignedIn = false ))
239+ coEvery { authProvider.signIn(any(), any()) } returns Success (
240+ mockSignInResult(signInStep = AuthSignInStep .CONFIRM_SIGN_IN_WITH_CUSTOM_CHALLENGE )
241+ )
242+
243+ viewModel.start(mockAuthenticatorConfiguration(initialStep = AuthenticatorStep .SignIn ))
244+
245+ viewModel.signIn(" username" , " password" )
246+ viewModel.currentStep shouldBe AuthenticatorStep .SignInConfirmCustomAuth
247+ }
248+
249+ @Test
250+ fun `New Password next step shows the SignInConfirmNewPassword screen` () = runTest {
251+ coEvery { authProvider.fetchAuthSession() } returns Success (mockAuthSession(isSignedIn = false ))
252+ coEvery { authProvider.signIn(any(), any()) } returns Success (
253+ mockSignInResult(signInStep = AuthSignInStep .CONFIRM_SIGN_IN_WITH_NEW_PASSWORD )
254+ )
255+
256+ viewModel.start(mockAuthenticatorConfiguration(initialStep = AuthenticatorStep .SignIn ))
257+
258+ viewModel.signIn(" username" , " password" )
259+ viewModel.currentStep shouldBe AuthenticatorStep .SignInConfirmNewPassword
260+ }
261+
262+ @Test
263+ fun `Confirm SignUp next step, get error from resendSignUpCode, stays in SignIn screen` () = runTest {
264+ coEvery { authProvider.fetchAuthSession() } returns Success (mockAuthSession(isSignedIn = false ))
265+ coEvery { authProvider.signIn(any(), any()) } returns Success (
266+ mockSignInResult(signInStep = AuthSignInStep .CONFIRM_SIGN_UP )
267+ )
268+ coEvery { authProvider.resendSignUpCode(any()) } returns AmplifyResult .Error (mockAuthException())
269+
270+ viewModel.start(mockAuthenticatorConfiguration(initialStep = AuthenticatorStep .SignIn ))
271+
272+ viewModel.signIn(" username" , " password" )
273+ viewModel.currentStep shouldBe AuthenticatorStep .SignIn
274+ }
275+
276+ @Test
277+ fun `Confirm SignUp next step shows the SignUpConfirm screen` () = runTest {
278+ coEvery { authProvider.fetchAuthSession() } returns Success (mockAuthSession(isSignedIn = false ))
279+ coEvery { authProvider.signIn(any(), any()) } returns Success (
280+ mockSignInResult(signInStep = AuthSignInStep .CONFIRM_SIGN_UP )
281+ )
282+ coEvery { authProvider.resendSignUpCode(any()) } returns Success (mockk())
283+
284+ viewModel.start(mockAuthenticatorConfiguration(initialStep = AuthenticatorStep .SignIn ))
285+
286+ viewModel.signIn(" username" , " password" )
287+ viewModel.currentStep shouldBe AuthenticatorStep .SignUpConfirm
288+ }
289+
223290 @Test
224291 fun `MFA selection next step shows error if allowedMFATypes is null` () = runTest {
225292 coEvery { authProvider.fetchAuthSession() } returns Success (mockAuthSession(isSignedIn = false ))
0 commit comments