@@ -352,6 +352,84 @@ describe('SignInFactorOne', () => {
352352 ) ,
353353 ) . not . toBeInTheDocument ( ) ;
354354 } ) ;
355+
356+ it ( 'using an untrusted password should show the untrusted password screen' , async ( ) => {
357+ const { wrapper, fixtures } = await createFixtures ( f => {
358+ f . withEmailAddress ( ) ;
359+ f . withPassword ( ) ;
360+ f . withPreferredSignInStrategy ( { strategy : 'password' } ) ;
361+ f . startSignInWithEmailAddress ( {
362+ supportEmailCode : true ,
363+ supportPassword : true ,
364+ supportResetPassword : true ,
365+ } ) ;
366+ } ) ;
367+ fixtures . signIn . prepareFirstFactor . mockReturnValueOnce ( Promise . resolve ( { } as SignInResource ) ) ;
368+
369+ const errJSON = {
370+ code : 'form_password_untrusted' ,
371+ long_message :
372+ "Your appears to have been compromised or it's no longer trusted and cannot be used. Please use another method to continue." ,
373+ message :
374+ "Your appears to have been compromised or it's no longer trusted and cannot be used. Please use another method to continue." ,
375+ meta : { param_name : 'password' } ,
376+ } ;
377+
378+ fixtures . signIn . attemptFirstFactor . mockRejectedValueOnce (
379+ new ClerkAPIResponseError ( 'Error' , {
380+ data : [ errJSON ] ,
381+ status : 422 ,
382+ } ) ,
383+ ) ;
384+ const { userEvent } = render ( < SignInFactorOne /> , { wrapper } ) ;
385+ await userEvent . type ( screen . getByLabelText ( 'Password' ) , '123456' ) ;
386+ await userEvent . click ( screen . getByText ( 'Continue' ) ) ;
387+
388+ await screen . findByText ( 'Password compromised' ) ;
389+ await screen . findByText (
390+ "Your appears to have been compromised or it's no longer trusted and cannot be used. Please use another method to continue." ,
391+ ) ;
392+
393+ await screen . findByText ( 'Email code to [email protected] ' ) ; 394+ } ) ;
395+
396+ it ( 'Prompts the user to use a different method if the password is untrusted' , async ( ) => {
397+ const { wrapper, fixtures } = await createFixtures ( f => {
398+ f . withEmailAddress ( ) ;
399+ f . withPassword ( ) ;
400+ f . withPreferredSignInStrategy ( { strategy : 'password' } ) ;
401+ f . withSocialProvider ( { provider : 'google' , authenticatable : true } ) ;
402+ f . startSignInWithEmailAddress ( {
403+ supportEmailCode : true ,
404+ supportPassword : true ,
405+ supportResetPassword : true ,
406+ } ) ;
407+ } ) ;
408+ fixtures . signIn . prepareFirstFactor . mockReturnValueOnce ( Promise . resolve ( { } as SignInResource ) ) ;
409+
410+ const errJSON = {
411+ code : 'form_password_untrusted' ,
412+ long_message :
413+ "Your appears to have been compromised or it's no longer trusted and cannot be used. Please use another method to continue." ,
414+ message :
415+ "Your appears to have been compromised or it's no longer trusted and cannot be used. Please use another method to continue." ,
416+ meta : { param_name : 'password' } ,
417+ } ;
418+
419+ fixtures . signIn . attemptFirstFactor . mockRejectedValueOnce (
420+ new ClerkAPIResponseError ( 'Error' , {
421+ data : [ errJSON ] ,
422+ status : 422 ,
423+ } ) ,
424+ ) ;
425+ const { userEvent } = render ( < SignInFactorOne /> , { wrapper } ) ;
426+ await userEvent . type ( screen . getByLabelText ( 'Password' ) , '123456' ) ;
427+ await userEvent . click ( screen . getByText ( 'Continue' ) ) ;
428+
429+ await screen . findByText ( 'Password compromised' ) ;
430+ await userEvent . click ( screen . getByText ( 'Email code to [email protected] ' ) ) ; 431+ await screen . findByText ( 'Check your email' ) ;
432+ } ) ;
355433 } ) ;
356434
357435 describe ( 'Forgot Password' , ( ) => {
@@ -1003,87 +1081,4 @@ describe('SignInFactorOne', () => {
10031081 } ) ;
10041082 } ) ;
10051083 } ) ;
1006-
1007- describe ( 'Password untrusted' , ( ) => {
1008- it ( 'it shows the untrusted password screen if the users password is untrusted' , async ( ) => {
1009- const { wrapper, fixtures } = await createFixtures ( f => {
1010- f . withEmailAddress ( ) ;
1011- f . withPassword ( ) ;
1012- f . withPreferredSignInStrategy ( { strategy : 'password' } ) ;
1013- f . withSocialProvider ( { provider : 'google' , authenticatable : true } ) ;
1014- f . startSignInWithEmailAddress ( {
1015- supportEmailCode : true ,
1016- supportPassword : true ,
1017- supportResetPassword : true ,
1018- } ) ;
1019- } ) ;
1020- fixtures . signIn . prepareFirstFactor . mockReturnValueOnce ( Promise . resolve ( { } as SignInResource ) ) ;
1021-
1022- const errJSON = {
1023- code : 'form_password_untrusted' ,
1024- long_message :
1025- "Your appears to have been compromised or it's no longer trusted and cannot be used. Please use another method to continue." ,
1026- message :
1027- "Your appears to have been compromised or it's no longer trusted and cannot be used. Please use another method to continue." ,
1028- meta : { param_name : 'password' } ,
1029- } ;
1030-
1031- fixtures . signIn . attemptFirstFactor . mockRejectedValueOnce (
1032- new ClerkAPIResponseError ( 'Error' , {
1033- data : [ errJSON ] ,
1034- status : 422 ,
1035- } ) ,
1036- ) ;
1037- const { userEvent } = render ( < SignInFactorOne /> , { wrapper } ) ;
1038- await userEvent . type ( screen . getByLabelText ( 'Password' ) , '123456' ) ;
1039- await userEvent . click ( screen . getByText ( 'Continue' ) ) ;
1040-
1041- await screen . findByText ( 'Password compromised' ) ;
1042- await screen . findByText (
1043- "Your appears to have been compromised or it's no longer trusted and cannot be used. Please use another method to continue." ,
1044- ) ;
1045-
1046- await screen . findByText ( 'Email code to [email protected] ' ) ; 1047- await screen . findByText ( 'Continue with Google' ) ;
1048- } ) ;
1049-
1050- it ( 'clicking the email code method should prompt the user to verify their email' , async ( ) => {
1051- const { wrapper, fixtures } = await createFixtures ( f => {
1052- f . withEmailAddress ( ) ;
1053- f . withPassword ( ) ;
1054- f . withPreferredSignInStrategy ( { strategy : 'password' } ) ;
1055- f . withSocialProvider ( { provider : 'google' , authenticatable : true } ) ;
1056- f . startSignInWithEmailAddress ( {
1057- supportEmailCode : true ,
1058- supportPassword : true ,
1059- supportResetPassword : true ,
1060- supportEmailLink : true ,
1061- } ) ;
1062- } ) ;
1063- fixtures . signIn . prepareFirstFactor . mockReturnValueOnce ( Promise . resolve ( { } as SignInResource ) ) ;
1064-
1065- const errJSON = {
1066- code : 'form_password_untrusted' ,
1067- long_message :
1068- "Your appears to have been compromised or it's no longer trusted and cannot be used. Please use another method to continue." ,
1069- message :
1070- "Your appears to have been compromised or it's no longer trusted and cannot be used. Please use another method to continue." ,
1071- meta : { param_name : 'password' } ,
1072- } ;
1073-
1074- fixtures . signIn . attemptFirstFactor . mockRejectedValueOnce (
1075- new ClerkAPIResponseError ( 'Error' , {
1076- data : [ errJSON ] ,
1077- status : 422 ,
1078- } ) ,
1079- ) ;
1080- const { userEvent } = render ( < SignInFactorOne /> , { wrapper } ) ;
1081- await userEvent . type ( screen . getByLabelText ( 'Password' ) , '123456' ) ;
1082- await userEvent . click ( screen . getByText ( 'Continue' ) ) ;
1083-
1084- await screen . findByText ( 'Password compromised' ) ;
1085- await userEvent . click ( screen . getByText ( 'Email code to [email protected] ' ) ) ; 1086- await screen . findByText ( 'Check your email' ) ;
1087- } ) ;
1088- } ) ;
10891084} ) ;
0 commit comments