@@ -102,19 +102,22 @@ describe('SignInFactorOneCodeForm', () => {
102102 ) ;
103103 } ) ;
104104
105- it ( 'still calls prepare when factor is already prepared but verification not verified ' , async ( ) => {
106- const { wrapper } = await createFixtures ( f => {
105+ it ( 'skips automatic prepare when the same factor verification is pending ' , async ( ) => {
106+ const { wrapper, fixtures } = await createFixtures ( f => {
107107 f . withPhoneNumber ( ) ;
108108 f . startSignInWithPhoneNumber ( { supportPhoneCode : true } ) ;
109109 } ) ;
110+ fixtures . signIn . firstFactorVerification . status = 'unverified' ;
111+ fixtures . signIn . firstFactorVerification . strategy = 'phone_code' ;
112+ fixtures . signIn . firstFactorVerification . channel = 'sms' ;
110113
111114 const props = {
112115 factor : {
113116 strategy : 'phone_code' as const ,
114117 phoneNumberId : 'idn_123' ,
115118 safeIdentifier : '+1234567890' ,
116119 } ,
117- factorAlreadyPrepared : true ,
120+ factorAlreadyPrepared : false ,
118121 onFactorPrepare : vi . fn ( ) ,
119122 cardTitle : localizationKeys ( 'signIn.phoneCode.title' ) ,
120123 cardSubtitle : localizationKeys ( 'signIn.phoneCode.subtitle' ) ,
@@ -124,16 +127,18 @@ describe('SignInFactorOneCodeForm', () => {
124127
125128 renderWithProviders ( < SignInFactorOneCodeForm { ...props } /> , { wrapper } ) ;
126129
127- expect ( vi . mocked ( useFetch ) ) . toHaveBeenCalledWith ( expect . any ( Function ) , expect . any ( Object ) , expect . any ( Object ) ) ;
130+ expect ( vi . mocked ( useFetch ) ) . toHaveBeenCalledWith ( undefined , expect . any ( Object ) , expect . any ( Object ) ) ;
128131 } ) ;
129132 } ) ;
130133
131134 describe ( 'shouldAvoidPrepare Logic' , ( ) => {
132- it ( 'still calls prepare when factor is already prepared but verification not verified ' , async ( ) => {
133- const { wrapper } = await createFixtures ( f => {
135+ it ( 'allows prepare when the same factor verification is expired ' , async ( ) => {
136+ const { wrapper, fixtures } = await createFixtures ( f => {
134137 f . withPhoneNumber ( ) ;
135138 f . startSignInWithPhoneNumber ( { supportPhoneCode : true } ) ;
136139 } ) ;
140+ fixtures . signIn . firstFactorVerification . status = 'expired' ;
141+ fixtures . signIn . firstFactorVerification . strategy = 'phone_code' ;
137142
138143 const propsWithFactorPrepared = {
139144 ...defaultProps ,
@@ -142,11 +147,7 @@ describe('SignInFactorOneCodeForm', () => {
142147
143148 renderWithProviders ( < SignInFactorOneCodeForm { ...propsWithFactorPrepared } /> , { wrapper } ) ;
144149
145- expect ( vi . mocked ( useFetch ) ) . toHaveBeenCalledWith (
146- expect . any ( Function ) , // fetcher should still be a function because shouldAvoidPrepare requires BOTH conditions
147- expect . any ( Object ) ,
148- expect . any ( Object ) ,
149- ) ;
150+ expect ( vi . mocked ( useFetch ) ) . toHaveBeenCalledWith ( expect . any ( Function ) , expect . any ( Object ) , expect . any ( Object ) ) ;
150151 } ) ;
151152
152153 it ( 'allows prepare when factor is not already prepared' , async ( ) => {
0 commit comments