@@ -1313,6 +1313,46 @@ describe('Clerk singleton', () => {
13131313 expect ( mockNavigate ) . toHaveBeenCalledWith ( '/sign-in#/factor-one' ) ;
13141314 } ) ;
13151315 } ) ;
1316+
1317+ it ( 'redirects user to reset-password, if the user is required to set a new password' , async ( ) => {
1318+ mockEnvironmentFetch . mockReturnValue (
1319+ Promise . resolve ( {
1320+ authConfig : { } ,
1321+ userSettings : mockUserSettings ,
1322+ displayConfig : mockDisplayConfig ,
1323+ isSingleSession : ( ) => false ,
1324+ isProduction : ( ) => false ,
1325+ isDevelopmentOrStaging : ( ) => true ,
1326+ } ) ,
1327+ ) ;
1328+
1329+ mockClientFetch . mockReturnValue (
1330+ Promise . resolve ( {
1331+ activeSessions : [ ] ,
1332+ signIn : new SignIn ( {
1333+ status : 'needs_new_password' ,
1334+ } as unknown as SignInJSON ) ,
1335+ signUp : new SignUp ( null ) ,
1336+ } ) ,
1337+ ) ;
1338+
1339+ const mockSignInCreate = jest . fn ( ) . mockReturnValue ( Promise . resolve ( { status : 'needs_new_password' } ) ) ;
1340+
1341+ const sut = new Clerk ( frontendApi ) ;
1342+ await sut . load ( {
1343+ navigate : mockNavigate ,
1344+ } ) ;
1345+ if ( ! sut . client ) {
1346+ fail ( 'we should always have a client' ) ;
1347+ }
1348+ sut . client . signIn . create = mockSignInCreate ;
1349+
1350+ await sut . handleRedirectCallback ( ) ;
1351+
1352+ await waitFor ( ( ) => {
1353+ expect ( mockNavigate ) . toHaveBeenCalledWith ( '/sign-in#/reset-password' ) ;
1354+ } ) ;
1355+ } ) ;
13161356 } ) ;
13171357
13181358 describe ( '.handleMagicLinkVerification()' , ( ) => {
0 commit comments