@@ -24,6 +24,7 @@ import {
2424 useSignUpAuthFormSchema ,
2525 useForgotPasswordAuthFormSchema ,
2626 useEmailLinkAuthFormSchema ,
27+ useMultiFactorPhoneAuthAssertionNumberFormSchema ,
2728 usePhoneAuthNumberFormSchema ,
2829 usePhoneAuthVerifyFormSchema ,
2930 useRecaptchaVerifier ,
@@ -712,6 +713,116 @@ describe("usePhoneAuthVerifyFormSchema", () => {
712713 } ) ;
713714} ) ;
714715
716+ describe ( "useMultiFactorPhoneAuthAssertionNumberFormSchema" , ( ) => {
717+ beforeEach ( ( ) => {
718+ vi . clearAllMocks ( ) ;
719+ cleanup ( ) ;
720+ } ) ;
721+
722+ it ( "returns schema with default English error messages" , ( ) => {
723+ const mockUI = createMockUI ( ) ;
724+
725+ const { result } = renderHook ( ( ) => useMultiFactorPhoneAuthAssertionNumberFormSchema ( ) , {
726+ wrapper : ( { children } ) => createFirebaseUIProvider ( { children, ui : mockUI } ) ,
727+ } ) ;
728+
729+ const schema = result . current ;
730+
731+ const phoneResult = schema . safeParse ( { phoneNumber : "invalid-phone" } ) ;
732+ expect ( phoneResult . success ) . toBe ( false ) ;
733+ if ( ! phoneResult . success ) {
734+ expect ( phoneResult . error . issues [ 0 ] ! . message ) . toBe ( enUs . translations . errors ! . invalidPhoneNumber ) ;
735+ }
736+ } ) ;
737+
738+ it ( "returns schema with custom error messages when locale changes" , ( ) => {
739+ const customTranslations = {
740+ errors : {
741+ invalidPhoneNumber : "Por favor ingresa un número de teléfono válido" ,
742+ } ,
743+ } ;
744+
745+ const customLocale = registerLocale ( "es-ES" , customTranslations ) ;
746+ const mockUI = createMockUI ( { locale : customLocale } ) ;
747+
748+ const { result } = renderHook ( ( ) => useMultiFactorPhoneAuthAssertionNumberFormSchema ( ) , {
749+ wrapper : ( { children } ) => createFirebaseUIProvider ( { children, ui : mockUI } ) ,
750+ } ) ;
751+
752+ const schema = result . current ;
753+
754+ const phoneResult = schema . safeParse ( { phoneNumber : "invalid-phone" } ) ;
755+ expect ( phoneResult . success ) . toBe ( false ) ;
756+ if ( ! phoneResult . success ) {
757+ expect ( phoneResult . error . issues [ 0 ] ! . message ) . toBe ( "Por favor ingresa un número de teléfono válido" ) ;
758+ }
759+ } ) ;
760+
761+ it ( "returns stable reference when UI hasn't changed" , ( ) => {
762+ const mockUI = createMockUI ( ) ;
763+
764+ const { result, rerender } = renderHook ( ( ) => useMultiFactorPhoneAuthAssertionNumberFormSchema ( ) , {
765+ wrapper : ( { children } ) => createFirebaseUIProvider ( { children, ui : mockUI } ) ,
766+ } ) ;
767+
768+ const initialSchema = result . current ;
769+
770+ rerender ( ) ;
771+
772+ expect ( result . current ) . toBe ( initialSchema ) ;
773+ } ) ;
774+
775+ it ( "returns new schema when locale changes" , ( ) => {
776+ const mockUI = createMockUI ( ) ;
777+
778+ const { result, rerender } = renderHook ( ( ) => useMultiFactorPhoneAuthAssertionNumberFormSchema ( ) , {
779+ wrapper : ( { children } ) => createFirebaseUIProvider ( { children, ui : mockUI } ) ,
780+ } ) ;
781+
782+ const initialSchema = result . current ;
783+
784+ const customTranslations = {
785+ errors : {
786+ invalidPhoneNumber : "Custom phone error" ,
787+ } ,
788+ } ;
789+ const customLocale = registerLocale ( "fr-FR" , customTranslations ) ;
790+
791+ act ( ( ) => {
792+ mockUI . get ( ) . setLocale ( customLocale ) ;
793+ } ) ;
794+
795+ rerender ( ) ;
796+
797+ expect ( result . current ) . not . toBe ( initialSchema ) ;
798+
799+ const phoneResult = result . current . safeParse ( { phoneNumber : "invalid-phone" } ) ;
800+ expect ( phoneResult . success ) . toBe ( false ) ;
801+
802+ if ( ! phoneResult . success ) {
803+ expect ( phoneResult . error . issues [ 0 ] ! . message ) . toBe ( "Custom phone error" ) ;
804+ }
805+ } ) ;
806+
807+ it ( "accepts valid phone number without requiring displayName" , ( ) => {
808+ const mockUI = createMockUI ( ) ;
809+
810+ const { result } = renderHook ( ( ) => useMultiFactorPhoneAuthAssertionNumberFormSchema ( ) , {
811+ wrapper : ( { children } ) => createFirebaseUIProvider ( { children, ui : mockUI } ) ,
812+ } ) ;
813+
814+ const schema = result . current ;
815+
816+ const phoneResult = schema . safeParse ( { phoneNumber : "1234567890" } ) ;
817+ expect ( phoneResult . success ) . toBe ( true ) ;
818+ if ( phoneResult . success ) {
819+ expect ( phoneResult . data ) . toEqual ( { phoneNumber : "1234567890" } ) ;
820+ // Should not have displayName field
821+ expect ( phoneResult . data ) . not . toHaveProperty ( "displayName" ) ;
822+ }
823+ } ) ;
824+ } ) ;
825+
715826describe ( "useRedirectError" , ( ) => {
716827 beforeEach ( ( ) => {
717828 vi . clearAllMocks ( ) ;
0 commit comments