@@ -7083,6 +7083,77 @@ describe('ParseGraphQLServer', () => {
7083
7083
expect ( result . data . requestResetPassword . clientMutationId ) . toEqual ( clientMutationId ) ;
7084
7084
expect ( result . data . requestResetPassword . ok ) . toBeTruthy ( ) ;
7085
7085
} ) ;
7086
+
7087
+ it ( 'should reset password' , async ( ) => {
7088
+ const clientMutationId = uuidv4 ( ) ;
7089
+ let resetPasswordToken ;
7090
+ const emailAdapter = {
7091
+ sendVerificationEmail : ( ) => { } ,
7092
+ sendPasswordResetEmail : ( { link } ) => {
7093
+ resetPasswordToken = link . split ( 'token=' ) [ 1 ] . split ( '&' ) [ 0 ] ;
7094
+ } ,
7095
+ sendMail : ( ) => { } ,
7096
+ } ;
7097
+ parseServer = await global . reconfigureServer ( {
7098
+ appName : 'test' ,
7099
+ emailAdapter : emailAdapter ,
7100
+ publicServerURL : 'http://localhost:13377/parse' ,
7101
+ auth : {
7102
+ myAuth : {
7103
+ module : global . mockCustomAuthenticator ( 'parse' , 'graphql' ) ,
7104
+ } ,
7105
+ } ,
7106
+ } ) ;
7107
+ const user = new Parse . User ( ) ;
7108
+ user . setUsername ( 'user1' ) ;
7109
+ user . setPassword ( 'user1' ) ;
7110
+ user . setEmail ( '[email protected] ' ) ;
7111
+ await user . signUp ( ) ;
7112
+ await Parse . User . logOut ( ) ;
7113
+ await Parse . User . requestPasswordReset ( '[email protected] ' ) ;
7114
+ await apolloClient . mutate ( {
7115
+ mutation : gql `
7116
+ mutation ResetPassword($input: ResetPasswordInput!) {
7117
+ resetPassword(input: $input) {
7118
+ clientMutationId
7119
+ ok
7120
+ }
7121
+ }
7122
+ ` ,
7123
+ variables : {
7124
+ input : {
7125
+ clientMutationId,
7126
+ username : 'user1' ,
7127
+ password : 'newPassword' ,
7128
+ token : resetPasswordToken ,
7129
+ } ,
7130
+ } ,
7131
+ } ) ;
7132
+ const result = await apolloClient . mutate ( {
7133
+ mutation : gql `
7134
+ mutation LogInUser($input: LogInInput!) {
7135
+ logIn(input: $input) {
7136
+ clientMutationId
7137
+ viewer {
7138
+ sessionToken
7139
+ }
7140
+ }
7141
+ }
7142
+ ` ,
7143
+ variables : {
7144
+ input : {
7145
+ clientMutationId,
7146
+ username : 'user1' ,
7147
+ password : 'newPassword' ,
7148
+ } ,
7149
+ } ,
7150
+ } ) ;
7151
+
7152
+ expect ( result . data . logIn . clientMutationId ) . toEqual ( clientMutationId ) ;
7153
+ expect ( result . data . logIn . viewer . sessionToken ) . toBeDefined ( ) ;
7154
+ expect ( typeof result . data . logIn . viewer . sessionToken ) . toBe ( 'string' ) ;
7155
+ } ) ;
7156
+
7086
7157
it ( 'should send verification email again' , async ( ) => {
7087
7158
const clientMutationId = uuidv4 ( ) ;
7088
7159
const emailAdapter = {
0 commit comments