@@ -847,6 +847,67 @@ describe('Pages Router', () => {
847847 ) ;
848848 } ) ;
849849
850+ it ( 'localizes end-to-end for verify email: invalid verification link - link send fail with emailVerifySuccessOnInvalidEmail disabled' , async ( ) => {
851+ config . emailVerifySuccessOnInvalidEmail = false ;
852+ await reconfigureServer ( config ) ;
853+ const sendVerificationEmail = spyOn (
854+ config . emailAdapter ,
855+ 'sendVerificationEmail'
856+ ) . and . callThrough ( ) ;
857+ const user = new Parse . User ( ) ;
858+ user . setUsername ( 'exampleUsername' ) ;
859+ user . setPassword ( 'examplePassword' ) ;
860+ user . set ( 'email' , 'mail@example.com' ) ;
861+ await user . signUp ( ) ;
862+ await jasmine . timeout ( ) ;
863+
864+ const link = sendVerificationEmail . calls . all ( ) [ 0 ] . args [ 0 ] . link ;
865+ const linkWithLocale = new URL ( link ) ;
866+ linkWithLocale . searchParams . append ( pageParams . locale , exampleLocale ) ;
867+ linkWithLocale . searchParams . set ( pageParams . token , 'invalidToken' ) ;
868+
869+ const linkResponse = await request ( {
870+ url : linkWithLocale . toString ( ) ,
871+ followRedirects : false ,
872+ } ) ;
873+ expect ( linkResponse . status ) . toBe ( 200 ) ;
874+
875+ const appId = linkResponse . headers [ 'x-parse-page-param-appid' ] ;
876+ const locale = linkResponse . headers [ 'x-parse-page-param-locale' ] ;
877+ const publicServerUrl = linkResponse . headers [ 'x-parse-page-param-publicserverurl' ] ;
878+ await jasmine . timeout ( ) ;
879+
880+ const invalidVerificationPagePath = pageResponse . calls . all ( ) [ 0 ] . args [ 0 ] ;
881+ expect ( appId ) . toBeDefined ( ) ;
882+ expect ( locale ) . toBe ( exampleLocale ) ;
883+ expect ( publicServerUrl ) . toBeDefined ( ) ;
884+ expect ( invalidVerificationPagePath ) . toMatch (
885+ new RegExp ( `\/${ exampleLocale } \/${ pages . emailVerificationLinkInvalid . defaultFile } ` )
886+ ) ;
887+
888+ spyOn ( UserController . prototype , 'resendVerificationEmail' ) . and . callFake ( ( ) =>
889+ Promise . reject ( 'failed to resend verification email' )
890+ ) ;
891+
892+ const formUrl = `${ publicServerUrl } /apps/${ appId } /resend_verification_email` ;
893+ const formResponse = await request ( {
894+ url : formUrl ,
895+ method : 'POST' ,
896+ body : {
897+ locale,
898+ username : 'exampleUsername' ,
899+ } ,
900+ headers : { 'Content-Type' : 'application/x-www-form-urlencoded' } ,
901+ followRedirects : false ,
902+ } ) ;
903+ expect ( formResponse . status ) . toEqual ( 303 ) ;
904+ // With emailVerifySuccessOnInvalidEmail: false, the resend page
905+ // redirects to the fail page
906+ expect ( formResponse . text ) . toContain (
907+ `/${ locale } /${ pages . emailVerificationSendFail . defaultFile } `
908+ ) ;
909+ } ) ;
910+
850911 it ( 'localizes end-to-end for resend verification email: invalid link' , async ( ) => {
851912 await reconfigureServer ( config ) ;
852913 const formUrl = `${ config . publicServerURL } /apps/${ config . appId } /resend_verification_email` ;
0 commit comments