@@ -769,6 +769,10 @@ describe('getDataConnect()', () => {
769769 } ) ;
770770
771771 describe ( 'mutationRef()' , ( ) => {
772+ function generateEmailId ( ) : string {
773+ return `email_id_${ Math . random ( ) * 1000 } ` ;
774+ }
775+
772776 it ( "should fail when executing a mutation which doesn't exist" , async ( ) => {
773777 return getDataConnect ( connectorConfig ) . executeMutation (
774778 'DOES_NOT_EXIST!!!' , optsUnauthorizedClaims
@@ -780,7 +784,7 @@ describe('getDataConnect()', () => {
780784 const resp = await getDataConnect ( connectorConfig )
781785 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
782786 'InsertEmailPublic' ,
783- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
787+ { id : generateEmailId ( ) } ,
784788 optsUnauthorizedClaims
785789 ) ;
786790 expect ( resp . data . email_insert . id ) . to . not . be . undefined ;
@@ -789,31 +793,31 @@ describe('getDataConnect()', () => {
789793 it ( 'should fail to execute a mutation with @auth(level: USER_ANON)' , ( ) => {
790794 return getDataConnect ( connectorConfig ) . executeMutation < InsertEmailResponse , InsertEmailVariables > (
791795 'InsertEmailUserAnon' ,
792- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
796+ { id : generateEmailId ( ) } ,
793797 optsUnauthorizedClaims
794798 ) . should . eventually . be . rejected . and . have . property ( 'code' , 'data-connect/unauthenticated' ) ;
795799 } ) ;
796800
797801 it ( 'should fail to execute a mutation with @auth(level: USER)' , async ( ) => {
798802 return getDataConnect ( connectorConfig ) . executeMutation < InsertEmailResponse , InsertEmailVariables > (
799803 'InsertEmailUser' ,
800- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
804+ { id : generateEmailId ( ) } ,
801805 optsUnauthorizedClaims
802806 ) . should . eventually . be . rejected . and . have . property ( 'code' , 'data-connect/unauthenticated' ) ;
803807 } ) ;
804808
805809 it ( 'should fail to execute a mutation with @auth(level: USER_EMAIL_VERIFIED)' , ( ) => {
806810 return getDataConnect ( connectorConfig ) . executeMutation < InsertEmailResponse , InsertEmailVariables > (
807811 'InsertEmailUserEmailVerified' ,
808- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
812+ { id : generateEmailId ( ) } ,
809813 optsUnauthorizedClaims
810814 ) . should . eventually . be . rejected . and . have . property ( 'code' , 'data-connect/unauthenticated' ) ;
811815 } ) ;
812816
813817 it ( 'should fail to execute a mutation with @auth(level: NO_ACCESS)' , async ( ) => {
814818 return getDataConnect ( connectorConfig ) . executeMutation < InsertEmailResponse , InsertEmailVariables > (
815819 'InsertEmailNoAccess' ,
816- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
820+ { id : generateEmailId ( ) } ,
817821 optsUnauthorizedClaims
818822 ) . should . eventually . be . rejected . and . have . property ( 'code' , 'data-connect/permission-denied' ) ;
819823 } ) ;
@@ -824,7 +828,7 @@ describe('getDataConnect()', () => {
824828 const resp = await getDataConnect ( connectorConfig )
825829 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
826830 'InsertEmailPublic' ,
827- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
831+ { id : generateEmailId ( ) } ,
828832 optsAuthorizedFredAnonClaims
829833 ) ;
830834 expect ( resp . data . email_insert . id ) . to . not . be . undefined ;
@@ -834,7 +838,7 @@ describe('getDataConnect()', () => {
834838 const resp = await getDataConnect ( connectorConfig )
835839 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
836840 'InsertEmailUserAnon' ,
837- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
841+ { id : generateEmailId ( ) } ,
838842 optsAuthorizedFredAnonClaims
839843 ) ;
840844 expect ( resp . data . email_insert . id ) . to . not . be . undefined ;
@@ -843,23 +847,23 @@ describe('getDataConnect()', () => {
843847 it ( 'should fail to execute a mutation with @auth(level: USER)' , async ( ) => {
844848 return getDataConnect ( connectorConfig ) . executeMutation < InsertEmailResponse , InsertEmailVariables > (
845849 'InsertEmailUser' ,
846- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
850+ { id : generateEmailId ( ) } ,
847851 optsAuthorizedFredAnonClaims
848852 ) . should . eventually . be . rejected . and . have . property ( 'code' , 'data-connect/unauthenticated' ) ;
849853 } ) ;
850854
851855 it ( 'should fail to execute a mutation with @auth(level: USER_EMAIL_VERIFIED)' , ( ) => {
852856 return getDataConnect ( connectorConfig ) . executeMutation < InsertEmailResponse , InsertEmailVariables > (
853857 'InsertEmailUserEmailVerified' ,
854- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
858+ { id : generateEmailId ( ) } ,
855859 optsAuthorizedFredAnonClaims
856860 ) . should . eventually . be . rejected . and . have . property ( 'code' , 'data-connect/unauthenticated' ) ;
857861 } ) ;
858862
859863 it ( 'should fail to execute a mutation with @auth(level: NO_ACCESS)' , async ( ) => {
860864 return getDataConnect ( connectorConfig ) . executeMutation < InsertEmailResponse , InsertEmailVariables > (
861865 'InsertEmailNoAccess' ,
862- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
866+ { id : generateEmailId ( ) } ,
863867 optsAuthorizedFredAnonClaims
864868 ) . should . eventually . be . rejected . and . have . property ( 'code' , 'data-connect/permission-denied' ) ;
865869 } ) ;
@@ -868,7 +872,7 @@ describe('getDataConnect()', () => {
868872 const insertResp = await getDataConnect ( connectorConfig )
869873 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
870874 'InsertEmailImpersonation' ,
871- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
875+ { id : generateEmailId ( ) } ,
872876 optsAuthorizedFredAnonClaims
873877 ) ;
874878 expect ( insertResp . data . email_insert . id ) . to . not . be . undefined ;
@@ -886,7 +890,7 @@ describe('getDataConnect()', () => {
886890 const resp = await getDataConnect ( connectorConfig )
887891 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
888892 'InsertEmailPublic' ,
889- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
893+ { id : generateEmailId ( ) } ,
890894 optsAuthorizedFredClaims
891895 ) ;
892896 expect ( resp . data . email_insert . id ) . to . not . be . undefined ;
@@ -896,7 +900,7 @@ describe('getDataConnect()', () => {
896900 const resp = await getDataConnect ( connectorConfig )
897901 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
898902 'InsertEmailUserAnon' ,
899- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
903+ { id : generateEmailId ( ) } ,
900904 optsAuthorizedFredClaims
901905 ) ;
902906 expect ( resp . data . email_insert . id ) . to . not . be . undefined ;
@@ -906,7 +910,7 @@ describe('getDataConnect()', () => {
906910 const resp = await getDataConnect ( connectorConfig )
907911 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
908912 'InsertEmailUser' ,
909- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
913+ { id : generateEmailId ( ) } ,
910914 optsAuthorizedFredClaims
911915 ) ;
912916 expect ( resp . data . email_insert . id ) . to . not . be . undefined ;
@@ -915,15 +919,15 @@ describe('getDataConnect()', () => {
915919 it ( 'should fail to execute a mutation with @auth(level: USER_EMAIL_VERIFIED)' , ( ) => {
916920 return getDataConnect ( connectorConfig ) . executeMutation < InsertEmailResponse , InsertEmailVariables > (
917921 'InsertEmailUserEmailVerified' ,
918- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
922+ { id : generateEmailId ( ) } ,
919923 optsAuthorizedFredClaims
920924 ) . should . eventually . be . rejected . and . have . property ( 'code' , 'data-connect/unauthenticated' ) ;
921925 } ) ;
922926
923927 it ( 'should fail to execute a mutation with @auth(level: NO_ACCESS)' , async ( ) => {
924928 return getDataConnect ( connectorConfig ) . executeMutation < InsertEmailResponse , InsertEmailVariables > (
925929 'InsertEmailNoAccess' ,
926- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
930+ { id : generateEmailId ( ) } ,
927931 optsAuthorizedFredClaims
928932 ) . should . eventually . be . rejected . and . have . property ( 'code' , 'data-connect/permission-denied' ) ;
929933 } ) ;
@@ -932,7 +936,7 @@ describe('getDataConnect()', () => {
932936 const insertResp = await getDataConnect ( connectorConfig )
933937 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
934938 'InsertEmailImpersonation' ,
935- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
939+ { id : generateEmailId ( ) } ,
936940 optsAuthorizedFredClaims
937941 ) ;
938942 expect ( insertResp . data . email_insert . id ) . to . not . be . undefined ;
@@ -950,7 +954,7 @@ describe('getDataConnect()', () => {
950954 const resp = await getDataConnect ( connectorConfig )
951955 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
952956 'InsertEmailPublic' ,
953- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
957+ { id : generateEmailId ( ) } ,
954958 optsAuthorizedFredEmailVerifiedClaims
955959 ) ;
956960 expect ( resp . data . email_insert . id ) . to . not . be . undefined ;
@@ -960,7 +964,7 @@ describe('getDataConnect()', () => {
960964 const resp = await getDataConnect ( connectorConfig )
961965 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
962966 'InsertEmailUserAnon' ,
963- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
967+ { id : generateEmailId ( ) } ,
964968 optsAuthorizedFredEmailVerifiedClaims
965969 ) ;
966970 expect ( resp . data . email_insert . id ) . to . not . be . undefined ;
@@ -970,7 +974,7 @@ describe('getDataConnect()', () => {
970974 const resp = await getDataConnect ( connectorConfig )
971975 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
972976 'InsertEmailUser' ,
973- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
977+ { id : generateEmailId ( ) } ,
974978 optsAuthorizedFredEmailVerifiedClaims
975979 ) ;
976980 expect ( resp . data . email_insert . id ) . to . not . be . undefined ;
@@ -980,7 +984,7 @@ describe('getDataConnect()', () => {
980984 const resp = await getDataConnect ( connectorConfig )
981985 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
982986 'InsertEmailUserEmailVerified' ,
983- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
987+ { id : generateEmailId ( ) } ,
984988 optsAuthorizedFredEmailVerifiedClaims
985989 ) ;
986990 expect ( resp . data . email_insert . id ) . to . not . be . undefined ;
@@ -989,7 +993,7 @@ describe('getDataConnect()', () => {
989993 it ( 'should fail to execute a mutation with @auth(level: NO_ACCESS)' , async ( ) => {
990994 return getDataConnect ( connectorConfig ) . executeMutation < InsertEmailResponse , InsertEmailVariables > (
991995 'InsertEmailNoAccess' ,
992- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
996+ { id : generateEmailId ( ) } ,
993997 optsAuthorizedFredEmailVerifiedClaims
994998 ) . should . eventually . be . rejected . and . have . property ( 'code' , 'data-connect/permission-denied' ) ;
995999 } ) ;
@@ -998,7 +1002,7 @@ describe('getDataConnect()', () => {
9981002 const insertResp = await getDataConnect ( connectorConfig )
9991003 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
10001004 'InsertEmailImpersonation' ,
1001- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
1005+ { id : generateEmailId ( ) } ,
10021006 optsAuthorizedFredEmailVerifiedClaims
10031007 ) ;
10041008 expect ( insertResp . data . email_insert . id ) . to . not . be . undefined ;
@@ -1016,7 +1020,7 @@ describe('getDataConnect()', () => {
10161020 const resp = await getDataConnect ( connectorConfig )
10171021 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
10181022 'InsertEmailPublic' ,
1019- { id : `email_id_ ${ Math . random ( ) * 1000 } ` }
1023+ { id : generateEmailId ( ) }
10201024 ) ;
10211025 expect ( resp . data . email_insert . id ) . to . not . be . undefined ;
10221026 } ) ;
@@ -1025,7 +1029,7 @@ describe('getDataConnect()', () => {
10251029 const resp = await getDataConnect ( connectorConfig )
10261030 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
10271031 'InsertEmailUserAnon' ,
1028- { id : `email_id_ ${ Math . random ( ) * 1000 } ` }
1032+ { id : generateEmailId ( ) }
10291033 ) ;
10301034 expect ( resp . data . email_insert . id ) . to . not . be . undefined ;
10311035 } ) ;
@@ -1034,7 +1038,7 @@ describe('getDataConnect()', () => {
10341038 const resp = await getDataConnect ( connectorConfig )
10351039 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
10361040 'InsertEmailUser' ,
1037- { id : `email_id_ ${ Math . random ( ) * 1000 } ` }
1041+ { id : generateEmailId ( ) }
10381042 ) ;
10391043 expect ( resp . data . email_insert . id ) . to . not . be . undefined ;
10401044 } ) ;
@@ -1043,7 +1047,7 @@ describe('getDataConnect()', () => {
10431047 const resp = await getDataConnect ( connectorConfig )
10441048 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
10451049 'InsertEmailUserEmailVerified' ,
1046- { id : `email_id_ ${ Math . random ( ) * 1000 } ` }
1050+ { id : generateEmailId ( ) }
10471051 ) ;
10481052 expect ( resp . data . email_insert . id ) . to . not . be . undefined ;
10491053 } ) ;
@@ -1052,18 +1056,18 @@ describe('getDataConnect()', () => {
10521056 const resp = await getDataConnect ( connectorConfig )
10531057 . executeMutation < InsertEmailResponse , InsertEmailVariables > (
10541058 'InsertEmailNoAccess' ,
1055- { id : `email_id_ ${ Math . random ( ) * 1000 } ` }
1059+ { id : generateEmailId ( ) }
10561060 ) ;
10571061 expect ( resp . data . email_insert . id ) . to . not . be . undefined ;
10581062 } ) ;
10591063
10601064 it ( "should fail to execute a mutation using the impersonated user's auth.uid" , async ( ) => {
10611065 return getDataConnect ( connectorConfig ) . executeMutation < InsertEmailResponse , InsertEmailVariables > (
10621066 'InsertEmailImpersonation' ,
1063- { id : `email_id_ ${ Math . random ( ) * 1000 } ` } ,
1067+ { id : generateEmailId ( ) } ,
10641068 ) . should . eventually . be . rejected . and . have . property ( 'code' , 'data-connect/query-error' ) ;
10651069 } ) ;
10661070 } ) ;
10671071 } ) ;
10681072 } ) ;
1069- } ) ;
1073+ } ) ;
0 commit comments